[clang] [Clang] disallow use of attributes before extern template declarations (PR #136328)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 21 06:15:56 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 think it's reasonable to reject all attributes.
> 
> > ALSO: I checked and this should only prevent regular keywords-as-attributes, which seem to only be ARM based ones, so this won't affect things like __alignas or calling conventions/etc.
> 
> @erichkeane I don't follow this comment. I think we should reject all attributes, not keywords implemented as an attribute. Right?

AH, yes, sorry, I spent some time looking at this code and confirmed the above, it wasn't a request for the submitter.

This currently rejects all attributes and 'regular-keywords' (as spelled in `Attr.td`).  BUT those are only ARM ones, so those are fine IMO.

https://github.com/llvm/llvm-project/pull/136328


More information about the cfe-commits mailing list