| 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 | class S { |
| 47 | public: |
| 48 | void zee() { |
| 49 | #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}} |
| 50 | int a; |
| 51 | #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}} |
| 52 | int b; |
| 53 | #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}} |
| 54 | int c; |
| 55 | } |
| 56 | }; |
| 57 | |
| 58 | #pragma omp target // expected-error {{unexpected OpenMP directive '#pragma omp target'}} |
| 59 | |
| 60 | int main(int argc, char **argv) { |
| 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 } // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}} |
| 72 | foo(); |
| 73 | #pragma omp target |
| 74 | foo(); |
| 75 | // expected-warning@+1 {{extra tokens at the end of '#pragma omp target' are ignored}} |
| 76 | #pragma omp target unknown() |
| 77 | foo(); |
| 78 | L1: |
| 79 | foo(); |
| 80 | #pragma omp target |
| 81 | ; |
| 82 | #pragma omp target |
| 83 | { |
| 84 | goto L1; // expected-error {{use of undeclared label 'L1'}} |
| 85 | argc++; |
| 86 | } |
| 87 | |
| 88 | for (int i = 0; i < 10; ++i) { |
| 89 | switch(argc) { |
| 90 | case (0): |
| 91 | #pragma omp target |
| 92 | { |
| 93 | foo(); |
| 94 | break; // expected-error {{'break' statement not in loop or switch statement}} |
| 95 | continue; // expected-error {{'continue' statement not in loop statement}} |
| 96 | } |
| 97 | default: |
| 98 | break; |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | goto L2; // expected-error {{use of undeclared label 'L2'}} |
| 103 | #pragma omp target |
| 104 | L2: |
| 105 | foo(); |
| 106 | #pragma omp target |
| 107 | { |
| 108 | return 1; // expected-error {{cannot return from OpenMP region}} |
| 109 | } |
| 110 | |
| 111 | [[]] // expected-error {{an attribute list cannot appear here}} |
| 112 | #pragma omp target |
| 113 | for (int n = 0; n < 100; ++n) {} |
| 114 | |
| 115 | return 0; |
| 116 | } |
| 117 | #endif |
| 118 | |