GCC supports:
- namespace <gnu attributes> identifier
- namespace identifier <gnu attributes>
But clang supports only namespace identifier <gnu attributes> and diagnostics for namespace <gnu attributes> identifier case looks unclear:
Code:
namespace __attribute__((visibility("hidden"))) A { }
Diags:
test.cpp:1:49: error: expected identifier or '{' namespace __attribute__((visibility("hidden"))) A ^ test.cpp:1:49: error: C++ requires a type specifier for all declarations test.cpp:3:2: error: expected ';' after top level declarator }
This patch adds support for namespace <gnu attributes> identifier and also forbids gnu attributes for nested namespaces (this already done for C++ attributes).
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.