1 // RUN: %clang_cc1 -fcxx-exceptions -ast-dump -ast-dump-filter Test %s | FileCheck -strict-whitespace %s
2
3 namespace n {
function()4 void function() {}
5 int Variable;
6 }
7 using n::function;
8 using n::Variable;
TestFunction()9 void TestFunction() {
10 void (*f)() = &function;
11 // CHECK: DeclRefExpr{{.*}} (UsingShadow{{.*}}function
12 Variable = 4;
13 // CHECK: DeclRefExpr{{.*}} (UsingShadow{{.*}}Variable
14 }
15
16 // CHECK: FunctionDecl {{.*}} TestCatch1
TestCatch1()17 void TestCatch1() {
18 // CHECK: CXXTryStmt
19 // CHECK-NEXT: CompoundStmt
20 try {
21 }
22 // CHECK-NEXT: CXXCatchStmt
23 // CHECK-NEXT: VarDecl {{.*}} x
24 // CHECK-NEXT: CompoundStmt
25 catch (int x) {
26 }
27 }
28
29 // CHECK: FunctionDecl {{.*}} TestCatch2
TestCatch2()30 void TestCatch2() {
31 // CHECK: CXXTryStmt
32 // CHECK-NEXT: CompoundStmt
33 try {
34 }
35 // CHECK-NEXT: CXXCatchStmt
36 // CHECK-NEXT: NULL
37 // CHECK-NEXT: CompoundStmt
38 catch (...) {
39 }
40 }
41
TestAllocationExprs()42 void TestAllocationExprs() {
43 int *p;
44 p = new int;
45 delete p;
46 p = new int[2];
47 delete[] p;
48 p = ::new int;
49 ::delete p;
50 }
51 // CHECK: FunctionDecl {{.*}} TestAllocationExprs
52 // CHECK: CXXNewExpr {{.*}} 'int *' Function {{.*}} 'operator new'
53 // CHECK: CXXDeleteExpr {{.*}} 'void' Function {{.*}} 'operator delete'
54 // CHECK: CXXNewExpr {{.*}} 'int *' array Function {{.*}} 'operator new[]'
55 // CHECK: CXXDeleteExpr {{.*}} 'void' array Function {{.*}} 'operator delete[]'
56 // CHECK: CXXNewExpr {{.*}} 'int *' global Function {{.*}} 'operator new'
57 // CHECK: CXXDeleteExpr {{.*}} 'void' global Function {{.*}} 'operator delete'
58
59 // Don't crash on dependent exprs that haven't been resolved yet.
60 template <typename T>
TestDependentAllocationExpr()61 void TestDependentAllocationExpr() {
62 T *p = new T;
63 delete p;
64 }
65 // CHECK: FunctionTemplateDecl {{.*}} TestDependentAllocationExpr
66 // CHECK: CXXNewExpr {{.*'T \*'$}}
67 // CHECK: CXXDeleteExpr {{.*'void'$}}
68