[PATCH] D121245: [clang][parser] Allow GNU attributes before namespace identifier

Aleksandr Platonov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Mar 12 12:13:09 PST 2022


ArcsinX marked an inline comment as done.
ArcsinX added inline comments.


================
Comment at: clang/lib/Parse/ParseDeclCXX.cpp:79
+
+  auto ReadLabelAttrubutes = [&] {
+    // Read label attributes, if present.
----------------
aaron.ballman wrote:
> However, I don't think there's a reason we need this lambda -- it seems we can call `MaybeParseGNUAttributes()` instead, and get the attribute location from the `ParsedAttributesWithRange` object passed in.
`MaybeParseAttributes(PAKM_GNU | PAKM_CXX11, Attrs)` parses different kind of attributes in a loop (e.g. `struct __attribute__(()) [[]] [[]] __attribute__(()) S {};` is valid for clang), but we can't use it because we need to warn about c++11 attributes usage for namespace if c++ < 17. So, I added a lambda which works similar to `MaybeParseAttributes()`.

Thus, now clang handles attributes for namespace like it handle attributes for structure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121245



More information about the cfe-commits mailing list