This call to ProhibitAttributes() is almost always dead code.
For GNU attributes, it always is, even though they are being used in explicit template instantiations in, e.g. in clang/test/CodeGenCXX/visibility.cpp:
#define DEFAULT __attribute__((visibility("default"))) namespace PR11690 { template<class T> struct Class { void size() const { } }; template class DEFAULT Class<char>; }
This code is accepted by current g++ and clang++, even though the code claims to reject it because of the attributes.
If the attributes are changed to C++ attributes however, clang++ _does_ reject it:
#define DEFAULT [[]] namespace PR11690 { template<class T> struct Class { void size() const { } }; template class DEFAULT Class<char>; }
But g++ still accepts the above code. Simply ignoring the attributes does not work either as it breaks tests (e.g. the visibility test from above).
I am not sure why or if GNU-style and C++ attributes should be handled differently here, so I am open for a discussion but this call seems mislead to me.
Thanks,
Timm
We really should be using ProhibitCXX11Attributes() here, but that doesn't currently handle the case where it's an empty attribute list. However, we could use the valid source range information in that case to look at the tokens used to decide whether to diagnose or not.