1 // RUN: %clang_cc1 -verify -fopenmp -std=c++11 -o - %s 2 // RUN: not %clang_cc1 -fopenmp -std=c++11 -fopenmp-targets=aaa-bbb-ccc-ddd -o - %s 2>&1 | FileCheck %s 3 4 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 -o - %s 5 // CHECK: error: OpenMP target is invalid: 'aaa-bbb-ccc-ddd' 6 // RUN: not %clang_cc1 -fopenmp -std=c++11 -triple nvptx64-nvidia-cuda -o - %s 2>&1 | FileCheck --check-prefix CHECK-UNSUPPORTED-HOST-TARGET %s 7 // RUN: not %clang_cc1 -fopenmp -std=c++11 -triple nvptx-nvidia-cuda -o - %s 2>&1 | FileCheck --check-prefix CHECK-UNSUPPORTED-HOST-TARGET %s 8 // CHECK-UNSUPPORTED-HOST-TARGET: error: The target '{{nvptx64-nvidia-cuda|nvptx-nvidia-cuda}}' is not a supported OpenMP host target. 9 // RUN: not %clang_cc1 -fopenmp -std=c++11 -fopenmp-targets=hexagon-linux-gnu -o - %s 2>&1 | FileCheck --check-prefix CHECK-UNSUPPORTED-DEVICE-TARGET %s 10 // CHECK-UNSUPPORTED-DEVICE-TARGET: OpenMP target is invalid: 'hexagon-linux-gnu' 11 12 // RUN: not %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path 1111.bc -o - 2>&1 | FileCheck --check-prefix NO-HOST-BC %s 13 // NO-HOST-BC: The provided host compiler IR file '1111.bc' is required to generate code for OpenMP target regions but cannot be found. 14 15 // RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc -DREGION_HOST 16 // RUN: not %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - -DREGION_DEVICE 2>&1 17 18 #if defined(REGION_HOST) || defined(REGION_DEVICE) 19 void foo() { 20 #ifdef REGION_HOST 21 #pragma omp target // expected-error {{Offloading entry for target region in _Z3foov is incorrect: either the address or the ID is invalid.}} 22 ; 23 #endif 24 #ifdef REGION_DEVICE 25 #pragma omp target 26 ; 27 #endif 28 } 29 #pragma omp declare target to(foo) 30 void bar() { 31 #ifdef REGION_HOST 32 #pragma omp target 33 ; 34 #endif 35 #ifdef REGION_DEVICE 36 #pragma omp target 37 ; 38 #endif 39 } 40 #else 41 void foo() { 42 } 43 44 class S { 45 public: 46 void zee() { 47 #pragma omp target map(this[:2]) // expected-note {{expected length on mapping of 'this' array section expression to be '1'}} // expected-error {{invalid 'this' expression on 'map' clause}} 48 int a; 49 #pragma omp target map(this[1:1]) // expected-note {{expected lower bound on mapping of 'this' array section expression to be '0' or not specified}} // expected-error {{invalid 'this' expression on 'map' clause}} 50 int b; 51 #pragma omp target map(this[1]) // expected-note {{expected 'this' subscript expression on map clause to be 'this[0]'}} // expected-error {{invalid 'this' expression on 'map' clause}} 52 int c; 53 } 54 }; 55 56 #pragma omp target // expected-error {{unexpected OpenMP directive '#pragma omp target'}} 57 58 int main(int argc, char **argv) { 59 #pragma omp target { // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}} 60 foo(); 61 #pragma omp target ( // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}} 62 foo(); 63 #pragma omp target [ // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}} 64 foo(); 65 #pragma omp target ] // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}} 66 foo(); 67 #pragma omp target ) // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}} 68 foo(); 69 #pragma omp target } // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}} 70 foo(); 71 #pragma omp target 72 foo(); 73 // expected-warning@+1 {{extra tokens at the end of '#pragma omp target' are ignored}} 74 #pragma omp target unknown() 75 foo(); 76 L1: 77 foo(); 78 #pragma omp target 79 ; 80 #pragma omp target 81 { 82 goto L1; // expected-error {{use of undeclared label 'L1'}} 83 argc++; 84 } 85 86 for (int i = 0; i < 10; ++i) { 87 switch(argc) { 88 case (0): 89 #pragma omp target 90 { 91 foo(); 92 break; // expected-error {{'break' statement not in loop or switch statement}} 93 continue; // expected-error {{'continue' statement not in loop statement}} 94 } 95 default: 96 break; 97 } 98 } 99 100 goto L2; // expected-error {{use of undeclared label 'L2'}} 101 #pragma omp target 102 L2: 103 foo(); 104 #pragma omp target 105 { 106 return 1; // expected-error {{cannot return from OpenMP region}} 107 } 108 109 [[]] // expected-error {{an attribute list cannot appear here}} 110 #pragma omp target 111 for (int n = 0; n < 100; ++n) {} 112 113 return 0; 114 } 115 116 template <class> struct a { static bool b; }; 117 template <class c, bool = a<c>::b> void e(c) { // expected-note {{candidate template ignored: substitution failure [with c = int]: non-type template argument is not a constant expression}} 118 #pragma omp target 119 { 120 int d ; e(d); // expected-error {{no matching function for call to 'e'}} 121 } 122 } 123 #endif 124