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 fc0771a..859085b 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 78ebbde..b021ff6 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 95d558f..c11b5c8 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." }