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