blob: ce621255e81ec3da36bc46451819e2d2f3192e62 [file] [edit]
// RUN: %clang_cc1 -fsyntax-only -verify -std=c23 %s
// RUN: %clang_cc1 -fsyntax-only -verify -x c++ %s
typedef long l;
enum E : long { X };
#ifdef __cplusplus
static_assert(_Generic(0L, enum A : l { B } : 1, int: 0), ""); // expected-error {{'A' cannot be defined in a type specifier}}
enum X { Y };
void f()
{
static_assert(_Generic(0L, enum X : int {Y}, long: 1), "'int {Y}' parses as an expression");
}
#else
// expected-no-diagnostics
static_assert(_Generic(0L, enum E : long { X } : 1, int: 0), "");
static_assert(_Generic(0L, enum E : 1, int: 0), "");
static_assert(_Generic(0L, enum A : l { B } : 1, int: 0), "");
static_assert(_Generic(0L, struct { enum A : l { B } a : 1; } : 0, long: 1), "");
static_assert(_Generic(0, struct S { enum F : int {A} : 1; } : 0, int: 1));
static_assert(_Generic(0, struct S { enum E : 1; } : 0, int: 1));
#endif