[clang] [Clang] disallow use of attributes before extern template declarations (PR #136328)
Oleksandr T. via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 18 14:17:01 PDT 2025
================
@@ -1049,6 +1049,7 @@ Parser::ParseExternalDeclaration(ParsedAttributes &Attrs,
case tok::kw_extern:
if (getLangOpts().CPlusPlus && NextToken().is(tok::kw_template)) {
+ ProhibitAttributes(Attrs);
----------------
a-tarasyuk wrote:
@erichkeane, thanks for the feedback. I followed this part of the spec
> No [attribute-specifier-seq](https://eel.is/c++draft/dcl.attr.grammar#nt:attribute-specifier-seq) ([[dcl.attr.grammar]](https://eel.is/c++draft/dcl.attr.grammar)) shall appertain to an [explicit instantiation](https://eel.is/c++draft/temp.explicit#3.sentence-3).
I also checked how GCC handles this case, and it seems that it disallows all kinds of attrs.
Should non-standard attributes be applied to this `S<int>` (_if we are talking about the current test case_) declaration?
https://github.com/llvm/llvm-project/pull/136328
More information about the cfe-commits
mailing list