aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/decl.c
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@redhat.com>2011-12-15 15:40:25 +0000
committerDodji Seketeli <dodji@gcc.gnu.org>2011-12-15 16:40:25 +0100
commitf03e689a9db25772c9650630bff7333bbf01c43d (patch)
tree166d4f3125440f265c7cae9244db82bc83609cbe /gcc/cp/decl.c
parent90376fadb87083f9990804ce6b6588004241be77 (diff)
downloadgcc-f03e689a9db25772c9650630bff7333bbf01c43d.zip
gcc-f03e689a9db25772c9650630bff7333bbf01c43d.tar.gz
gcc-f03e689a9db25772c9650630bff7333bbf01c43d.tar.bz2
PR c++/51473 - ICE with invalid auto
gcc/cp/ PR c++/51473 * decl.c (check_tag_decl): Error out on auto specifier with no declarator. gcc/testsuite/ PR c++/51473 * g++.dg/cpp0x/auto30.C: New test. From-SVN: r182375
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r--gcc/cp/decl.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 480d211..1fe63bb 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -4140,6 +4140,12 @@ check_tag_decl (cp_decl_specifier_seq *declspecs)
error_p = true;
if (declared_type == NULL_TREE && ! saw_friend && !error_p)
permerror (input_location, "declaration does not declare anything");
+ else if (declared_type != NULL_TREE && type_uses_auto (declared_type))
+ {
+ error ("%<auto%> can only be specified for variables "
+ "or function declarations");
+ return error_mark_node;
+ }
/* Check for an anonymous union. */
else if (declared_type && RECORD_OR_UNION_CODE_P (TREE_CODE (declared_type))
&& TYPE_ANONYMOUS_P (declared_type))