xref: /llvm-project/clang/test/OpenMP/error_ast_print.cpp (revision 978e0839ae2feb5ddda3e4e0b5a7ddba1727d2d8)
1 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=51 -ast-print %s | FileCheck %s
2 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -fopenmp-version=51 -emit-pch -o %t %s
3 // RUN: %clang_cc1 -fopenmp -std=c++11 -fopenmp-version=51 -include-pch %t -verify %s -ast-print | FileCheck %s
4 
5 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=60 -ast-print %s | FileCheck %s
6 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -fopenmp-version=60 -emit-pch -o %t %s
7 // RUN: %clang_cc1 -fopenmp -std=c++11 -fopenmp-version=60 -include-pch %t -verify %s -ast-print | FileCheck %s
8 
9 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=51 -ast-print %s | FileCheck %s
10 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -fopenmp-version=51 -emit-pch -o %t %s
11 // RUN: %clang_cc1 -fopenmp-simd -std=c++11 -fopenmp-version=51 -include-pch %t -verify %s -ast-print | FileCheck %s
12 
13 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=60 -ast-print %s | FileCheck %s
14 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -fopenmp-version=60 -emit-pch -o %t %s
15 // RUN: %clang_cc1 -fopenmp-simd -std=c++11 -fopenmp-version=60 -include-pch %t -verify %s -ast-print | FileCheck %s
16 // expected-no-diagnostics
17 
18 #ifndef HEADER
19 #define HEADER
20 
21 void foo() {}
22 // CHECK: template <typename T, int N> int tmain(T argc, char **argv)
23 // CHECK: static int a;
24 // CHECK-NEXT: #pragma omp error at(execution) severity(fatal) message("GNU compiler required.")
25 // CHECK-NEXT: a = argv[0][0];
26 // CHECK-NEXT: ++a;
27 // CHECK-NEXT: #pragma omp error at(execution) severity(warning) message("Notice: add for loop.")
28 // CHECK-NEXT: {
29 // CHECK-NEXT: int b = 10;
30 // CHECK-NEXT: T c = 100;
31 // CHECK-NEXT: a = b + c;
32 // CHECK-NEXT: }
33 // CHECK-NEXT: #pragma omp error at(execution) severity(fatal) message("GPU compiler required.")
34 // CHECK-NEXT: foo();
35 // CHECK-NEXT: return N;
36 
37 template <typename T, int N>
38 int tmain(T argc, char **argv) {
39   T b = argc, c, d, e, f, g;
40   static int a;
41 #pragma omp error at(execution) severity(fatal) message("GNU compiler required.")
42   a = argv[0][0];
43   ++a;
44 #pragma omp error at(execution) severity(warning) message("Notice: add for loop.")
45   {
46     int b = 10;
47     T c = 100;
48     a = b + c;
49   }
50 #pragma omp  error at(execution) severity(fatal) message("GPU compiler required.")
51   foo();
52 return N;
53 }
54 
55 // CHECK: int main(int argc, char **argv)
56 // CHECK-NEXT: int b = argc, c, d, e, f, g;
57 // CHECK-NEXT: static int a;
58 // CHECK-NEXT: #pragma omp error at(execution) severity(fatal) message("GPU compiler required.")
59 // CHECK-NEXT: a = 2;
60 // CHECK-NEXT: #pragma omp error at(execution) severity(warning) message("Note this is functioncall.")
61 // CHECK-NEXT: foo();
62 int main (int argc, char **argv) {
63   int b = argc, c, d, e, f, g;
64   static int a;
65 #pragma omp error at(execution) severity(fatal) message("GPU compiler required.")
66    a=2;
67 #pragma omp error at(execution) severity(warning) message("Note this is functioncall.")
68   foo();
69 }
70 #endif
71