From 5a5a6ef37cf2d1714e4e1902c79f1d93f1870974 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 13 May 2014 12:05:07 -0400 Subject: [PATCH] re PR c++/60628 ([c++11] ICE initializing array of auto) PR c++/60628 * decl.c (create_array_type_for_decl): Complain about array of auto. From-SVN: r210382 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/decl.c | 8 ++++++++ gcc/testsuite/g++.dg/cpp0x/auto42.C | 9 +++++++++ 3 files changed, 20 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/auto42.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d1b4ed1b765e..13989d0b1d47 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2014-05-13 Jason Merrill + 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. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 9b2afdc3cebd..6faf3fd7f6ee 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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 index 000000000000..fea4c28d84d9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto42.C @@ -0,0 +1,9 @@ +// PR c++/60628 +// { dg-do compile { target c++11 } } + +#include + +void foo(int i) +{ + auto x[1] = { 0 }; // { dg-error "array of .auto" } +} -- 2.47.2