https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105377
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> --- But we don['t want to use gnu++17 because we want the compiler to be built using portable ISO C++17. An unrecognized attribute is a portable ISO C++17 construct, it just doesn't do anything (except maybe give a warning). We could add: #ifdef __clang__ #pragma clang diagnostic ignored "-Wc++20-attribute-extensions" #endif To disable this warning, since we know we're already guarding the attribute with __has_cpp_attribute.