summaryrefslogtreecommitdiff
path: root/ortho/gcc
diff options
context:
space:
mode:
authorBrian Drummond2013-12-03 13:34:44 +0000
committerBrian Drummond2013-12-03 13:34:44 +0000
commit65e61ca45081ed4f19bfd9ee0a50fee4f0d0359b (patch)
tree0499df940b474d2c61ccaafd8daddedb8bfd8074 /ortho/gcc
parent242ee7a30d0ac1d5d5b7e59d5206f1cef30d1435 (diff)
downloadghdl-65e61ca45081ed4f19bfd9ee0a50fee4f0d0359b.tar.gz
ghdl-65e61ca45081ed4f19bfd9ee0a50fee4f0d0359b.tar.bz2
ghdl-65e61ca45081ed4f19bfd9ee0a50fee4f0d0359b.zip
Fix for catastrophic error in ortho-lang.c handling nested case statements. This error is present in revisions 137 to 140.
Diffstat (limited to 'ortho/gcc')
-rw-r--r--ortho/gcc/ortho-lang.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/ortho/gcc/ortho-lang.c b/ortho/gcc/ortho-lang.c
index 3c0dbe9..22e303a 100644
--- a/ortho/gcc/ortho-lang.c
+++ b/ortho/gcc/ortho-lang.c
@@ -2061,8 +2061,8 @@ struct GTY(()) o_case_block
int add_break;
};
-
-static GTY(()) tree t_condtype;
+static GTY(()) tree t_condtype = NULL_TREE;
+static vec <tree> t_condtype_stack = vec<tree>();
void
start_case_stmt (struct o_case_block *block, tree value)
@@ -2072,7 +2072,12 @@ start_case_stmt (struct o_case_block *block, tree value)
// following https://bitbucket.org/goshawk/gdc/issue/344/compilation-with-latest-trunk-fails
// gimplify_switch_expr now checks type of index expr is (some discrete type) but at least not void
-// Saved in static variable for start_choice to use
+// Saved in static variable t_condtype for start_choice to use
+//
+// Static variable is inadequate : nested Case statements won't work, so we either:
+// need to stack t_condtypes, or add a parameter to start_choice, which affects
+// translation.adb and the interface to ALL backends, mcode etc. I think this is less ugly.
+ t_condtype_stack.safe_push(t_condtype);
t_condtype = TREE_TYPE(value);
block->end_label = build_label ();
@@ -2142,8 +2147,8 @@ finish_case_stmt (struct o_case_block *block)
pop_stmts ();
stmt = build1 (LABEL_EXPR, void_type_node, block->end_label);
append_stmt (stmt);
-
- t_condtype = NULL_TREE;
+// see start_case_stmt : restore t_condtype to handle outer case statement
+ t_condtype = t_condtype_stack.pop();
}
bool