]> 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, 25 Mar 2014 18:00:30 +0000 (14:00 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 25 Mar 2014 18:00:30 +0000 (14:00 -0400)
PR c++/60628
* decl.c (create_array_type_for_decl): Complain about array of auto.

From-SVN: r208816

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

index a5a369564de15b24771c404b227c876a764f9934..47c989098ca4d375cf54f0bb92f2685da8b67d79 100644 (file)
@@ -1,3 +1,8 @@
+2014-03-25  Jason Merrill  <jason@redhat.com>
+
+       PR c++/60628
+       * decl.c (create_array_type_for_decl): Complain about array of auto.
+
 2014-03-25  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/60331
index c912ffcb50622ce524fd6ffa08ea827d7542c62b..f3a081b8a8f50f241265ab144b3b520fdd91c8e9 100644 (file)
@@ -8534,6 +8534,14 @@ create_array_type_for_decl (tree name, tree type, tree size)
       && (flag_iso || warn_vla > 0))
     pedwarn (input_location, OPT_Wvla, "array of array of runtime bound");
 
+  /* 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" }
+}