aaron.ballman added inline comments.

================
Comment at: clang/lib/Parse/ParseDeclCXX.cpp:1828-1830
+      // Allow only GNU attributes here.
+      if (!attrs.hasOnlyGNUAttributes())
+        ProhibitAttributes(attrs);
----------------
tbaeder wrote:
> aaron.ballman wrote:
> > 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.
> Unfortunately, also diagnosing empty `[[]]` triggers a whole lot of the 
> tests, e.g. because `int [[]] foo;` now starts warning.
Yeah, I would not be surprised that other parts of the system are accidentally 
relying on silently accepting `[[]]`. I would guess the warning about `int [[]] 
foo;` is because we don't *support* any attributes in that position currently 
rather than because the attribute list is prohibited from being in that 
position.

Typically, we use `DiagnoseAndSkipCXX11Attributes()` when we are not allowed to 
*parse* the attribute list in a given position and we use 
`ProhibitCXX11Attributes()` when we've already done the parsing work but don't 
support attributes in that position. However, I think this case would be 
difficult to implement at the parsing level (but maybe I'm wrong).

One possible way forward is to add a parameter to `ProhibitCXX11Attributes()` 
for whether to diagnose an empty list or not.


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

https://reviews.llvm.org/D97362

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to