aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2011-05-25 22:22:54 -0400
committerJason Merrill <jason@gcc.gnu.org>2011-05-25 22:22:54 -0400
commit5df0c0c767de7cc44474504d0de8e15ac96c97b9 (patch)
tree05999189321f92014015a2a38f0889e6d71355d6 /gcc
parenteda19906998dbfcc1444296fa6a288456339cd17 (diff)
downloadgcc-5df0c0c767de7cc44474504d0de8e15ac96c97b9.zip
gcc-5df0c0c767de7cc44474504d0de8e15ac96c97b9.tar.gz
gcc-5df0c0c767de7cc44474504d0de8e15ac96c97b9.tar.bz2
re PR c++/48599 ([C++0x] no diagnostic for invalid use of auto with array declarator)
PR c++/48599 * decl.c (create_array_type_for_decl): Complain about array of auto. From-SVN: r174257
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog3
-rw-r--r--gcc/cp/decl.c6
-rw-r--r--gcc/testsuite/ChangeLog2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/auto24.C5
4 files changed, 16 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 06d5159..dad97ad 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,8 @@
2011-05-25 Jason Merrill <jason@redhat.com>
+ PR c++/48599
+ * decl.c (create_array_type_for_decl): Complain about array of auto.
+
PR c++/44944
PR c++/49156
* error.c (dump_template_bindings): Set processing_template_decl
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/ChangeLog b/gcc/testsuite/ChangeLog
index 07f4845..bcef9a9 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,7 @@
2011-05-25 Jason Merrill <jason@redhat.com>
+ * g++.dg/cpp0x/auto24.C: New.
+
* g++.dg/cpp0x/error4.C: New.
* g++.dg/cpp0x/rv-restrict.C: New.
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" }