[all-commits] [llvm/llvm-project] 8bd005: [clang][parser] Allow GNU attributes before namesp...

Aleksandr Platonov via All-commits all-commits at lists.llvm.org
Tue Mar 15 12:31:54 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8bd00557e3f43b46a96cf0e357d5e65624c85a2b
      https://github.com/llvm/llvm-project/commit/8bd00557e3f43b46a96cf0e357d5e65624c85a2b
  Author: Aleksandr Platonov <platonov.aleksandr at huawei.com>
  Date:   2022-03-15 (Tue, 15 Mar 2022)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/lib/Parse/ParseDeclCXX.cpp
    A clang/test/Parser/namespace-attributes.cpp

  Log Message:
  -----------
  [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




More information about the All-commits mailing list