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