From 7edc71a78916cdeb2f8e850615cff19659ce97a7 Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Sat, 26 Jul 2008 08:06:04 +0000 Subject: [PATCH] - BugFix: although tarval_b_false and tarval_b_true are reserved tarvals, they are valid constants [r20704] --- ir/tv/tv.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/ir/tv/tv.c b/ir/tv/tv.c index ef1ea63b9..f52f14218 100644 --- a/ir/tv/tv.c +++ b/ir/tv/tv.c @@ -281,10 +281,10 @@ static tarval *get_tarval_overflow(const void *value, int length, ir_mode *mode) */ static tarval reserved_tv[6]; -tarval *tarval_bad = &reserved_tv[0]; -tarval *tarval_undefined = &reserved_tv[1]; -tarval *tarval_b_false = &reserved_tv[2]; -tarval *tarval_b_true = &reserved_tv[3]; +tarval *tarval_b_false = &reserved_tv[0]; +tarval *tarval_b_true = &reserved_tv[1]; +tarval *tarval_bad = &reserved_tv[2]; +tarval *tarval_undefined = &reserved_tv[3]; tarval *tarval_reachable = &reserved_tv[4]; tarval *tarval_unreachable = &reserved_tv[5]; @@ -649,8 +649,9 @@ tarval *get_tarval_all_one(ir_mode *mode) { int tarval_is_constant(tarval *tv) { int num_res = sizeof(reserved_tv) / sizeof(reserved_tv[0]); - /* reserved tarvals are NOT constants */ - return (tv < &reserved_tv[0] || tv > &reserved_tv[num_res - 1]); + /* reserved tarvals are NOT constants. Note that although + tarval_b_true and tarval_b_false are reserved, they are constants of course. */ + return (tv < &reserved_tv[2] || tv > &reserved_tv[num_res - 1]); } tarval *get_tarval_minus_one(ir_mode *mode) { @@ -1804,6 +1805,10 @@ static const tarval_mode_info hex_output = { * Initialization of the tarval module: called before init_mode() */ void init_tarval_1(long null_value) { + /* if these assertion fail, tarval_is_constant() will follow ... */ + assert(tarval_b_false == &reserved_tv[0] && "b_false MUST be the first reserved tarval!"); + assert(tarval_b_true == &reserved_tv[1] && "b_true MUST be the second reserved tarval!"); + _null_value = null_value; /* initialize the sets holding the tarvals with a comparison function and -- 2.20.1