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 -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 | FileCheck %s --check-prefix NO-REGION 17 // NO-REGION: Offloading entry for target region is incorrect: either the address or the ID is invalid. 18 // NO-REGION-NOT: Offloading entry for target region is incorrect: either the address or the ID is invalid. 19 20 #if defined(REGION_HOST) || defined(REGION_DEVICE) 21 void foo() { 22 #ifdef REGION_HOST 23 #pragma omp target 24 ; 25 #endif 26 #ifdef REGION_DEVICE 27 #pragma omp target 28 ; 29 #endif 30 } 31 #pragma omp declare target to(foo) 32 void bar() { 33 #ifdef REGION_HOST 34 #pragma omp target 35 ; 36 #endif 37 #ifdef REGION_DEVICE 38 #pragma omp target 39 ; 40 #endif 41 } 42 #else 43 void foo() { 44 } 45 46 #pragma omp target // expected-error {{unexpected OpenMP directive '#pragma omp target'}} 47 48 int main(int argc, char **argv) { 49 #pragma omp target { // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}} 50 foo(); 51 #pragma omp target ( // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}} 52 foo(); 53 #pragma omp target [ // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}} 54 foo(); 55 #pragma omp target ] // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}} 56 foo(); 57 #pragma omp target ) // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}} 58 foo(); 59 #pragma omp target } // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}} 60 foo(); 61 #pragma omp target 62 foo(); 63 // expected-warning@+1 {{extra tokens at the end of '#pragma omp target' are ignored}} 64 #pragma omp target unknown() 65 foo(); 66 L1: 67 foo(); 68 #pragma omp target 69 ; 70 #pragma omp target 71 { 72 goto L1; // expected-error {{use of undeclared label 'L1'}} 73 argc++; 74 } 75 76 for (int i = 0; i < 10; ++i) { 77 switch(argc) { 78 case (0): 79 #pragma omp target 80 { 81 foo(); 82 break; // expected-error {{'break' statement not in loop or switch statement}} 83 continue; // expected-error {{'continue' statement not in loop statement}} 84 } 85 default: 86 break; 87 } 88 } 89 90 goto L2; // expected-error {{use of undeclared label 'L2'}} 91 #pragma omp target 92 L2: 93 foo(); 94 #pragma omp target 95 { 96 return 1; // expected-error {{cannot return from OpenMP region}} 97 } 98 99 [[]] // expected-error {{an attribute list cannot appear here}} 100 #pragma omp target 101 for (int n = 0; n < 100; ++n) {} 102 103 return 0; 104 } 105 #endif 106