Debian Codegraph @

clang/test/C/C23/n2653.c

raw
1 // RUN: %clang_cc1 -ffreestanding -verify=c23 -std=c23 %s
2 // RUN: %clang_cc1 -ffreestanding -verify=c17 -std=c17 %s
3
4 // c23-no-diagnostics
5
6 #include <stdatomic.h>
7
8 #define __enable_constant_folding(x) (__builtin_constant_p(x) ? (x) : (x))
9 #define __is_same(a, b) (__extension__ _Generic(a, b: 1, default: 0) && __extension__ _Generic(b, a: 1, default: 0))
10
11 #ifndef ATOMIC_CHAR8_T_LOCK_FREE
12 #error missing
13 #endif
14 // c17-error@-2 {{missing}}
15
16 _Static_assert(__is_same(atomic_char8_t, unsigned char _Atomic), "");
17 // c17-error@-1 {{use of undeclared identifier 'atomic_char8_t'}}
18 // c17-error@-2 {{unknown type name 'atomic_char8_t'}}
19
20 _Static_assert(_Generic(u8"", unsigned char*: 1, char*: 0), "");
21 // c17-error@-1 {{static assertion failed}}
22
23 // -fsigned-char is the default
24 #define M(X) __enable_constant_folding((X) >= 0x80)
25
26 _Static_assert(M(u8"\U000000E9"[0]), "");
27 // c17-error@-1 {{static assertion failed}}
28 #if __STDC_VERSION__ >= 202311L
29 _Static_assert(M(u8'\xC3'), "");
30 #endif
31
32 const char cu8[] = u8"text";
33 const signed char scu8[] = u8"text";
34 const unsigned char ucu8[] = u8"text";