]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/60628 ([c++11] ICE initializing array of auto)
authorJason Merrill <jason@redhat.com>
Tue, 13 May 2014 16:05:07 +0000 (12:05 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 13 May 2014 16:05:07 +0000 (12:05 -0400)
PR c++/60628
* decl.c (create_array_type_for_decl): Complain about array of auto.

From-SVN: r210382

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/g++.dg/cpp0x/auto42.C [new file with mode: 0644]

index d1b4ed1b765e23a8f4f56ec70b64998a1c5f291a..13989d0b1d4781743fc94e6b44cc2e3e720d0921 100644 (file)
@@ -1,5 +1,8 @@
 2014-05-13  Jason Merrill  <jason@redhat.com>
 
+       PR c++/60628
+       * decl.c (create_array_type_for_decl): Complain about array of auto.
+
        PR c++/60367
        * call.c (convert_default_arg): Remove special handling for
        CONSTRUCTOR.
index 9b2afdc3cebde582f5b624e8bd70d2d67a94afbb..6faf3fd7f6eeb8b35bbb2a388a2b5ffc075f6e1e 100644 (file)
@@ -8475,6 +8475,14 @@ create_array_type_for_decl (tree name, tree type, tree size)
       return error_mark_node;
     }
 
+  /* 8.3.4p1: ...if the type of the identifier of D contains the auto
+     type-specifier, the program is ill-formed.  */
+  if (type_uses_auto (type))
+    {
+      error ("%qD declared as array of %qT", name, type);
+      return error_mark_node;
+    }
+
   /* Figure out the index type for the array.  */
   if (size)
     itype = compute_array_index_type (name, size, tf_warning_or_error);
diff --git a/gcc/testsuite/g++.dg/cpp0x/auto42.C b/gcc/testsuite/g++.dg/cpp0x/auto42.C
new file mode 100644 (file)
index 0000000..fea4c28
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/60628
+// { dg-do compile { target c++11 } }
+
+#include <initializer_list>
+
+void foo(int i)
+{
+  auto x[1] = { 0 };           // { dg-error "array of .auto" }
+}