[PATCH] D97362: [clang][parser] Allow attributes in explicit template instantiations

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 3 06:26:40 PST 2021


aaron.ballman added inline comments.


================
Comment at: clang/lib/Parse/ParseDecl.cpp:1618
+
+    if (Tok && (*Tok).is(tok::l_square)) {
+      Diag(Attrs.Range.getBegin(), diag::err_attributes_not_allowed) << Attrs.Range;
----------------
This will incorrectly classify an empty MS attribute `[]` as being a prohibited `[[]]` attribute. I think we need something like:
```
if (Tok && Tok->is(tok::l_square)) {  
 SourceLocation NextTokLoc = Lexer::findLocationAfterToken(Attrs.Range.getBegin(), Tok.getKind(), SM, getLangOpts(), true);
 auto NextTok = Lexer::findNextToken(NextTokLoc, SM, getLangOpts());
 if (NextTok && NextTok->is(tok::l_square)) {
   ...
 }
}
```
Also, I think it should use `DiagID` rather than hard-coding the diagnostic to use.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97362/new/

https://reviews.llvm.org/D97362



More information about the cfe-commits mailing list