Debian Codegraph @

clang/test/AST/Interp/c23.c

raw
1 // RUN: %clang_cc1 -std=c23 -fexperimental-new-constant-interpreter -verify=expected,both %s
2 // RUN: %clang_cc1 -std=c23 -verify=ref,both %s
3
4
5
6 const _Bool inf1 = (1.0/0.0 == __builtin_inf());
7 constexpr _Bool inf2 = (1.0/0.0 == __builtin_inf()); // both-error {{must be initialized by a constant expression}} \
8 // both-note {{division by zero}}
9 constexpr _Bool inf3 = __builtin_inf() == __builtin_inf();
10
11 /// Used to crash.
12 struct S {
13 int x;
14 char c;
15 float f;
16 };
17
18 #define DECL_BUFFER(Ty, Name) alignas(Ty) unsigned char Name[sizeof(Ty)]
19
20 char bar() {
21 DECL_BUFFER(struct S, buffer);
22 ((struct S *)buffer)->c = 'a';
23 return ((struct S *)buffer)->c;
24 }