The gimplifier was getting confused because we didn't set
TREE_SIDE_EFFECTS on the CONSTRUCTOR.
Tested x86_64-pc-linux-gnu, applying to trunk.
commit 00cbdd8b8a83dd7b8e386fc713bb2b1dab173d81
Author: Jason Merrill <ja...@redhat.com>
Date: Tue Apr 1 14:06:46 2014 -0400
PR c++/60713
* typeck2.c (PICFLAG_SIDE_EFFECTS): New.
(picflag_from_initializer): Return it.
(process_init_constructor): Handle it.
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index bd21ad8..68e518a 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -1103,6 +1103,7 @@ digest_init_flags (tree type, tree init, int flags)
#define PICFLAG_ERRONEOUS 1
#define PICFLAG_NOT_ALL_CONSTANT 2
#define PICFLAG_NOT_ALL_SIMPLE 4
+#define PICFLAG_SIDE_EFFECTS 8
/* Given an initializer INIT, return the flag (PICFLAG_*) which better
describe it. */
@@ -1113,7 +1114,12 @@ picflag_from_initializer (tree init)
if (init == error_mark_node)
return PICFLAG_ERRONEOUS;
else if (!TREE_CONSTANT (init))
- return PICFLAG_NOT_ALL_CONSTANT;
+ {
+ if (TREE_SIDE_EFFECTS (init))
+ return PICFLAG_SIDE_EFFECTS;
+ else
+ return PICFLAG_NOT_ALL_CONSTANT;
+ }
else if (!initializer_constant_valid_p (init, TREE_TYPE (init)))
return PICFLAG_NOT_ALL_SIMPLE;
return 0;
@@ -1493,7 +1499,12 @@ process_init_constructor (tree type, tree init, tsubst_flags_t complain)
TREE_TYPE (init) = type;
if (TREE_CODE (type) == ARRAY_TYPE && TYPE_DOMAIN (type) == NULL_TREE)
cp_complete_array_type (&TREE_TYPE (init), init, /*do_default=*/0);
- if (flags & PICFLAG_NOT_ALL_CONSTANT)
+ if (flags & PICFLAG_SIDE_EFFECTS)
+ {
+ TREE_CONSTANT (init) = false;
+ TREE_SIDE_EFFECTS (init) = true;
+ }
+ else if (flags & PICFLAG_NOT_ALL_CONSTANT)
/* Make sure TREE_CONSTANT isn't set from build_constructor. */
TREE_CONSTANT (init) = false;
else
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist81.C b/gcc/testsuite/g++.dg/cpp0x/initlist81.C
new file mode 100644
index 0000000..5978c63
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist81.C
@@ -0,0 +1,25 @@
+// PR c++/60713
+// { dg-options "-O" }
+// { dg-do compile { target c++11 } }
+
+template < class x0, class x1, class x2, class x3, class x4 >
+int *x5 (x0 *, x2 (x1::*)(x3, x4));
+
+class x6
+{
+ void x7 ();
+ struct x8
+ {
+ int *x9;
+ };
+ void x10 (x8);
+ void x11 (int *, int *);
+};
+
+void
+x6::x7 ()
+{
+ x10 ({
+ x5 (this, &x6::x11)
+ });
+}