re PR c++/60417 ([DR 1518] Bogus error on C++03 aggregate initialization)
authorJason Merrill <jason@redhat.com>
Thu, 7 Aug 2014 01:44:11 +0000 (21:44 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 7 Aug 2014 01:44:11 +0000 (21:44 -0400)
PR c++/60417
* init.c (build_vec_init): Reorganize earlier change a bit.

From-SVN: r213689

gcc/cp/ChangeLog
gcc/cp/init.c

index 9ffd7468563843a997f7ce73b4f086a201ef2b30..a373ccfe95c7558a8cbc2f7fb36a37183796e2c6 100644 (file)
@@ -1,5 +1,8 @@
 2014-08-06  Jason Merrill  <jason@redhat.com>
 
+       PR c++/60417
+       * init.c (build_vec_init): Reorganize earlier change a bit.
+
        PR c++/61994
        * init.c (build_vec_init): Leave atype an ARRAY_TYPE
        if we're just returning an INIT_EXPR.
index 17e6c4becb56a76e47df1e878fdfcaf55ba4c2e7..777e0a984e486b9896d7e6668920e2c0399237a3 100644 (file)
@@ -3685,26 +3685,6 @@ build_vec_init (tree base, tree maxindex, tree init,
        }
     }
 
-  /* If the initializer is {}, then all elements are initialized from T{}.
-     But for non-classes, that's the same as value-initialization.  */
-  if (empty_list)
-    {
-      if (cxx_dialect >= cxx11 && AGGREGATE_TYPE_P (type))
-       {
-         if (BRACE_ENCLOSED_INITIALIZER_P (init)
-             && CONSTRUCTOR_NELTS (init) == 0)
-           /* Reuse it.  */;
-         else
-           init = build_constructor (init_list_type_node, NULL);
-         CONSTRUCTOR_IS_DIRECT_INIT (init) = true;
-       }
-      else
-       {
-         init = NULL_TREE;
-         explicit_value_init_p = true;
-       }
-    }
-
   /* Now, default-initialize any remaining elements.  We don't need to
      do that if a) the type does not need constructing, or b) we've
      already initialized all the elements.
@@ -3736,6 +3716,26 @@ build_vec_init (tree base, tree maxindex, tree init,
 
       to = build1 (INDIRECT_REF, type, base);
 
+      /* If the initializer is {}, then all elements are initialized from T{}.
+        But for non-classes, that's the same as value-initialization.  */
+      if (empty_list)
+       {
+         if (cxx_dialect >= cxx11 && AGGREGATE_TYPE_P (type))
+           {
+             if (BRACE_ENCLOSED_INITIALIZER_P (init)
+                 && CONSTRUCTOR_NELTS (init) == 0)
+               /* Reuse it.  */;
+             else
+               init = build_constructor (init_list_type_node, NULL);
+             CONSTRUCTOR_IS_DIRECT_INIT (init) = true;
+           }
+         else
+           {
+             init = NULL_TREE;
+             explicit_value_init_p = true;
+           }
+       }
+
       if (from_array)
        {
          tree from;