We can't talk about the type if there is no type. Tested x86_64-pc-linux-gnu, applying to trunk.
commit bc94f519583cdfc705c1bde750a06bbd42537193 Author: Jason Merrill <ja...@redhat.com> Date: Wed Apr 11 10:08:37 2012 -0400
PR c++/52906 * decl.c (check_tag_decl): Don't complain about attributes if we don't even have a type. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index e2f01d5..8b22192 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -4224,7 +4224,7 @@ check_tag_decl (cp_decl_specifier_seq *declspecs) error ("%<constexpr%> cannot be used for type declarations"); } - if (declspecs->attributes && warn_attributes) + if (declspecs->attributes && warn_attributes && declared_type) { location_t loc; if (!CLASS_TYPE_P (declared_type) diff --git a/gcc/testsuite/g++.dg/ext/attrib45.C b/gcc/testsuite/g++.dg/ext/attrib45.C new file mode 100644 index 0000000..0be1322 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/attrib45.C @@ -0,0 +1,3 @@ +// PR c++/52906 + +__attribute__ ((__deprecated__)); // { dg-error "does not declare anything" }