[clang] [clang][nullability] allow _Nonnull etc on nullable class types (PR #82705)

Sam McCall via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 11 06:30:19 PDT 2024


================
@@ -1494,6 +1494,15 @@ void Parser::ParseMicrosoftInheritanceClassAttributes(ParsedAttributes &attrs) {
   }
 }
 
+void Parser::ParseNullabilityClassAttributes(ParsedAttributes &attrs) {
+  while (Tok.is(tok::kw__Nullable)) {
----------------
sam-mccall wrote:

It's not important that we accept it, but I think better than changing this to `if`:

- consistent with other attributes: we accept `struct [[nodiscard]] [[nodiscard]] S{};`
- if we forbid this here by not parsing the second `_Nullable` as an attribute, we'll parse it as a class name instead which I think is unlikely to be the intent. The follow-on diagnostics are pretty bad.
- on the other hand, if we forbid this elsewhere by checking the attribute list, this costs extra ad-hoc code that (I think) we've decided isn't worth it for other attributes

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


More information about the cfe-commits mailing list