PR c++/60951
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 30 Apr 2014 14:23:11 +0000 (14:23 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 30 Apr 2014 14:23:11 +0000 (14:23 +0000)
* typeck2.c (massage_init_elt): Use maybe_constant_init.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@209933 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/typeck2.c
gcc/testsuite/g++.dg/cpp0x/constexpr-aggr1.C [new file with mode: 0644]

index c4be5bd..a387883 100644 (file)
@@ -1,3 +1,8 @@
+2014-04-30  Jason Merrill  <jason@redhat.com>
+
+       PR c++/60951
+       * typeck2.c (massage_init_elt): Use maybe_constant_init.
+
 2014-04-30  Marek Polacek  <polacek@redhat.com>
 
        * typeck.c (cp_build_binary_op): Call ubsan_instrument_division
index 5bbc2ef..044d971 100644 (file)
@@ -1138,7 +1138,7 @@ massage_init_elt (tree type, tree init, tsubst_flags_t complain)
   /* When we defer constant folding within a statement, we may want to
      defer this folding as well.  */
   tree t = fold_non_dependent_expr_sfinae (init, complain);
-  t = maybe_constant_value (t);
+  t = maybe_constant_init (t);
   if (TREE_CONSTANT (t))
     init = t;
   return init;
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-aggr1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-aggr1.C
new file mode 100644 (file)
index 0000000..7e4da11
--- /dev/null
@@ -0,0 +1,17 @@
+// PR c++/60951
+// { dg-do compile { target c++11 } }
+
+struct Foo {
+  constexpr Foo(int x = 0) : memb(x) {}
+  int memb;
+};
+
+struct FooContainer {
+  Foo foo[2];
+};
+
+void fubar() {
+  int nonConst = 0;
+  FooContainer fooContainer;
+  fooContainer = { { 0, nonConst } };
+}