[clang] [Clang] disallow use of attributes before extern template declarations (PR #136328)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 18 14:31:19 PDT 2025
================
@@ -1049,6 +1049,7 @@ Parser::ParseExternalDeclaration(ParsedAttributes &Attrs,
case tok::kw_extern:
if (getLangOpts().CPlusPlus && NextToken().is(tok::kw_template)) {
+ ProhibitAttributes(Attrs);
----------------
erichkeane wrote:
>I followed this part of the spec
Yep, understood. But `attribute-specifier-seq` is ONLY the `[[...]]` spelling. The REST is implementation defined extensions (that is, `__attribute__((..))` and `__declspec(..)` spellings).
That said, I spent some time looking, and both MSVC and GCC compilers seem to get thrown off pretty terribly by `<attribute-tokens> extern template`, so unless @AaronBallman can think of others, I think I'm ok with this.
I WOULD like to have our test check `__attribute__` and a `__declspec` variant as well though, so please add a test for those.
https://github.com/llvm/llvm-project/pull/136328
More information about the cfe-commits
mailing list