Skip to content

_Generic in C++ doesn't allow an elaborated type specifier as an association #55562

@AaronBallman

Description

@AaronBallman

Clang supports _Generic as an extension in C++ mode, but the following C++ code doesn't parse when it should:

struct S {
  int i;
};

void func(struct S s) {
  (void)_Generic(s, struct S : 1); //  error: 'S' cannot be defined in a type specifier \
                                       error: expected class name \
                                       error: expected '{' after base class list
                                           
}

This use is not defining a new type specifier, it's attempting to use an elaborated type specifier for referencing the type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions