@@ -16565,13 +16565,13 @@ cp_parser_decl_specifier_seq (cp_parser*
diagnose_misapplied_contracts (attrs);
attrs = NULL_TREE;
}
- else if (decl_specs->type && CLASS_TYPE_P (decl_specs->type))
+ else if (decl_specs->type
+ && decl_specs->type_definition_p
+ && OVERLOAD_TYPE_P (decl_specs->type))
{
- /* This is an attribute following a
- class-specifier. */
- if (decl_specs->type_definition_p)
- warn_misplaced_attr_for_class_type (token->location,
- decl_specs->type);
+ /* This is an attribute following a class-specifier. */
+ warn_misplaced_attr_for_class_type (token->location,
+ decl_specs->type);
attrs = NULL_TREE;
}
else
@@ -0,0 +1,7 @@
+// { dg-do compile { target c++11 } }
+
+struct S {};
+struct S [[gnu::deprecated]] s; // { dg-warning "attribute ignored" }
+// { dg-message "an attribute that appertains to a type-specifier is ignored" "" { target *-*-* } .-1 }
+enum E {} [[gnu::deprecated]]; // { dg-warning "attribute ignored in declaration of 'enum E'" }
+// { dg-message "attribute for 'enum E' must follow the 'enum' keyword" "" { target *-*-* } .-1 }