On Thu, Jan 19, 2017 at 9:43 AM, Jason Merrill <ja...@redhat.com> wrote:
> Jakub pointed out that parenthesized decomposition of an array wasn't
> properly using direct-initialization.  Rather than pass the flags down
> into build_vec_init at this point in GCC 7 development, let's turn the
> initializer into something that build_vec_init recognizes as
> direct-initialization.

And another issue from Jakub's email.
commit 6f412aaccd57bcc7c9226516b008b088df2f86c6
Author: Jason Merrill <ja...@redhat.com>
Date:   Thu Jan 19 10:38:10 2017 -0500

            Array decomposition fix.
    
            * decl.c (check_initializer): Always use build_aggr_init for array
            decomposition.

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 75baf94..792ebcc 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -6299,14 +6299,14 @@ check_initializer (tree decl, tree init, int flags, 
vec<tree, va_gc> **cleanups)
       if (type == error_mark_node)
        return NULL_TREE;
 
-      if ((type_build_ctor_call (type) || CLASS_TYPE_P (type)
-          || (DECL_DECOMPOSITION_P (decl) && TREE_CODE (type) == ARRAY_TYPE))
-         && !(flags & LOOKUP_ALREADY_DIGESTED)
-         && !(init && BRACE_ENCLOSED_INITIALIZER_P (init)
-              && CP_AGGREGATE_TYPE_P (type)
-              && (CLASS_TYPE_P (type)
-                  || !TYPE_NEEDS_CONSTRUCTING (type)
-                  || type_has_extended_temps (type))))
+      if (((type_build_ctor_call (type) || CLASS_TYPE_P (type))
+          && !(flags & LOOKUP_ALREADY_DIGESTED)
+          && !(init && BRACE_ENCLOSED_INITIALIZER_P (init)
+               && CP_AGGREGATE_TYPE_P (type)
+               && (CLASS_TYPE_P (type)
+                   || !TYPE_NEEDS_CONSTRUCTING (type)
+                   || type_has_extended_temps (type))))
+         || (DECL_DECOMPOSITION_P (decl) && TREE_CODE (type) == ARRAY_TYPE))
        {
          init_code = build_aggr_init_full_exprs (decl, init, flags);
 
diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp21.C 
b/gcc/testsuite/g++.dg/cpp1z/decomp21.C
new file mode 100644
index 0000000..d046ed5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/decomp21.C
@@ -0,0 +1,16 @@
+// { dg-options -std=c++1z }
+
+int a[3];
+struct S { int b, c, d; } s;
+void
+foo ()
+{
+  auto [ b, c, d ] = a;
+  auto [ e, f, g ] = s;
+  auto [ h, i, j ] { s };
+  auto [ k, l, m ] { s, };
+  auto [ n, o, p ] { a };
+  auto [ q, r, t ] ( s );
+  auto [ u, v, w ] ( s, );      // { dg-error "expected primary-expression 
before '.' token" }
+  auto [ x, y, z ] ( a );       // { dg-error "expression list treated as 
compound expression in initializer" "" { target *-*-* } .-1 }
+}

Reply via email to