110 lines · c
1// REQUIRES: host-supports-jit2// RUN: cat %s | clang-repl -Xcc -xc | FileCheck %s3// RUN: cat %s | clang-repl -Xcc -std=c++11 | FileCheck %s4 5// UNSUPPORTED: hwasan, msan6 7 8char c = 'a'; c9// CHECK: (char) 'a'10 11const char* c_str = "Hello, world!"; c_str12// CHECK-NEXT: (const char *) "Hello, world!"13 14c_str = "Goodbye, world!"; c_str15// CHECK-NEXT: (const char *) "Goodbye, world!"16 17const char* c_null_str = 0; c_null_str18// CHECK-NEXT: (const char *) 019 20"Hello, world"21// CHECK-NEXT: ({{(const )?}}char[13]) "Hello, world"22 23int x = 42; x24// CHECK-NEXT: (int) 4225 26&x27// CHECK-NEXT: (int *) 0x{{[0-9a-f]+}}28 29x - 230// CHECK-NEXT: (int) 4031 32float f = 4.2f; f33// CHECK-NEXT: (float) 4.20000f34 35double d = 4.21; d36// CHECK-NEXT: (double) 4.210000037 38long double tau = 6.2831853; tau39// CHECK-NEXT: (long double) 6.28318530000L40 41int foo() { return 42; } foo()42// CHECK-NEXT: (int) 4243 44void bar(int a, float b) {} bar45// CHECK-NEXT: (void (int, float)) Function @0x{{[0-9a-f]+}}46// CHECK-NEXT: void bar(int a, float b) {47 48bar49// CHECK: (void (int, float)) Function @0x{{[0-9a-f]+}}50// CHECK-NEXT: void bar(int a, float b) {51 52// Arrays.53 54int arr[3] = {1,2,3}; arr55// CHECK: (int[3]) { 1, 2, 3 }56 57double darr[3][4] = { {1,2,3,4}, {5,6,7,8}, {9,10,11,12} }; darr58// 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 } }59 60float farr[2][1] = { {0}, {3.14}}; farr61// CHECK-NEXT: (float[2][1]) { { 0.0f }, { 3.14000f } }62 630./0.64// CHECK-NEXT: (double) nan65 661.0f / 0.0f67// CHECK-NEXT: (float) inf68 690.00001f70// CHECK-NEXT: (float) 1.00000e-05f71 72int * ptr = (int*)0x123; ptr73// CHECK-NEXT: (int *) 0x12374 75int * null_ptr = (int*)0; null_ptr76// CHECK-NEXT: (int *) 0x077 78union U { int I; float F; } u; u.I = 12; u.I79// CHECK-NEXT: (int) 1280 81struct S1{} s1; s182// CHECK-NEXT: (S1 &) @0x{{[0-9a-f]+}}83 84struct S2 {int d;} E = {22}; E85// CHECK-NEXT: (S2 &) @0x{{[0-9a-f]+}}86 87E.d88// CHECK-NEXT: (int) 2289 90// TODO: _Bool, _Complex, _Atomic, and _BitInt91 92// -----------------------------------------------------------------------------93// Tentative definition handling (C99 6.9.2)94// Verify that multiple distinct tentative definitions across inputs no longer95// conflict. Each variable should emit correctly in its own incremental module.96// -----------------------------------------------------------------------------97 98int t1;99int t2;100int t3;101t1 = 1; t2 = 2; t3 = 3;102t1 + t2 + t3103// CHECK-NEXT: (int) 6104 105// A redefinition of an existing tentative variable should still fail.106int t1;107// expected-error {{duplicate definition of symbol '_t1'}}108 109%quit110