Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/Changes
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,30 @@ behavior standard-mandated. It is now the default behavior, except in
Microsoft mode with microsoft_version < 1951.


Version 7.1

10/1/26 [GH #195]
C++-generating back end: dependent multi-dimensional subscripts

In cases in which template definitions are generated from the prototype
instantiation IL, when a dependent multi-dimensional subscript operation
appears in a template definition, the C++-generating back end previously
emitted only the first subscript. This is now fixed. For example, with
--c++23:

template<typename T> auto f(const T &t) {
return t[1, 2]; // Previously generated as "t[1]"
}


10/1/26 [GH #191]
C++-generating back end: inaccessible or out-of-scope template arguments

In certain complex cases, the C++-generating back end could put out a
template argument that uses an inaccessible or out-of-scope name, making
the generated code uncompilable. This is now fixed.


Version 7.0, September 28, 2026

9/15/26 [EDGcpfe/28958]
Expand Down
24 changes: 17 additions & 7 deletions src/cp_gen_be.c
Original file line number Diff line number Diff line change
Expand Up @@ -15255,16 +15255,26 @@ it is a tpck_unknown_function constant and to NULL otherwise.
} /* is_dot_static_operation */


static void gen_array_subscript(an_expr_node_ptr expr)
static void gen_array_subscript_list(an_expr_node_ptr expr)
/*
Render the given expression surrounded by brackets.
Put out the given expression list surrounded by square brackets.
*/
{
a_boolean first = TRUE;

write_tok_ch('[');
gen_expr(expr, /*need_parens=*/expr_has_comma_operation(expr),
/*obj_expr_of_mfunc_operator=*/FALSE);
while (expr != NULL) {
if (first) {
first = FALSE;
} else {
write_tok_str(", ");
} /* if */
gen_expr(expr, /*need_parens=*/expr_has_comma_operation(expr),
/*obj_expr_of_mfunc_operator=*/FALSE);
expr = expr->next;
} /* if */
write_tok_ch(']');
} /* gen_array_subscript */
} /* gen_array_subscript_list */


static void gen_va_arg(an_expr_node_ptr expr)
Expand Down Expand Up @@ -17852,7 +17862,7 @@ handled through recursion.
break;
case eok_subscript:
gen_member_selector_for_builtin_offsetof(arg1);
gen_array_subscript(arg2);
gen_array_subscript_list(arg2);
break;
case eok_cast:
case eok_base_class_cast:
Expand Down Expand Up @@ -19245,7 +19255,7 @@ gen_expr that might end up generating this expr as a temporary.
parens_may_be_needed(generated_precedence[eok_subscript],
operand_1),
/*obj_expr_of_mfunc_operator=*/FALSE);
gen_array_subscript(operand_2);
gen_array_subscript_list(operand_2);
goto done_with_operation;
case eok_cli_subscript:
gen_expr_with_parens(operand_1);
Expand Down
1 change: 1 addition & 0 deletions tests/tests/regressions/.gh-195.rto/default.1.1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cpfe -DTEST_NUMBER=1 --c++23 Test_name.c
9 changes: 9 additions & 0 deletions tests/tests/regressions/gh-195.sft.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//options_all:--c++23
//type:cp
template<typename T> auto f(const T &t) {
return t[1, 2]; // Previously generated as "t[1]"
}
struct S {
int operator[](int, int) const;
} s;
int i = f(s);
Loading