https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120635
--- Comment #9 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <[email protected]>: https://gcc.gnu.org/g:b77cf8f055cce3e42f09410cbbf1e4f1e196b25d commit r17-2405-gb77cf8f055cce3e42f09410cbbf1e4f1e196b25d Author: Jakub Jelinek <[email protected]> Date: Wed Jul 15 09:21:41 2026 +0200 c++: In attributes expect _Clang namespace rather than __clang__ [PR120635] Apparently in clang __clang__ is a predefined macro (predefined to 1). Because of that, clang doesn't have alternate spelling of its scoped attributes as [[__clang__::__something__]] but [[_Clang::__something__]] The former isn't accepted even with -U__clang__. For GNU attributes they do handle [[__gnu__::__something__]] like GCC does (if they support a particular attribute). So, I'm afraid if we want to stay compatible with this mess, we need to do the same thing. The following patch does that. It emits a warning when one attempts to use the __clang__ attribute namespace suggesting to use _Clang instead (clang++ does that too), but in __has_cpp_attribute/__has_attribute doesn't do that, just ensures that 0 is returned in that case (i.e. it is not canonicalized in that case), just canonicalizes _Clang to clang. 2026-07-15 Jakub Jelinek <[email protected]> PR c++/120635 gcc/ * doc/extend.texi: Document variant spelling of standard attributes and that alternate namespace spelling for clang namespace is _Clang rather than __clang__. For no_specializations use _Clang:: rather than __clang__::. gcc/c-family/ * c-lex.cc (c_common_has_attribute): For __clang__ namespace don't call canonicalize_attr_name and for _Clang use clang instead. gcc/cp/ * parser.cc (cp_parser_std_attribute): Add canonicalize_attr_ns_name lambda and use it instead of canonicalize_attr_name for namespaces. Emit a warning on __clang__::. (cp_parser_std_attribute_spec): Emit a warning on using __clang__:. gcc/testsuite/ * g++.dg/cpp0x/attr-trivial_abi8.C: Add further tests. * g++.dg/cpp0x/attr-trivial_abi11.C: New test. * g++.dg/ext/attr-no_specializations1.C: Use _Clang:: instead of __clang__. * g++.dg/ext/attr-no_specializations2.C: Likewise. * g++.dg/ext/attr-no_specializations6.C: Likewise. * g++.dg/ext/attr-no_specializations7.C: Likewise. * g++.dg/ext/attr-no_specializations8.C: Likewise. * g++.dg/ext/attr-no_specializations10.C: Add further tests. * g++.dg/ext/attr-no_specializations12.C: New test. Reviewed-by: Jason Merrill <[email protected]>
