From f03e689a9db25772c9650630bff7333bbf01c43d Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Thu, 15 Dec 2011 15:40:25 +0000 Subject: [PATCH] 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 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/decl.c | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/auto30.C | 9 +++++++++ 4 files changed, 26 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/auto30.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7e99f58f037..3e56008703c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2011-12-15 Dodji Seketeli + + PR c++/51473 + * decl.c (check_tag_decl): Error out on auto specifier with no + declarator. + 2011-12-15 Jonathan Wakely PR libstdc++/51365 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 480d211871a..1fe63bb3564 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 ("% 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)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 465097785cd..331ef1c9d45 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-12-15 Dodji Seketeli + + PR c++/51473 + * g++.dg/cpp0x/auto30.C: New test. + 2011-12-15 Tobias Burnus * gfortran.dg/coarray/poly_run_3.f90: New. diff --git a/gcc/testsuite/g++.dg/cpp0x/auto30.C b/gcc/testsuite/g++.dg/cpp0x/auto30.C new file mode 100644 index 00000000000..d26e290f5cc --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto30.C @@ -0,0 +1,9 @@ +// Origin PR c++/51473 +// { dg-options "-std=c++11" } + +struct A +{ + auto friend struct B; // { dg-error "multiple types|can only be specified|friend" } +}; + +auto int; // { dg-error "multiple types|can only be specified for variables" } -- 2.30.2