1 // RUN: %clang_cc1 %s -fsyntax-only --embed-dir=%S/Inputs -verify -Wno-c23-extensions 2 // RUN: %clang_cc1 %s -fsyntax-only --embed-dir=%S/Inputs -verify -fexperimental-new-constant-interpreter -Wno-c23-extensions 3 4 constexpr int value(int a, int b) { 5 return a + b; 6 } 7 8 constexpr int func_call() { 9 return value( 10 #embed <jk.txt> 11 ); 12 } 13 14 constexpr int init_list_expr() { 15 int vals[] = { 16 #embed <jk.txt> 17 }; 18 return value(vals[0], vals[1]); 19 } 20 21 template <int N, int M> 22 struct Hurr { 23 static constexpr int V1 = N; 24 static constexpr int V2 = M; 25 }; 26 27 constexpr int template_args() { 28 Hurr< 29 #embed <jk.txt> 30 > H; 31 return value(H.V1, H.V2); 32 } 33 34 constexpr int ExpectedValue = 'j' + 'k'; 35 static_assert(func_call() == ExpectedValue); 36 static_assert(init_list_expr() == ExpectedValue); 37 static_assert(template_args() == ExpectedValue); 38 39 static_assert( 40 #embed <jk.txt> limit(1) suffix(== 'j') 41 ); 42 43 int array[ 44 #embed <jk.txt> limit(1) 45 ]; 46 static_assert(sizeof(array) / sizeof(int) == 'j'); 47 48 constexpr int comma_expr = ( 49 #embed <jk.txt> // expected-warning {{left operand of comma operator has no effect}} 50 ); 51 static_assert(comma_expr == 'k'); 52 53 constexpr int comma_expr_init_list{ ( 54 #embed <jk.txt> limit(1) 55 ) }; 56 static_assert(comma_expr_init_list == 'j'); 57 58 constexpr int paren_init( 59 #embed <jk.txt> limit(1) 60 ); 61 static_assert(paren_init == 'j'); 62 63 struct S { 64 const char buffer[2] = { 65 #embed "jk.txt" 66 }; 67 }; 68 69 constexpr struct S s; 70 static_assert(s.buffer[1] == 'k'); 71 72 struct S1 { 73 int x, y; 74 }; 75 76 struct T { 77 int x, y; 78 struct S1 s; 79 }; 80 81 constexpr struct T t[] = { 82 #embed <numbers.txt> 83 }; 84 static_assert(t[0].s.x == '2'); 85 86 constexpr int func(int i, int) { return i; } 87 static_assert( 88 func( 89 #embed <jk.txt> 90 ) == 'j'); 91 92 template <int N> 93 struct ST {}; 94 95 ST< 96 #embed <jk.txt> limit(1) 97 > st; 98