From 27a98312c54b6c00a4e7deb1bf663547cd4f2dcc Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Mon, 13 Aug 2018 15:36:30 +0000 Subject: [PATCH] re PR c++/86915 (Segmentation fault for an array of auto in template parameter) 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 | 5 +++++ gcc/cp/decl.c | 5 ++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/diagnostic/auto1.C | 4 ++++ 4 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/diagnostic/auto1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index fc0771aa7f2..859085be4ca 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2018-08-13 Marek Polacek + + PR c++/86915 + * decl.c (create_array_type_for_decl): Handle null name. + 2018-08-10 Jason Merrill PR c++/86728 - C variadic generic lambda. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 78ebbde61a3..b021ff6f37c 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 95d558f2522..c11b5c89af1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-08-13 Marek Polacek + + PR c++/86915 + * g++.dg/diagnostic/auto1.C: New test. + 2018-08-12 Paul Thomas 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 index 00000000000..ee2eefd59aa --- /dev/null +++ b/gcc/testsuite/g++.dg/diagnostic/auto1.C @@ -0,0 +1,4 @@ +// PR c++/86915 +// { dg-do compile { target c++17 } } + +template struct S; // { dg-error "creating array of .auto." } -- 2.30.2