| 1 |
// RUN: %clang_cc1 -triple x86_64-linux -std=c23 -fsyntax-only -verify %s |
| 2 |
// expected-no-diagnostics |
| 3 |
|
| 4 |
#define INT64_MIN (-9223372036854775807LL - 1) |
| 5 |
|
| 6 |
void t1() { |
| 7 |
{ |
| 8 |
enum { A }; |
| 9 |
enum { B }; |
| 10 |
|
| 11 |
_Static_assert(_Generic(A, typeof(B): 1, default: 0) == 1, ""); |
| 12 |
_Static_assert(_Generic(typeof(A), typeof(B): 1, default: 0) == 1, ""); |
| 13 |
} |
| 14 |
|
| 15 |
{ |
| 16 |
_Static_assert( |
| 17 |
_Generic(typeof(enum {A}), typeof(enum {B}): 1, default: 0) == 0, ""); |
| 18 |
} |
| 19 |
} |
| 20 |
|
| 21 |
void t2() { |
| 22 |
{ |
| 23 |
enum : int { A }; |
| 24 |
enum : int { B }; |
| 25 |
|
| 26 |
_Static_assert(_Generic(A, typeof(B): 1, default: 0) == 0, ""); |
| 27 |
_Static_assert(_Generic(typeof(A), typeof(B): 1, default: 0) == 0, ""); |
| 28 |
} |
| 29 |
|
| 30 |
{ |
| 31 |
_Static_assert( |
| 32 |
_Generic(typeof(enum : int{A}), typeof(enum : int{B}): 1, default: 0) == 0, ""); |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
void t3() { |
| 37 |
{ |
| 38 |
enum { A = INT64_MIN }; |
| 39 |
enum { B = INT64_MIN }; |
| 40 |
|
| 41 |
_Static_assert(_Generic(A, __typeof__(B): 1, default: 0) == 0, ""); |
| 42 |
_Static_assert(_Generic(__typeof__(A), __typeof__(B): 1, default: 0) == 0, ""); |
| 43 |
} |
| 44 |
|
| 45 |
{ |
| 46 |
enum : long long { A = INT64_MIN }; |
| 47 |
enum : long long { B = INT64_MIN }; |
| 48 |
|
| 49 |
_Static_assert(_Generic(A, __typeof__(B): 1, default: 0) == 0, ""); |
| 50 |
_Static_assert(_Generic(__typeof__(A), __typeof__(B): 1, default: 0) == 0, ""); |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
void t4() { |
| 55 |
enum : int { A }; |
| 56 |
enum : int { B }; |
| 57 |
|
| 58 |
_Static_assert(_Generic(A, typeof(B): 1, typeof(A): 2, default: 0) == 2, ""); |
| 59 |
} |