Thread View: gmane.comp.gcc.patches
1 messages
1 total messages
Started by Jason Merrill
Tue, 25 Mar 2014 13:43
C++ PATCH for c++/60628 (auto array)
Author: Jason Merrill
Date: Tue, 25 Mar 2014 13:43
Date: Tue, 25 Mar 2014 13:43
60 lines
1896 bytes
1896 bytes
This is a multi-part message in MIME format. --------------000707080306020502020507 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit We got confused tsubsting the VLA type because tsubst doesn't expect to see a SAVE_EXPR. Simple to fix by enforcing the rule against auto arrays. Tested x86_64-pc-linux-gnu, applying to trunk. --------------000707080306020502020507 Content-Type: text/x-patch; name="60628.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="60628.patch" commit f2fbd4a8a0152e2d9d6c0b9d6ccfb1639183ed0c Author: Jason Merrill <jason@redhat.com> Date: Mon Mar 24 14:58:58 2014 -0400 PR c++/60628 * decl.c (create_array_type_for_decl): Complain about array of auto. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index c912ffc..f3a081b 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 0000000..fea4c28 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto42.C @@ -0,0 +1,9 @@ +// PR c++/60628 +// { dg-do compile { target c++11 } } + +#include <initializer_list> + +void foo(int i) +{ + auto x[1] = { 0 }; // { dg-error "array of .auto" } +} --------------000707080306020502020507--
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads