2012-10-13 06:45:14 +08:00
|
|
|
// RUN: %clang_cc1 -ast-print %s | FileCheck %s
|
|
|
|
|
|
|
|
// CHECK: r;
|
|
|
|
// CHECK-NEXT: (r->method());
|
|
|
|
struct MyClass
|
|
|
|
{
|
|
|
|
void method() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Reference
|
|
|
|
{
|
|
|
|
MyClass* object;
|
|
|
|
MyClass* operator ->() { return object; }
|
|
|
|
};
|
|
|
|
|
2012-10-19 05:53:46 +08:00
|
|
|
void test1() {
|
2012-10-13 06:45:14 +08:00
|
|
|
Reference r;
|
|
|
|
(r->method());
|
|
|
|
}
|
|
|
|
|
2012-10-17 07:45:15 +08:00
|
|
|
// CHECK: if (int a = 1)
|
|
|
|
// CHECK: while (int a = 1)
|
|
|
|
// CHECK: switch (int a = 1)
|
|
|
|
|
2012-10-19 05:53:46 +08:00
|
|
|
void test2()
|
2012-10-17 07:45:15 +08:00
|
|
|
{
|
|
|
|
if (int a = 1) { }
|
|
|
|
while (int a = 1) { }
|
|
|
|
switch (int a = 1) { }
|
|
|
|
}
|
|
|
|
|
2012-10-19 04:54:37 +08:00
|
|
|
// CHECK: new (1) int;
|
|
|
|
void *operator new (typeof(sizeof(1)), int, int = 2);
|
2012-10-19 05:53:46 +08:00
|
|
|
void test3() {
|
2012-10-19 04:54:37 +08:00
|
|
|
new (1) int;
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK: new X;
|
|
|
|
struct X {
|
|
|
|
void *operator new (typeof(sizeof(1)), int = 2);
|
|
|
|
};
|
2012-10-19 05:53:46 +08:00
|
|
|
void test4() { new X; }
|
2012-10-19 04:58:58 +08:00
|
|
|
|
|
|
|
// CHECK: for (int i = 2097, j = 42; false;)
|
2012-10-19 05:53:46 +08:00
|
|
|
void test5() {
|
2012-10-19 04:58:58 +08:00
|
|
|
for (int i = 2097, j = 42; false;) {}
|
|
|
|
}
|
2012-10-19 05:53:46 +08:00
|
|
|
|
|
|
|
// CHECK: test6fn((int &)y);
|
|
|
|
void test6fn(int& x);
|
|
|
|
void test6() {
|
|
|
|
unsigned int y = 0;
|
|
|
|
test6fn((int&)y);
|
|
|
|
}
|
2012-10-20 04:36:44 +08:00
|
|
|
|
|
|
|
// CHECK: S s( 1, 2 );
|
|
|
|
|
|
|
|
template <class S> void test7()
|
|
|
|
{
|
|
|
|
S s( 1,2 );
|
|
|
|
}
|
|
|
|
|
2012-10-24 04:26:57 +08:00
|
|
|
|
|
|
|
// CHECK: t.~T();
|
|
|
|
|
|
|
|
template <typename T> void test8(T t) { t.~T(); }
|
2012-10-25 04:21:25 +08:00
|
|
|
|
|
|
|
|
|
|
|
// CHECK: enum E {
|
|
|
|
// CHECK-NEXT: A,
|
|
|
|
// CHECK-NEXT: B,
|
|
|
|
// CHECK-NEXT: C
|
|
|
|
// CHECK-NEXT: };
|
|
|
|
// CHECK-NEXT: {{^[ ]+}}E a = A;
|
|
|
|
|
|
|
|
struct test9
|
|
|
|
{
|
|
|
|
void f()
|
|
|
|
{
|
|
|
|
enum E { A, B, C };
|
|
|
|
E a = A;
|
|
|
|
}
|
|
|
|
};
|