https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110345
--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:49b142f2ef5d985dd6c4509d692ee4dfedfd4658 commit r15-6328-g49b142f2ef5d985dd6c4509d692ee4dfedfd4658 Author: Jakub Jelinek <ja...@redhat.com> Date: Wed Dec 18 11:52:31 2024 +0100 c++: Handle enum attributes like class attributes [PR110345] As the following testcase shows, cp_parser_decl_specifier_seq was calling warn_misplaced_attr_for_class_type only for class types and not for enum types, while check_tag_decl calls them for both class and enum types. Enum types are really the same case here, the attribute needs to go before the type name to apply to all instances of the type. Additionally, when warn_misplaced_attr_for_class_type is called, it diagnoses something and so it is fine to drop the attributes then on the floor, but in case it wasn't a type decision, it silently discarded the attributes, which is invalid for the ignorability of standard attributes paper. This patch in that case adds them to decl_specs->std_attributes and let it be diagnosed later (e.g. in grokdeclarator). 2024-12-18 Jakub Jelinek <ja...@redhat.com> PR c++/110345 * parser.cc (cp_parser_decl_specifier_seq): Call warn_misplaced_attr_for_class_type for all OVERLOAD_TYPE_P types, not just CLASS_TYPE_P. When not calling warn_misplaced_attr_for_class_type, don't clear attrs and add it to decl_specs->std_attributes instead. * g++.dg/cpp0x/gen-attrs-85.C: New test.