Clang Project

clang_source_code/test/OpenMP/target_update_ast_print.cpp
1// RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s
2// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s
3// RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
4
5// RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s | FileCheck %s
6// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -emit-pch -o %t %s
7// RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
8// expected-no-diagnostics
9
10#ifndef HEADER
11#define HEADER
12
13void foo() {}
14
15template <class T, class U>
16T foo(T targ, U uarg) {
17  static T a;
18  U b;
19  int l;
20#pragma omp target update to(a) if(l>5) device(l) nowait depend(inout:l)
21
22#pragma omp target update from(b) if(l<5) device(l-1) nowait depend(inout:l)
23  return a + targ + (T)b;
24}
25// CHECK:      static T a;
26// CHECK-NEXT: U b;
27// CHECK-NEXT: int l;
28// CHECK-NEXT: #pragma omp target update to(a) if(l > 5) device(l) nowait depend(inout : l){{$}}
29// CHECK-NEXT: #pragma omp target update from(b) if(l < 5) device(l - 1) nowait depend(inout : l)
30// CHECK:      static int a;
31// CHECK-NEXT: float b;
32// CHECK-NEXT: int l;
33// CHECK-NEXT: #pragma omp target update to(a) if(l > 5) device(l) nowait depend(inout : l)
34// CHECK-NEXT: #pragma omp target update from(b) if(l < 5) device(l - 1) nowait depend(inout : l)
35// CHECK:      static char a;
36// CHECK-NEXT: float b;
37// CHECK-NEXT: int l;
38// CHECK-NEXT: #pragma omp target update to(a) if(l > 5) device(l) nowait depend(inout : l)
39// CHECK-NEXT: #pragma omp target update from(b) if(l < 5) device(l - 1) nowait depend(inout : l)
40
41int main(int argc, char **argv) {
42  static int a;
43  int n;
44  float f;
45
46// CHECK:      static int a;
47// CHECK-NEXT: int n;
48// CHECK-NEXT: float f;
49#pragma omp target update to(a) if(f>0.0) device(n) nowait depend(in:n)
50// CHECK-NEXT: #pragma omp target update to(a) if(f > 0.) device(n) nowait depend(in : n)
51#pragma omp target update from(f) if(f<0.0) device(n+1) nowait depend(in:n)
52// CHECK-NEXT: #pragma omp target update from(f) if(f < 0.) device(n + 1) nowait depend(in : n)
53  return foo(argc, f) + foo(argv[0][0], f) + a;
54}
55
56#endif
57