1 // 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 7 template <typename T> 8 class TemplateClass { 9 T a; 10 public: 11 TemplateClass() { throw 1;} 12 T f_method() const { return a; } 13 }; 14 15 int foo(); 16 17 int baz1(); 18 19 int baz2(); 20 21 int baz4() { return 5; } 22 23 template <typename T> 24 T FA() { 25 TemplateClass<T> s; 26 return s.f_method(); 27 } 28 29 #pragma omp declare target 30 struct S { 31 int a; 32 S(int a) : a(a) { throw 1; } // expected-error {{cannot use 'throw' with exceptions disabled}} 33 }; 34 35 int foo() { return 0; } 36 int b = 15; 37 int d; 38 #pragma omp end declare target 39 int c; 40 41 int bar() { return 1 + foo() + bar() + baz1() + baz2(); } 42 43 int 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 61 int baz3() { return 2 + baz2(); } 62 int 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 71 #endif // HEADER 72