1 // RUN: %clang_cc1 -verify -fopenmp -ast-dump %s | FileCheck %s -implicit-check-not=openmp_structured_block
2 // RUN: %clang_cc1 -verify -fopenmp-simd -ast-dump %s | FileCheck %s -implicit-check-not=openmp_structured_block
3 // expected-no-diagnostics
4
5 int ga, gb;
6 #pragma omp threadprivate(ga, gb)
7
8 // CHECK: |-OMPThreadPrivateDecl {{.+}} <col:1> col:1
9 // CHECK-NEXT: | |-DeclRefExpr {{.+}} <col:27> 'int' lvalue Var {{.+}} 'ga' 'int'
10 // CHECK-NEXT: | `-DeclRefExpr {{.+}} <col:31> 'int' lvalue Var {{.+}} 'gb' 'int'
11
12 #pragma omp declare reduction(+ : int, char : omp_out *= omp_in)
13
14 #pragma omp declare reduction(fun : float : omp_out += omp_in) initializer(omp_priv = omp_orig + 15)
15
16 // CHECK: |-OMPDeclareReductionDecl {{.+}} <line:[[@LINE-4]]:35> col:35 operator+ 'int' combiner 0x{{.+}}
17 // CHECK-NEXT: | |-CompoundAssignOperator {{.+}} <col:47, col:58> 'int' lvalue '*=' ComputeLHSTy='int' ComputeResultTy='int'
18 // CHECK-NEXT: | | |-DeclRefExpr {{.+}} <col:47> 'int' lvalue Var {{.+}} 'omp_out' 'int'
19 // CHECK-NEXT: | | `-ImplicitCastExpr {{.+}} <col:58> 'int' <LValueToRValue>
20 // CHECK-NEXT: | | `-DeclRefExpr {{.+}} <col:58> 'int' lvalue Var {{.+}} 'omp_in' 'int'
21 // CHECK-NEXT: | |-VarDecl {{.+}} <col:35> col:35 implicit used omp_in 'int'
22 // CHECK-NEXT: | `-VarDecl {{.+}} <col:35> col:35 implicit used omp_out 'int'
23 // CHECK-NEXT: |-OMPDeclareReductionDecl {{.+}} <col:40> col:40 operator+ 'char' combiner 0x{{.+}}
24 // CHECK-NEXT: | |-CompoundAssignOperator {{.+}} <col:47, col:58> 'char' lvalue '*=' ComputeLHSTy='int' ComputeResultTy='int'
25 // CHECK-NEXT: | | |-DeclRefExpr {{.+}} <col:47> 'char' lvalue Var {{.+}} 'omp_out' 'char'
26 // CHECK-NEXT: | | `-ImplicitCastExpr {{.+}} <col:58> 'int' <IntegralCast>
27 // CHECK-NEXT: | | `-ImplicitCastExpr {{.+}} <col:58> 'char' <LValueToRValue>
28 // CHECK-NEXT: | | `-DeclRefExpr {{.+}} <col:58> 'char' lvalue Var {{.+}} 'omp_in' 'char'
29 // CHECK-NEXT: | |-VarDecl {{.+}} <col:40> col:40 implicit used omp_in 'char'
30 // CHECK-NEXT: | `-VarDecl {{.+}} <col:40> col:40 implicit used omp_out 'char'
31 // CHECK-NEXT: |-OMPDeclareReductionDecl {{.+}} <line:[[@LINE-17]]:37> col:37 fun 'float' combiner 0x{{.+}} initializer 0x{{.+}}
32 // CHECK-NEXT: | |-CompoundAssignOperator {{.+}} <col:45, col:56> 'float' lvalue '+=' ComputeLHSTy='float' ComputeResultTy='float'
33 // CHECK-NEXT: | | |-DeclRefExpr {{.+}} <col:45> 'float' lvalue Var {{.+}} 'omp_out' 'float'
34 // CHECK-NEXT: | | `-ImplicitCastExpr {{.+}} <col:56> 'float' <LValueToRValue>
35 // CHECK-NEXT: | | `-DeclRefExpr {{.+}} <col:56> 'float' lvalue Var {{.+}} 'omp_in' 'float'
36 // CHECK-NEXT: | |-BinaryOperator {{.+}} <col:87, col:98> 'float' '+'
37 // CHECK-NEXT: | | |-ImplicitCastExpr {{.+}} <col:87> 'float' <LValueToRValue>
38 // CHECK-NEXT: | | | `-DeclRefExpr {{.+}} <col:87> 'float' lvalue Var {{.+}} 'omp_orig' 'float'
39 // CHECK-NEXT: | | `-ImplicitCastExpr {{.+}} <col:98> 'float' <IntegralToFloating>
40 // CHECK-NEXT: | | `-IntegerLiteral {{.+}} <col:98> 'int' 15
41
42 struct S {
43 int a, b;
SS44 S() {
45 #pragma omp parallel for default(none) private(a) shared(b) schedule(static, a)
46 for (int i = 0; i < 0; ++i)
47 ++a;
48 }
49 };
50
51 // CHECK: | `-OMPParallelForDirective {{.+}} {{<line:.+:1, col:80>|<col:1, col:80>}}
52 // CHECK-NEXT: | |-OMPDefaultClause {{.+}} <col:26, col:38>
53 // CHECK-NEXT: | |-OMPPrivateClause {{.+}} <col:40, col:49>
54 // CHECK-NEXT: | | `-DeclRefExpr {{.+}} <col:48> 'int' lvalue OMPCapturedExpr {{.+}} 'a' 'int &'
55 // CHECK-NEXT: | |-OMPSharedClause {{.+}} <col:51, col:59>
56 // CHECK-NEXT: | | `-MemberExpr {{.+}} <col:58> 'int' lvalue ->b
57 // CHECK-NEXT: | | `-CXXThisExpr {{.+}} <col:58> 'S *' implicit this
58 // CHECK-NEXT: | |-OMPScheduleClause {{.+}} <col:61, col:79>
59 // CHECK-NEXT: | | `-ImplicitCastExpr {{.+}} <col:78> 'int' <LValueToRValue>
60 // CHECK-NEXT: | | `-DeclRefExpr {{.+}} <col:78> 'int' lvalue OMPCapturedExpr {{.+}} '.capture_expr.' 'int'
61 // CHECK-NEXT: | `-CapturedStmt {{.+}} <line:[[@LINE-15]]:5, line:[[@LINE-14]]:9>
62 // CHECK-NEXT: | |-CapturedDecl {{.+}} <<invalid sloc>> <invalid sloc> nothrow
63 // CHECK-NEXT: | | |-ForStmt {{.+}} <line:[[@LINE-17]]:5, line:[[@LINE-16]]:9>
64 // CHECK: | | | `-UnaryOperator {{.+}} <line:[[@LINE-17]]:7, col:9> 'int' lvalue prefix '++'
65 // CHECK-NEXT: | | | `-DeclRefExpr {{.+}} <col:9> 'int' lvalue OMPCapturedExpr {{.+}} 'a' 'int &'
66
67 #pragma omp declare simd
68 #pragma omp declare simd inbranch
69 void foo();
70
71 // CHECK: |-FunctionDecl {{.+}} <line:[[@LINE-2]]:1, col:10> col:6 foo 'void ()'
72 // CHECK-NEXT: |-OMPDeclareSimdDeclAttr {{.+}} <line:[[@LINE-4]]:1, col:34> Implicit BS_Inbranch
73 // CHECK: `-OMPDeclareSimdDeclAttr {{.+}} <line:[[@LINE-6]]:1, col:25> Implicit BS_Undefined
74
75 #pragma omp declare target
bar()76 int bar() {
77 int f;
78 return f;
79 }
80 #pragma omp end declare target
81
82 // CHECK: `-FunctionDecl {{.+}} <line:[[@LINE-6]]:1, line:[[@LINE-3]]:1> line:[[@LINE-6]]:5 bar 'int ()'
83 // CHECK-NEXT: |-CompoundStmt {{.+}} <col:11, line:[[@LINE-4]]:1>
84 // CHECK-NEXT: | |-DeclStmt {{.+}} <line:[[@LINE-7]]:3, col:8>
85 // CHECK-NEXT: | | `-VarDecl {{.+}} <col:3, col:7> col:7 used f 'int'
86 // CHECK-NEXT: | `-ReturnStmt {{.+}} <line:[[@LINE-8]]:3, col:10>
87 // CHECK-NEXT: | `-ImplicitCastExpr {{.+}} <col:10> 'int' <LValueToRValue>
88 // CHECK-NEXT: | `-DeclRefExpr {{.+}} <col:10> 'int' lvalue Var {{.+}} 'f' 'int'
89 // CHECK-NEXT: `-OMPDeclareTargetDeclAttr {{.+}} <line:75:21> Implicit MT_To DT_Any 1
90