From 2ae910750b2c9fd417899cb4563f996b07323bce Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Fri, 27 Sep 2019 20:04:09 +0100 Subject: [PATCH] Put generate case item block names in correct scope. The compiler creates an artificial scope around the case items. We need to add the block names to the real containing scope. --- pform.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pform.cc b/pform.cc index 17ad83d60..fa44f4a28 100644 --- a/pform.cc +++ b/pform.cc @@ -1567,8 +1567,13 @@ void pform_generate_block_name(char*name) conditional_block_names.front().insert(scope_name); } - add_local_symbol(pform_cur_generate->parent_scope(), - scope_name, pform_cur_generate); + LexicalScope*parent_scope = pform_cur_generate->parent_scope(); + assert(parent_scope); + if (pform_cur_generate->scheme_type == PGenerate::GS_CASE_ITEM) + // Skip over the PGenerate::GS_CASE container. + parent_scope = parent_scope->parent_scope(); + + add_local_symbol(parent_scope, scope_name, pform_cur_generate); } void pform_endgenerate(bool end_conditional)