Skip to content

[clang] "'auto' cannot be combined with a type specifier" when an auto declarator-id shadows a type and is followed by asm / __attribute__ / alignas #213082

Description

@patrykstefanski

Since 72af746 (#208552), clang rejects a declaration of the form:

auto NAME <token> ...;

when NAME also names a type and <token> is not on the list that #208552 introduced. tok::l_brace was added to that list by #210347, but tok::kw_asm, tok::kw___attribute and tok::kw_alignas seem to be missing:

https://godbolt.org/z/av3zWe8xf

struct Foo {};
struct Bar {};
struct Baz {};

auto Foo asm("foo_label") = 0;         // (1)
auto Bar __attribute__((unused)) = 0;  // (2)
auto Baz alignas(4) = 0;               // (3)

Clang releases predating 72af746 accept all of these. I'm not sure if this is expected or a regression.

CC @to268

Metadata

Metadata

Assignees

Labels

clang:frontendLanguage frontend issues, e.g. anything involving "Sema"

Type

No type

Projects

Status
Needs Triage

Relationships

None yet

Development

No branches or pull requests

Issue actions