From 614bac3f30c3ba76bb726fab80b27dc433457d38 Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 28 Aug 2007 13:57:09 +0000 Subject: [PATCH] PR c++/28558 * cp/decl.c (groktypename): Ignore attributes applied to class type. * testsuite/g++.dg/ext/attrib28.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@127859 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/decl.c | 8 +++++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/ext/attrib28.C | 12 ++++++++++++ 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/ext/attrib28.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a6222faae7a..03d6b51c1a6 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2007-08-27 Jason Merrill + + PR c++/28558 + * decl.c (groktypename): Ignore attributes applied to class type. + 2007-08-28 Richard Guenther * decl.c (duplicate_decls): Merge DECL_DISREGARD_INLINE_LIMITS. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index fdccb3542ad..3117a7a33eb 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -3877,7 +3877,13 @@ groktypename (cp_decl_specifier_seq *type_specifiers, type_specifiers->attributes = NULL_TREE; type = grokdeclarator (declarator, type_specifiers, TYPENAME, 0, &attrs); if (attrs) - cplus_decl_attributes (&type, attrs, 0); + { + if (CLASS_TYPE_P (type)) + warning (OPT_Wattributes, "ignoring attributes applied to class type " + "outside of definition"); + else + cplus_decl_attributes (&type, attrs, 0); + } return type; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f3a78804c85..b71ec15f826 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-08-28 Jason Merrill + + PR c++/28558 + * g++.dg/ext/attrib28.C: New test. + 2007-08-28 Uros Bizjak PR target/32661 diff --git a/gcc/testsuite/g++.dg/ext/attrib28.C b/gcc/testsuite/g++.dg/ext/attrib28.C new file mode 100644 index 00000000000..2f18d418418 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/attrib28.C @@ -0,0 +1,12 @@ +// PR c++/28558 +// { dg-options "" } + +struct A +{ + A(int) { } +}; + +int main() +{ + A a = (A __attribute__((unused)))0; // { dg-warning "attribute" } +} -- 2.11.4.GIT