Repository navigation
Initial support for C++26 enumerating expansion statements (IL CHANGE) [GH #216] #477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20310,6 +20310,59 @@ Generate code for the indicated range-based-for statement. | |
| gen_statement(statement->variant.range_based_for_loop.statement); | ||
| } /* gen_range_based_for_statement */ | ||
|
|
||
|
|
||
| static void gen_expansion_statement(a_statement_ptr statement) | ||
| /* | ||
| Generate code for the indicated expansion statement. | ||
| */ | ||
| { | ||
| an_expansion_stmt_info_ptr expn_info = expn_info_of(statement); | ||
|
|
||
| if (expn_info->expansion_scope != NULL) { | ||
| push_name_context(expn_info->expansion_scope); | ||
| } /* if */ | ||
| write_tok_str("template for ("); | ||
| if (expn_info->initialization != NULL) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| /* Generate the initialization statement. */ | ||
| gen_init_statement_or_statement( | ||
| get_for_init_statement(expn_info->initialization)); | ||
| } /* if */ | ||
| gen_variable_decl(/*is_condition=*/FALSE, /*is_iterator=*/TRUE, | ||
| /*for_init=*/FALSE, /*suppress_specifiers=*/FALSE, | ||
| (a_boolean *)NULL); | ||
| write_tok_str(" : "); | ||
| if (expn_info->initializer_is_list) { | ||
| /* Generate the initializer list. */ | ||
| write_tok_ch('{'); | ||
| for (an_expr_node_ptr expr = expn_info->initializer; | ||
| expr != NULL; | ||
| expr = expr->next) { | ||
| if (expr != expn_info->initializer) { | ||
| write_tok_str(", "); | ||
| } /* if */ | ||
| skip_embedded_declarations(); | ||
| gen_expr(expr, /*need_parens=*/expr_has_comma_operation(expr), | ||
| /*obj_expr_of_mfunc_operator=*/FALSE); | ||
|
Comment on lines
+20344
to
+20345
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Skip declarations embedded in initializer elements. An element such as
|
||
| } /* for */ | ||
| write_tok_ch('}'); | ||
| } else { | ||
| /* Generate the initializer expression. */ | ||
| check_assertion(expn_info->initializer != NULL); | ||
| gen_expression(expn_info->initializer); | ||
| } /* if */ | ||
| write_tok_str(") "); | ||
| /* The body is a template definition even outside an ordinary template; | ||
| generate it in prototype form. */ | ||
| Value_saver<a_boolean> prototype_context_saver( | ||
| &in_prototype_instantiation_context, TRUE); | ||
| if (expn_info->iterator_scope != NULL) { | ||
| push_name_context(expn_info->iterator_scope); | ||
| } /* if */ | ||
| gen_statement(statement->variant.expansion_statement.statement); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| if (expn_info->iterator_scope != NULL) pop_name_context(); | ||
| if (expn_info->expansion_scope != NULL) pop_name_context(); | ||
| } /* gen_expansion_statement */ | ||
|
|
||
| #if MICROSOFT_EXTENSIONS_ALLOWED | ||
|
|
||
| static void gen_for_each_statement(a_statement_ptr statement) | ||
|
|
@@ -22657,6 +22710,10 @@ one that yields the value) of a statement expression. | |
| /* range-based-for statement. */ | ||
| gen_range_based_for_statement(statement); | ||
| break; | ||
| case stmk_expansion_statement: | ||
| /* Expansion statement. */ | ||
| gen_expansion_statement(statement); | ||
| break; | ||
| #if MICROSOFT_EXTENSIONS_ALLOWED | ||
| case stmk_for_each: | ||
| /* "for each" statement. */ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.