re PR c++/36943 ([c++0x] Use of nested C++0x initializer list for non-aggregate rejected)
authorJason Merrill <jason@redhat.com>
Tue, 29 Jul 2008 00:06:08 +0000 (20:06 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 29 Jul 2008 00:06:08 +0000 (20:06 -0400)
        PR c++/36943
        * decl.c (reshape_init_r): Allow C++0x initializer lists.

From-SVN: r138221

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/g++.dg/cpp0x/initlist1.C

index ad2964cf4035dda21383ba4a113fde1123026036..bbb23ee197659ea3cc56b1d15410314b5199fa44 100644 (file)
@@ -1,3 +1,8 @@
+2008-07-27  Jason Merrill  <jason@redhat.com>
+
+       PR c++/36943
+       * decl.c (reshape_init_r): Allow C++0x initializer lists.
+
 2008-07-28  Richard Guenther  <rguenther@suse.de>
 
        Merge from gimple-tuples-branch.
index 630faacb354e2bbf4c0bb44e40dde7afb3eb066d..2d9ccba3a5cf8b3afc28f27139187da06e666e87 100644 (file)
@@ -4786,15 +4786,20 @@ reshape_init_r (tree type, reshape_iter *d, bool first_initializer_p)
   if (!CP_AGGREGATE_TYPE_P (type))
     {
       /* It is invalid to initialize a non-aggregate type with a
-        brace-enclosed initializer.
+        brace-enclosed initializer before C++0x.
         We need to check for BRACE_ENCLOSED_INITIALIZER_P here because
         of g++.old-deja/g++.mike/p7626.C: a pointer-to-member constant is
         a CONSTRUCTOR (with a record type).  */
       if (TREE_CODE (init) == CONSTRUCTOR
          && BRACE_ENCLOSED_INITIALIZER_P (init))  /* p7626.C */
        {
-         error ("braces around scalar initializer for type %qT", type);
-         init = error_mark_node;
+         if (SCALAR_TYPE_P (type))
+           {
+             error ("braces around scalar initializer for type %qT", type);
+             init = error_mark_node;
+           }
+         else
+           maybe_warn_cpp0x ("extended initializer lists");
        }
 
       d->cur++;
index b7583da782977410fd35839f4caa843246240aa8..ff45f7176f611b900433a66527314206eed55bda 100644 (file)
@@ -56,6 +56,9 @@ void i(initializer_list<int> l)
   if (p != l.end()) abort();
 }
 
+struct U { U(int, int) {} };
+U ua[] = { { 3, 2 } };
+
 int main()
 {
   g({1,2,3});