re PR c++/86915 (Segmentation fault for an array of auto in template parameter)
authorMarek Polacek <polacek@redhat.com>
Mon, 13 Aug 2018 15:36:30 +0000 (15:36 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Mon, 13 Aug 2018 15:36:30 +0000 (15:36 +0000)
PR c++/86915
* decl.c (create_array_type_for_decl): Handle null name.

* g++.dg/diagnostic/auto1.C: New test.

From-SVN: r263507

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

index fc0771aa7f2d3a81559b5eccccd14f7a0dc840d7..859085be4cad94fc32954ff7ed2dff8dfbf70378 100644 (file)
@@ -1,3 +1,8 @@
+2018-08-13  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/86915
+       * decl.c (create_array_type_for_decl): Handle null name.
+
 2018-08-10  Jason Merrill  <jason@redhat.com>
 
        PR c++/86728 - C variadic generic lambda.
index 78ebbde61a33ac2a71bc246cd5e48cf4ae75de87..b021ff6f37c5f470d690abf8fb91618a3c578d21 100644 (file)
@@ -9838,7 +9838,10 @@ create_array_type_for_decl (tree name, tree type, tree size)
      type-specifier, the program is ill-formed.  */
   if (type_uses_auto (type))
     {
-      error ("%qD declared as array of %qT", name, type);
+      if (name)
+   error ("%qD declared as array of %qT", name, type);
+      else
+   error ("creating array of %qT", type);
       return error_mark_node;
     }
 
index 95d558f2522043e0c6fefabe124826480ff5fd9e..c11b5c89af11fb7454453ac8a5aef60afcf6b134 100644 (file)
@@ -1,3 +1,8 @@
+2018-08-13  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/86915
+       * g++.dg/diagnostic/auto1.C: New test.
+
 2018-08-12  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/66679
diff --git a/gcc/testsuite/g++.dg/diagnostic/auto1.C b/gcc/testsuite/g++.dg/diagnostic/auto1.C
new file mode 100644 (file)
index 0000000..ee2eefd
--- /dev/null
@@ -0,0 +1,4 @@
+// PR c++/86915
+// { dg-do compile { target c++17 } }
+
+template<auto [1]> struct S; // { dg-error "creating array of .auto." }