| 1 |
// REQUIRES: host-supports-jit |
| 2 |
// RUN: cat %s | clang-repl -Xcc -xc | FileCheck %s |
| 3 |
// RUN: cat %s | clang-repl -Xcc -std=c++11 | FileCheck %s |
| 4 |
// RUN: cat %s | clang-repl -Xcc -xc -Xcc -std=c89 | FileCheck %s |
| 5 |
|
| 6 |
// UNSUPPORTED: hwasan, msan |
| 7 |
|
| 8 |
|
| 9 |
char c = 'a'; c |
| 10 |
// CHECK: (char) 'a' |
| 11 |
|
| 12 |
const char* c_str = "Hello, world!"; c_str |
| 13 |
// CHECK-NEXT: (const char *) "Hello, world!" |
| 14 |
|
| 15 |
c_str = "Goodbye, world!"; c_str |
| 16 |
// CHECK-NEXT: (const char *) "Goodbye, world!" |
| 17 |
|
| 18 |
const char* c_null_str = 0; c_null_str |
| 19 |
// CHECK-NEXT: (const char *) 0 |
| 20 |
|
| 21 |
"Hello, world" |
| 22 |
// CHECK-NEXT: ({{(const )?}}char[13]) "Hello, world" |
| 23 |
|
| 24 |
printf("Hello World\n"); |
| 25 |
// expected-error {{call to undeclared library function 'printf' with type 'int (const char *, ...)' }} |
| 26 |
|
| 27 |
int x = 42; x |
| 28 |
// CHECK-NEXT: (int) 42 |
| 29 |
|
| 30 |
&x |
| 31 |
// CHECK-NEXT: (int *) 0x{{[0-9a-f]+}} |
| 32 |
|
| 33 |
x - 2 |
| 34 |
// CHECK-NEXT: (int) 40 |
| 35 |
|
| 36 |
float f = 4.2f; f |
| 37 |
// CHECK-NEXT: (float) 4.20000f |
| 38 |
|
| 39 |
double d = 4.21; d |
| 40 |
// CHECK-NEXT: (double) 4.2100000 |
| 41 |
|
| 42 |
long double tau = 6.2831853; tau |
| 43 |
// CHECK-NEXT: (long double) 6.28318530000L |
| 44 |
|
| 45 |
int foo() { return 42; } foo() |
| 46 |
// CHECK-NEXT: (int) 42 |
| 47 |
|
| 48 |
void bar(int a, float b) {} bar |
| 49 |
// CHECK-NEXT: (void (int, float)) Function @0x{{[0-9a-f]+}} |
| 50 |
// CHECK-NEXT: void bar(int a, float b) { |
| 51 |
|
| 52 |
bar |
| 53 |
// CHECK: (void (int, float)) Function @0x{{[0-9a-f]+}} |
| 54 |
// CHECK-NEXT: void bar(int a, float b) { |
| 55 |
|
| 56 |
// Arrays. |
| 57 |
|
| 58 |
int arr[3] = {1,2,3}; arr |
| 59 |
// CHECK: (int[3]) { 1, 2, 3 } |
| 60 |
|
| 61 |
double darr[3][4] = { {1,2,3,4}, {5,6,7,8}, {9,10,11,12} }; darr |
| 62 |
// CHECK-NEXT: (double[3][4]) { { 1.0, 2.0, 3.0, 4.0 }, { 5.0, 6.0, 7.0, 8.0 }, { 9.0, 10.0, 11.0, 12.0 } } |
| 63 |
|
| 64 |
float farr[2][1] = { {0}, {3.14}}; farr |
| 65 |
// CHECK-NEXT: (float[2][1]) { { 0.0f }, { 3.14000f } } |
| 66 |
|
| 67 |
0./0. |
| 68 |
// CHECK-NEXT: (double) nan |
| 69 |
|
| 70 |
1.0f / 0.0f |
| 71 |
// CHECK-NEXT: (float) inf |
| 72 |
|
| 73 |
0.00001f |
| 74 |
// CHECK-NEXT: (float) 1.00000e-05f |
| 75 |
|
| 76 |
int * ptr = (int*)0x123; ptr |
| 77 |
// CHECK-NEXT: (int *) 0x123 |
| 78 |
|
| 79 |
int * null_ptr = (int*)0; null_ptr |
| 80 |
// CHECK-NEXT: (int *) 0x0 |
| 81 |
|
| 82 |
union U { int I; float F; } u; u.I = 12; u.I |
| 83 |
// CHECK-NEXT: (int) 12 |
| 84 |
|
| 85 |
struct S1{} s1; s1 |
| 86 |
// CHECK-NEXT: (S1 &) @0x{{[0-9a-f]+}} |
| 87 |
|
| 88 |
struct S2 {int d;} E = {22}; E |
| 89 |
// CHECK-NEXT: (S2 &) @0x{{[0-9a-f]+}} |
| 90 |
|
| 91 |
E.d |
| 92 |
// CHECK-NEXT: (int) 22 |
| 93 |
|
| 94 |
// TODO: _Bool, _Complex, _Atomic, and _BitInt |
| 95 |
|
| 96 |
// ----------------------------------------------------------------------------- |
| 97 |
// Tentative definition handling (C99 6.9.2) |
| 98 |
// Verify that multiple distinct tentative definitions across inputs no longer |
| 99 |
// conflict. Each variable should emit correctly in its own incremental module. |
| 100 |
// ----------------------------------------------------------------------------- |
| 101 |
|
| 102 |
int t1; |
| 103 |
int t2; |
| 104 |
int t3; |
| 105 |
t1 = 1; t2 = 2; t3 = 3; |
| 106 |
t1 + t2 + t3 |
| 107 |
// CHECK-NEXT: (int) 6 |
| 108 |
|
| 109 |
// A redefinition of an existing tentative variable should still fail. |
| 110 |
int t1; |
| 111 |
// expected-error {{duplicate definition of symbol '_t1'}} |
| 112 |
|
| 113 |
%quit |