aboutsummaryrefslogtreecommitdiff
path: root/gcc/btfout.cc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2024-04-11 09:46:00 +0200
committerJakub Jelinek <jakub@redhat.com>2024-04-11 09:46:00 +0200
commitcb46aca0a07355abf2f0b04f52087bca8f848524 (patch)
tree465ad99365c88bbfb429f0a4955fd7c8b7ee3792 /gcc/btfout.cc
parentf3fdcf4a37a7be07f2acbf5c8ed5e3399440a0ef (diff)
downloadgcc-cb46aca0a07355abf2f0b04f52087bca8f848524.zip
gcc-cb46aca0a07355abf2f0b04f52087bca8f848524.tar.gz
gcc-cb46aca0a07355abf2f0b04f52087bca8f848524.tar.bz2
c++: Fix ANNOTATE_EXPR instantiation [PR114409]
The following testcase ICEs starting with the r14-4229 PR111529 change which moved ANNOTATE_EXPR handling from tsubst_expr to tsubst_copy_and_build. ANNOTATE_EXPR is only allowed in the IL to wrap a loop condition, and the loop condition of while/for loops can be a COMPOUND_EXPR with DECL_EXPR in the first operand and the corresponding VAR_DECL in the second, as created by finish_cond else if (!empty_expr_stmt_p (cond)) expr = build2 (COMPOUND_EXPR, TREE_TYPE (expr), cond, expr); Since then Patrick reworked the instantiation, so that we have now tsubst_stmt and tsubst_expr and ANNOTATE_EXPR ended up in the latter, while only tsubst_stmt can handle DECL_EXPR. Now, the reason why the while/for loops with variable declaration in the condition works in templates without the pragmas (i.e. without ANNOTATE_EXPR) is that both the FOR_STMT and WHILE_STMT handling uses RECUR aka tsubst_stmt in handling of the *_COND operand: case FOR_STMT: stmt = begin_for_stmt (NULL_TREE, NULL_TREE); RECUR (FOR_INIT_STMT (t)); finish_init_stmt (stmt); tmp = RECUR (FOR_COND (t)); finish_for_cond (tmp, stmt, false, 0, false); and case WHILE_STMT: stmt = begin_while_stmt (); tmp = RECUR (WHILE_COND (t)); finish_while_stmt_cond (tmp, stmt, false, 0, false); Therefore, it will handle DECL_EXPR embedded in COMPOUND_EXPR of the {WHILE,FOR}_COND just fine. But if that COMPOUND_EXPR with DECL_EXPR is wrapped with one or more ANNOTATE_EXPRs, because ANNOTATE_EXPR is now done solely in tsubst_expr and uses RECUR there (i.e. tsubst_expr), it will ICE on DECL_EXPR in there. This could be fixed by keeping ANNOTATE_EXPR handling in tsubst_expr but using tsubst_stmt for the first operand, but this patch instead moves ANNOTATE_EXPR handling to tsubst_stmt (and uses tsubst_expr for the second/third operand). 2024-04-11 Jakub Jelinek <jakub@redhat.com> PR c++/114409 * pt.cc (tsubst_expr) <case ANNOTATE_EXPR>: Move to ... (tsubst_stmt) <case ANNOTATE_EXPR>: ... here. Use tsubst_expr instead of RECUR for the last 2 arguments. * g++.dg/ext/pr114409-2.C: New test.
Diffstat (limited to 'gcc/btfout.cc')
0 files changed, 0 insertions, 0 deletions