1) We want to skip anonymous structs when pushing member cleanups, too.
2) We shouldn't create a static variable for a compound literal in e.g.
sizeof.
I don't think either of these will actually affect compiler output,
they're just cleanups I noticed while working on other things.
Tested x86_64-pc-linux-gnu, applying to trunk.
commit beac93e0a45d47f6a896d9f3f27eed224ad51ee9
Author: Jason Merrill <ja...@redhat.com>
Date: Tue Oct 22 16:32:07 2013 -0400
* init.c (push_base_cleanups): Check ANON_AGGR_TYPE_P.
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 78ea986..82b3cae 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -4130,7 +4130,7 @@ push_base_cleanups (void)
|| TREE_CODE (member) != FIELD_DECL
|| DECL_ARTIFICIAL (member))
continue;
- if (ANON_UNION_TYPE_P (this_type))
+ if (ANON_AGGR_TYPE_P (this_type))
continue;
if (type_build_dtor_call (this_type))
{
commit d643f3c28260e0295e6ac3dd0b4d80e26b00ea3f
Author: Jason Merrill <ja...@redhat.com>
Date: Tue Oct 22 16:33:38 2013 -0400
* semantics.c (finish_compound_literal): Don't create a static variable
inside cp_unevaluated_operand.
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 052746c..a54123e 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -2501,6 +2501,7 @@ finish_compound_literal (tree type, tree compound_literal,
if ((!at_function_scope_p () || CP_TYPE_CONST_P (type))
&& TREE_CODE (type) == ARRAY_TYPE
&& !TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type)
+ && !cp_unevaluated_operand
&& initializer_constant_valid_p (compound_literal, type))
{
tree decl = create_temporary_var (type);