From: Jason Merrill Date: Tue, 25 Mar 2014 18:00:30 +0000 (-0400) Subject: re PR c++/60628 ([c++11] ICE initializing array of auto) X-Git-Tag: releases/gcc-4.9.0~311 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=45156f1474c97ecc7147951b36714fe4655676af;p=thirdparty%2Fgcc.git 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: r208816 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a5a369564de1..47c989098ca4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2014-03-25 Jason Merrill + + PR c++/60628 + * decl.c (create_array_type_for_decl): Complain about array of auto. + 2014-03-25 Jakub Jelinek PR c++/60331 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index c912ffcb5062..f3a081b8a8f5 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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 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" } +}