summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <ssp@redhat.com>2012-06-15 10:35:10 -0400
committerSøren Sandmann Pedersen <ssp@redhat.com>2012-06-15 10:35:10 -0400
commitc366ecb5e7c68149ec6e0709542396a54ec6e0cc (patch)
tree300af75161db82862ac012bbd1feb7ca0c0f39b2
parent162ffd529a3316416b91f8c1db92fbea93b027fe (diff)
Fix bug in graph_boolean_expression()
When the expression is known to be compile-time constant, its value is stored in expr->common.constant_value, but the code was treating the expression as if it were a boolean literal.
-rw-r--r--examples/ret.nl11
-rw-r--r--graph.c3
2 files changed, 11 insertions, 3 deletions
diff --git a/examples/ret.nl b/examples/ret.nl
index d485577..39aaf54 100644
--- a/examples/ret.nl
+++ b/examples/ret.nl
@@ -1,2 +1,11 @@
-fn () -> bool { return true; };
+nonvoid () -> int32
+{
+ if (false && false)
+ goto out;
+ return 10;
+@out:
+
+}
+
+nonvoid();
diff --git a/graph.c b/graph.c
index 8ced084..5ddabd8 100644
--- a/graph.c
+++ b/graph.c
@@ -158,7 +158,7 @@ graph_boolean_expression (ast_expression_t *expr,
if (expr->common.constant)
{
- if (expr->bool_literal.value)
+ if (expr->common.constant_value.bool_val)
node = node_new_goto (&true->label, node, ast);
else
node = node_new_goto (&false->label, node, ast);
@@ -183,7 +183,6 @@ graph_boolean_expression (ast_expression_t *expr,
if (expr->binary.operator == AST_OR)
{
- g_print ("wsat\n");
node_t *fallthru = node_new_label (NULL, ast);
node = graph_boolean_expression (