Commit Graph

1 Commits

Author SHA1 Message Date
Aleksandr Platonov 8bd00557e3 [clang][parser] Allow GNU attributes before namespace identifier
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).

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D121245
2022-03-15 22:30:22 +03:00