aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2020-11-24 18:21:38 -0500
committerJason Merrill <jason@redhat.com>2020-12-02 16:14:21 -0500
commitd9288bd28e24c755a7216311ee5247e7c88270a6 (patch)
tree568fbad2383c1885b79d96e21ac24ca3d36c4968 /gcc
parent07589ca2b2c84ec9609861ff5d119ed7413fd9c5 (diff)
downloadgcc-d9288bd28e24c755a7216311ee5247e7c88270a6.zip
gcc-d9288bd28e24c755a7216311ee5247e7c88270a6.tar.gz
gcc-d9288bd28e24c755a7216311ee5247e7c88270a6.tar.bz2
c++: Improve init handling
While looking at another issue I noticed that in a template we were failing to find the INIT_EXPR we were looking for, and so ended up doing redundant processing. No testcase, as the redundant processing ended up getting the right result. gcc/cp/ChangeLog: * decl.c (check_initializer): Also look through STMT_EXPR and BIND_EXPR.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/decl.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index df76155..1e2bae4 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -6892,9 +6892,17 @@ check_initializer (tree decl, tree init, int flags, vec<tree, va_gc> **cleanups)
have returned an INIT_EXPR rather than a CALL_EXPR. In that
case, pull the initializer back out and pass it down into
store_init_value. */
- while (TREE_CODE (init_code) == EXPR_STMT
- || TREE_CODE (init_code) == CONVERT_EXPR)
- init_code = TREE_OPERAND (init_code, 0);
+ while (true)
+ {
+ if (TREE_CODE (init_code) == EXPR_STMT
+ || TREE_CODE (init_code) == STMT_EXPR
+ || TREE_CODE (init_code) == CONVERT_EXPR)
+ init_code = TREE_OPERAND (init_code, 0);
+ else if (TREE_CODE (init_code) == BIND_EXPR)
+ init_code = BIND_EXPR_BODY (init_code);
+ else
+ break;
+ }
if (TREE_CODE (init_code) == INIT_EXPR)
{
/* In C++20, the call to build_aggr_init could have created