[mlir] Improve error message when number of operands and types differ (#118488)
[llvm-project.git] / clang / test / AST / ByteCode / c23.c
blob5154d57f6cb9e77f10d4b081b1023078626a85ec
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 // RUN: %clang_cc1 -std=c23 -triple=aarch64_be-linux-gnu -fexperimental-new-constant-interpreter -verify=expected,both %s
4 // RUN: %clang_cc1 -std=c23 -triple=aarch64_be-linux-gnu -verify=ref,both %s
7 typedef typeof(nullptr) nullptr_t;
9 const _Bool inf1 = (1.0/0.0 == __builtin_inf());
10 constexpr _Bool inf2 = (1.0/0.0 == __builtin_inf()); // both-error {{must be initialized by a constant expression}} \
11 // both-note {{division by zero}}
12 constexpr _Bool inf3 = __builtin_inf() == __builtin_inf();
14 /// Used to crash.
15 struct S {
16 int x;
17 char c;
18 float f;
21 #define DECL_BUFFER(Ty, Name) alignas(Ty) unsigned char Name[sizeof(Ty)]
23 char bar() {
24 DECL_BUFFER(struct S, buffer);
25 ((struct S *)buffer)->c = 'a';
26 return ((struct S *)buffer)->c;
29 static_assert((nullptr_t){} == 0);
31 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
32 # define LITTLE_END 1
33 #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
34 # define LITTLE_END 0
35 #else
36 # error "huh?"
37 #endif
39 typedef unsigned char u8x4_t __attribute__((vector_size(4)));
40 constexpr u8x4_t arg1 = (u8x4_t)0xCAFEBABE; // okay
41 #if LITTLE_END
42 static_assert(arg1[0] == 190);
43 static_assert(arg1[1] == 186);
44 static_assert(arg1[2] == 254);
45 static_assert(arg1[3] == 202);
46 #else
47 static_assert(arg1[0] == 202);
48 static_assert(arg1[1] == 254);
49 static_assert(arg1[2] == 186);
50 static_assert(arg1[3] == 190);
51 #endif