blob: 433ba13f73d6091659540065825e28e3240c5641 [file] [log] [blame]
Alexey Bataev1ab34572018-05-02 16:52:07 +00001// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc -fexceptions -fcxx-exceptions
2// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - -fexceptions -fcxx-exceptions -ferror-limit 100
3
4#ifndef HEADER
5#define HEADER
6
7template <typename T>
8class TemplateClass {
9 T a;
10public:
11 TemplateClass() { throw 1;}
12 T f_method() const { return a; }
13};
14
15int foo();
16
17int baz1();
18
19int baz2();
20
21int baz4() { return 5; }
22
23template <typename T>
24T FA() {
25 TemplateClass<T> s;
26 return s.f_method();
27}
28
29#pragma omp declare target
30struct S {
31 int a;
32 S(int a) : a(a) { throw 1; } // expected-error {{cannot use 'throw' with exceptions disabled}}
33};
34
35int foo() { return 0; }
36int b = 15;
37int d;
38#pragma omp end declare target
39int c;
40
41int bar() { return 1 + foo() + bar() + baz1() + baz2(); }
42
43int maini1() {
44 int a;
45 static long aa = 32;
46 try {
47#pragma omp target map(tofrom \
48 : a, b)
49 {
50 S s(a);
51 static long aaa = 23;
52 a = foo() + bar() + b + c + d + aa + aaa + FA<int>();
53 if (!a)
54 throw "Error"; // expected-error {{cannot use 'throw' with exceptions disabled}}
55 }
56 } catch(...) {
57 }
58 return baz4();
59}
60
61int baz3() { return 2 + baz2(); }
62int baz2() {
63#pragma omp target
64 try { // expected-error {{cannot use 'try' with exceptions disabled}}
65 ++c;
66 } catch (...) {
67 }
68 return 2 + baz3();
69}
70
Alexey Bataevc416e642019-02-08 18:02:25 +000071int baz1() { throw 1; } // expected-error {{cannot use 'throw' with exceptions disabled}}
72
73int foobar1();
74int foobar2();
75
76int (*A)() = &foobar1;
77#pragma omp declare target
78int (*B)() = &foobar2;
79#pragma omp end declare target
80
81int foobar1() { throw 1; }
82int foobar2() { throw 1; } // expected-error {{cannot use 'throw' with exceptions disabled}}
83
Alexey Bataev1ab34572018-05-02 16:52:07 +000084#endif // HEADER