| 1 |
// RUN: clang-repl "int i = 10;" 'extern "C" int printf(const char*,...);' \ |
| 2 |
// RUN: 'auto r1 = printf("i = %d\n", i);' | FileCheck --check-prefix=CHECK-DRIVER %s |
| 3 |
// The test is flaky with asan https://github.com/llvm/llvm-project/pull/148701. |
| 4 |
// UNSUPPORTED: asan |
| 5 |
// CHECK-DRIVER: i = 10 |
| 6 |
// RUN: cat %s | clang-repl -Xcc -std=c++11 -Xcc -fno-delayed-template-parsing | FileCheck %s |
| 7 |
extern "C" int printf(const char*,...); |
| 8 |
|
| 9 |
"ab" |
| 10 |
// CHECK: (const char[3]) "ab" |
| 11 |
|
| 12 |
123456 |
| 13 |
// CHECK-NEXT: (int) 123456 |
| 14 |
|
| 15 |
char ch[2] = {'1','a'}; ch |
| 16 |
// CHECK-NEXT: (char[2]) { '1', 'a' } |
| 17 |
|
| 18 |
char chnull[3] = {'1','a', '\0'}; chnull |
| 19 |
// CHECK-NEXT: (char[3]) "1a" |
| 20 |
|
| 21 |
char ch_arr[2][3][1] = {{{'a'}, {'b'}, {'c'}}, {{'d'}, {'e'}, {'f'}}}; ch_arr |
| 22 |
// CHECK: (char[2][3][1]) { { { 'a' }, { 'b' }, { 'c' } }, { { 'd' }, { 'e' }, { 'f' } } } |
| 23 |
struct S3 { int* p; S3() { p = new int(42); } ~S3() { delete p; } }; |
| 24 |
S3{} |
| 25 |
// CHECK-NEXT: (S3) @0x{{[0-9a-f]+}} |
| 26 |
S3 s3; |
| 27 |
s3 |
| 28 |
// CHECK-NEXT: (S3 &) @0x{{[0-9a-f]+}} |
| 29 |
|
| 30 |
struct S4 { ~S4() { printf("~S4()\n"); }}; |
| 31 |
S4{} |
| 32 |
// CHECK-NEXT: (S4) @0x{{[0-9a-f]+}} |
| 33 |
// TODO-CHECK-NEXT: ~S4() |
| 34 |
|
| 35 |
enum Enum{ e1 = -12, e2, e3=33, e4, e5 = 33}; |
| 36 |
e2 |
| 37 |
// CHECK-NEXT: (Enum) (e2) : int -11 |
| 38 |
::e1 |
| 39 |
// CHECK-NEXT: (Enum) (e1) : int -12 |
| 40 |
|
| 41 |
enum class Color { R = 0, G, B }; |
| 42 |
Color::R |
| 43 |
// CHECK-NEXT: (Color) (Color::R) : int 0 |
| 44 |
|
| 45 |
|
| 46 |
// Lambdas. |
| 47 |
|
| 48 |
auto Lambda1 = []{}; |
| 49 |
Lambda1 |
| 50 |
// CHECK-NEXT: ((lambda) &) @0x{{[0-9a-f]+}} |
| 51 |
[]{} |
| 52 |
// CHECK-NEXT: ((lambda at input_line_{{[0-9]+}}:1:1)) @0x{{[0-9a-f]+}} |
| 53 |
|
| 54 |
template<int n> struct F{ enum {RET=F<n-1>::RET*n} ; }; |
| 55 |
template<> struct F<0> { enum {RET = 1}; }; |
| 56 |
F<7>::RET |
| 57 |
// CHECK-NEXT: (F<7>::(unnamed enum at input_line_{{[0-9]+}}:1:27)) (F<7>::RET) : unsigned int 5040 |
| 58 |
|
| 59 |
struct S5 { int foo() { return 42; }}; |
| 60 |
&S5::foo |
| 61 |
// CHECK-NEXT: (int (S5::*)()) Function @0x{{[0-9a-f]+}} |
| 62 |
|
| 63 |
// Namespaced types deduced via auto |
| 64 |
namespace Outer { struct Foo {}; } |
| 65 |
auto x = Outer::Foo(); x |
| 66 |
// CHECK-NEXT: (Outer::Foo &) @0x{{[0-9a-f]+}} |
| 67 |
|
| 68 |
namespace Outer { template<class T> struct Bar {}; } |
| 69 |
auto y = Outer::Bar<int>(); y |
| 70 |
// CHECK-NEXT: (Outer::Bar<int> &) @0x{{[0-9a-f]+}} |
| 71 |
|
| 72 |
// Check that const is preserved |
| 73 |
const auto z = Outer::Foo(); z |
| 74 |
// CHECK-NEXT: (const Outer::Foo &) @0x{{[0-9a-f]+}} |
| 75 |
|
| 76 |
// Check printing of DecltypeTypes (this used to assert) |
| 77 |
namespace N { struct D {}; } |
| 78 |
decltype(N::D()) decl1; decl1 |
| 79 |
// CHECK-NEXT: (N::D &) @0x{{[0-9a-f]+}} |
| 80 |
|
| 81 |
// double-nested DecltypeType |
| 82 |
decltype(decl1) decl2; decl2 |
| 83 |
// CHECK-NEXT: (N::D &) @0x{{[0-9a-f]+}} |
| 84 |
|
| 85 |
const decltype(N::D()) decl3; decl3 |
| 86 |
// CHECK-NEXT: (const N::D &) @0x{{[0-9a-f]+}} |
| 87 |
|
| 88 |
// Check printing of UnaryTransformType (this used to assert) |
| 89 |
__remove_extent(N::D)* decl4; decl4 |
| 90 |
// CHECK-NEXT: (N::D *) |
| 91 |
|
| 92 |
// int i = 12; |
| 93 |
// int &iref = i; |
| 94 |
// iref |
| 95 |
// // TODO-CHECK-NEXT: (int &) 12 |
| 96 |
|
| 97 |
// int &&rref = 100; |
| 98 |
// rref |
| 99 |
|
| 100 |
// // TODO-CHECK-NEXT: (int &&) 100 |
| 101 |
|
| 102 |
%quit |
| 103 |
|