]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/69658 (Bogus "C99 designator outside aggregate initializer" error)
authorJakub Jelinek <jakub@redhat.com>
Mon, 15 Feb 2016 22:05:12 +0000 (23:05 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 15 Feb 2016 22:05:12 +0000 (23:05 +0100)
PR c++/69658
* init.c (expand_default_init): Only call reshape_init
in the direct-initialization from an initializer list case.

* g++.dg/init/pr69658.C: New test.

From-SVN: r233435

gcc/cp/ChangeLog
gcc/cp/init.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/init/pr69658.C [new file with mode: 0644]

index 04d55bc60b919d8bbc7a23c820e3f6a364e29419..51c99e1759889624895e1d29eb5ec90ead8a0413 100644 (file)
@@ -1,3 +1,9 @@
+2016-02-15  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/69658
+       * init.c (expand_default_init): Only call reshape_init
+       in the direct-initialization from an initializer list case.
+
 2016-02-15  Jason Merrill  <jason@redhat.com>
 
        PR c++/69753
index f6ceb7f431fcc08bdab1a5c949f49973f56df679..9f9c7292d2d470aa19d23782044b2ccee20766ca 100644 (file)
@@ -1636,16 +1636,17 @@ expand_default_init (tree binfo, tree true_exp, tree exp, tree init, int flags,
       gcc_checking_assert ((flags & LOOKUP_ONLYCONVERTING) == 0
                           && TREE_CHAIN (init) == NULL_TREE);
       init = TREE_VALUE (init);
+      /* Only call reshape_init if it has not been called earlier
+        by the callers.  */
+      if (BRACE_ENCLOSED_INITIALIZER_P (init) && CP_AGGREGATE_TYPE_P (type))
+       init = reshape_init (type, init, complain);
     }
 
   if (init && BRACE_ENCLOSED_INITIALIZER_P (init)
       && CP_AGGREGATE_TYPE_P (type))
     /* A brace-enclosed initializer for an aggregate.  In C++0x this can
        happen for direct-initialization, too.  */
-    {
-      init = reshape_init (type, init, complain);
-      init = digest_init (type, init, complain);
-    }
+    init = digest_init (type, init, complain);
 
   /* A CONSTRUCTOR of the target's type is a previously digested
      initializer, whether that happened just above or in
index 21b11e9178e5522084e77f085343ebb79a57d9d7..8987be19d3e9314f8d7020939ef6e395685ef924 100644 (file)
@@ -1,5 +1,8 @@
 2016-02-15  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/69658
+       * g++.dg/init/pr69658.C: New test.
+
        PR c++/69797
        * c-c++-common/pr69797.c: New test.
 
diff --git a/gcc/testsuite/g++.dg/init/pr69658.C b/gcc/testsuite/g++.dg/init/pr69658.C
new file mode 100644 (file)
index 0000000..976f79d
--- /dev/null
@@ -0,0 +1,6 @@
+// PR c++/69658
+// { dg-do compile }
+
+struct S { S (int); };
+struct T { char n[6]; S s; };
+T t[1] = { { "foo", 1 } };     // { dg-bogus "C99 designator" }