public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ PATCH for c++/48599 (prohibit array of auto)
@ 2011-05-26  4:43 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2011-05-26  4:43 UTC (permalink / raw)
  To: gcc-patches List

[-- Attachment #1: Type: text/plain, Size: 150 bytes --]

I argued against this restriction when it was introduced, but we should 
enforce it in pedantic mode.

Tested x86_64-pc-linux-gnu, applying to trunk.

[-- Attachment #2: 48599.patch --]
[-- Type: text/x-patch, Size: 1247 bytes --]

commit 9474a87e99bfacf0b8dfc9dc4c1218d39666a850
Author: Jason Merrill <jason@redhat.com>
Date:   Wed May 25 16:53:25 2011 -0400

    	PR c++/48599
    	* 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 d53fa26..58cab51 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -7974,6 +7974,12 @@ create_array_type_for_decl (tree name, tree type, tree size)
   if (type == error_mark_node || size == error_mark_node)
     return error_mark_node;
 
+  /* 8.3.4/1: If the type of the identifier of D contains the auto
+     type-specifier, the program is ill-formed.  */
+  if (pedantic && type_uses_auto (type))
+    pedwarn (input_location, OPT_pedantic,
+	     "declaration of %qD as array of %<auto%>", name);
+
   /* If there are some types which cannot be array elements,
      issue an error-message and return.  */
   switch (TREE_CODE (type))
diff --git a/gcc/testsuite/g++.dg/cpp0x/auto24.C b/gcc/testsuite/g++.dg/cpp0x/auto24.C
new file mode 100644
index 0000000..b024ad5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/auto24.C
@@ -0,0 +1,5 @@
+// PR c++/48599
+// { dg-options "-std=c++0x -pedantic-errors" }
+
+int v[1];
+auto (*p)[1] = &v;		// { dg-error "array of .auto" }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-05-26  0:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-26  4:43 C++ PATCH for c++/48599 (prohibit array of auto) Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).