Debian Codegraph @

clang/test/OpenMP/target_exceptions_messages.cpp

raw
1 // RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown \
2 // RUN: -verify=host -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc \
3 // RUN: %s -o %t-ppc-host.bc -fexceptions -fcxx-exceptions
4 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown \
5 // RUN: -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s \
6 // RUN: -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - \
7 // RUN: -fexceptions -fcxx-exceptions -ferror-limit 100
8
9 // RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown \
10 // RUN: -verify=host -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm-bc \
11 // RUN: %s -o %t-ppc-host-amd.bc -fexceptions -fcxx-exceptions
12 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple amdgcn-amd-amdhsa \
13 // RUN: -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s \
14 // RUN: -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host-amd.bc -o - \
15 // RUN: -fexceptions -fcxx-exceptions -ferror-limit 100
16
17 // RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown \
18 // RUN: -verify=host -fopenmp-targets=spirv64-intel -emit-llvm-bc \
19 // RUN: %s -o %t-ppc-host-spirv.bc -fexceptions -fcxx-exceptions
20 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple spirv64-intel \
21 // RUN: -fopenmp-targets=spirv64-intel -emit-llvm %s \
22 // RUN: -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host-spirv.bc -o - \
23 // RUN: -fexceptions -fcxx-exceptions -ferror-limit 100
24
25 #ifndef HEADER
26 #define HEADER
27
28 template <typename T>
29 class TemplateClass {
30 T a;
31 public:
32 TemplateClass() { throw 1;}
33 T f_method() const { return a; }
34 };
35
36 int foo();
37
38 int baz1();
39
40 int baz2();
41
42 int baz4() { return 5; }
43
44 template <typename T>
45 T FA() {
46 TemplateClass<T> s;
47 return s.f_method();
48 }
49
50 #pragma omp declare target
51 struct S {
52 int a;
53 S(int a) : a(a) { throw 1; } // expected-warning-re {{target '{{.*}}' does not support exception handling; 'throw' is assumed to be never reached}}
54 };
55
56 int foo() { return 0; }
57 int b = 15;
58 int d;
59 #pragma omp end declare target
60 int c;
61
62 int bar() { return 1 + foo() + bar() + baz1() + baz2(); } // expected-note {{called by 'bar'}}
63
64 int maini1() {
65 int a;
66 static long aa = 32;
67 try {
68 #pragma omp target map(tofrom \
69 : a, b)
70 {
71 // expected-note@+1 {{called by 'maini1'}}
72 S s(a);
73 static long aaa = 23;
74 a = foo() + bar() + b + c + d + aa + aaa + FA<int>(); // expected-note{{called by 'maini1'}}
75 if (!a)
76 throw "Error"; // expected-warning-re {{target '{{.*}}' does not support exception handling; 'throw' is assumed to be never reached}}
77 }
78 } catch(...) {
79 }
80 return baz4();
81 }
82
83 int baz3() { return 2 + baz2(); }
84 int baz2() {
85 #pragma omp target
86 try { // expected-warning-re {{target '{{.*}}' does not support exception handling; 'catch' block is ignored}}
87 ++c;
88 } catch (...) {
89 }
90 return 2 + baz3();
91 }
92
93 int baz1() { throw 1; } // expected-warning-re {{target '{{.*}}' does not support exception handling; 'throw' is assumed to be never reached}}
94
95 int foobar1();
96 int foobar2();
97
98 int (*A)() = &foobar1;
99 #pragma omp declare target
100 int (*B)() = &foobar2;
101 #pragma omp end declare target
102
103 int foobar1() { throw 1; }
104 int foobar2() { throw 1; } // expected-warning-re {{target '{{.*}}' does not support exception handling; 'throw' is assumed to be never reached}}
105
106
107 int foobar3();
108 int (*C)() = &foobar3; // expected-warning {{declaration is not declared in any declare target region}}
109 // host-warning@-1 {{declaration is not declared in any declare target region}}
110 #pragma omp declare target
111 int (*D)() = C; // expected-note {{used here}}
112 // host-note@-1 {{used here}}
113 #pragma omp end declare target
114 int foobar3() { throw 1; } // expected-warning-re {{target '{{.*}}' does not support exception handling; 'throw' is assumed to be never reached}}
115
116 // Check no infinite recursion in deferred diagnostic emitter.
117 long E = (long)&E;
118
119 #endif // HEADER