From d4655dc7dd7f36c1fd31c12dd912ec1a78654f10 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 22 Mar 2012 21:25:02 +0100 Subject: [PATCH] re PR c++/52671 (ICE with misplaced attribute on enum) PR c++/52671 * decl.c (check_tag_decl): Only use CLASSTYPE_TEMPLATE_INSTANTIATION on CLASS_TYPE_P types. * g++.dg/ext/attrib44.C: New test. From-SVN: r185709 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/decl.c | 3 ++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/ext/attrib44.C | 4 ++++ 4 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/ext/attrib44.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 370fd7abd63..7da7f59872f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2012-03-22 Jakub Jelinek + + PR c++/52671 + * decl.c (check_tag_decl): Only use CLASSTYPE_TEMPLATE_INSTANTIATION + on CLASS_TYPE_P types. + 2012-03-20 Jason Merrill * lex.c (init_reswords): Use >= for cxx_dialect test. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 2b2a551740e..e664d43285b 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -4219,7 +4219,8 @@ check_tag_decl (cp_decl_specifier_seq *declspecs) if (declspecs->attributes && warn_attributes) { location_t loc; - if (!CLASSTYPE_TEMPLATE_INSTANTIATION (declared_type)) + if (!CLASS_TYPE_P (declared_type) + || !CLASSTYPE_TEMPLATE_INSTANTIATION (declared_type)) /* For a non-template class, use the name location. */ loc = location_of (declared_type); else diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0e668832be3..36bb18b96e5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-03-22 Jakub Jelinek + + PR c++/52671 + * g++.dg/ext/attrib44.C: New test. + 2012-03-22 Jan Hubicka PR middle-end/51737 diff --git a/gcc/testsuite/g++.dg/ext/attrib44.C b/gcc/testsuite/g++.dg/ext/attrib44.C new file mode 100644 index 00000000000..ae08191d8ff --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/attrib44.C @@ -0,0 +1,4 @@ +// PR c++/52671 +// { dg-do compile } +__attribute__ ((deprecated)) enum E { E0 }; // { dg-warning "attribute ignored in declaration of" } +// { dg-message "must follow the" "" { target *-*-* } 3 } -- 2.11.4.GIT