aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/semantics.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2021-04-15 17:04:24 -0400
committerJason Merrill <jason@redhat.com>2021-04-29 14:33:39 -0400
commit3f0de4dd51fd9a1e9628411b4fd728f5841256fe (patch)
treeaf3e957d72b4b8b8005c81047b611418db51cc84 /gcc/cp/semantics.c
parentefeca0ac4155b76ce713155f190422aac20537c5 (diff)
downloadgcc-3f0de4dd51fd9a1e9628411b4fd728f5841256fe.zip
gcc-3f0de4dd51fd9a1e9628411b4fd728f5841256fe.tar.gz
gcc-3f0de4dd51fd9a1e9628411b4fd728f5841256fe.tar.bz2
c++: unset COMPOUND_LITERAL_P [PR100079]
Once a CONSTRUCTOR has been digested and used as an initializer, it no longer represents a compound literal by itself, so we can clear the flag, letting us use it consistently to distinguish between digested and undigested initializer-lists. gcc/cp/ChangeLog: * cp-tree.h: Clarify comments. * pt.c (get_template_parm_object): Add assert. * semantics.c (finish_compound_literal): Clear TREE_HAS_CONSTRUCTOR. * tree.c (zero_init_expr_p): Check TREE_HAS_CONSTRUCTOR. * typeck2.c (store_init_value): Likewise.
Diffstat (limited to 'gcc/cp/semantics.c')
-rw-r--r--gcc/cp/semantics.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 3a6468f..319a3a8 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -3177,9 +3177,13 @@ finish_compound_literal (tree type, tree compound_literal,
}
/* Represent other compound literals with TARGET_EXPR so we produce
- an lvalue, but can elide copies. */
+ a prvalue, and can elide copies. */
if (!VECTOR_TYPE_P (type))
- compound_literal = get_target_expr_sfinae (compound_literal, complain);
+ {
+ /* The CONSTRUCTOR is now an initializer, not a compound literal. */
+ TREE_HAS_CONSTRUCTOR (compound_literal) = false;
+ compound_literal = get_target_expr_sfinae (compound_literal, complain);
+ }
return compound_literal;
}