1 // RUN: %clang_cc1 -verify=expected,omp4 -fopenmp -fopenmp-version=45 -std=c++11 -o - %s
2 // RUN: %clang_cc1 -verify=expected,omp5 -fopenmp -o - -std=c++11 %s -Wuninitialized
4 // RUN: not %clang_cc1 -fopenmp -std=c++11 -fopenmp-targets=aaa-bbb-ccc-ddd -o - %s 2>&1 | FileCheck %s
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 -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'
15 // RUN: not %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-target-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
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-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - -DREGION_DEVICE 2>&1
20 // RUN: not %clang_cc1 -verify=expected,omp5 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - -DREGION_DEVICE 2>&1
22 #if defined(REGION_HOST) || defined(REGION_DEVICE)
25 #pragma omp target // expected-error {{Offloading entry for target region in _Z3foov is incorrect: either the address or the ID is invalid.}}
33 #pragma omp declare target to(foo)
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}}
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}}
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}}
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}}
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}}
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}}
66 #pragma omp target // expected-error {{unexpected OpenMP directive '#pragma omp target'}}
68 int main(int argc
, char **argv
) {
69 #pragma omp target { // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}}
71 #pragma omp target ( // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}}
73 #pragma omp target [ // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}}
75 #pragma omp target ] // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}}
77 #pragma omp target ) // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}}
79 #pragma omp target } // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}}
83 // expected-warning@+1 {{extra tokens at the end of '#pragma omp target' are ignored}}
84 #pragma omp target unknown()
92 goto L1
; // expected-error {{use of undeclared label 'L1'}}
96 for (int i
= 0; i
< 10; ++i
) {
102 break; // expected-error {{'break' statement not in loop or switch statement}}
103 continue; // expected-error {{'continue' statement not in loop statement}}
110 goto L2
; // expected-error {{use of undeclared label 'L2'}}
116 return 1; // expected-error {{cannot return from OpenMP region}}
119 [[]] // expected-error {{an attribute list cannot appear here}}
121 for (int n
= 0; n
< 100; ++n
) {}
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}}
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}}
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}}
138 int d
; e(d
); // expected-error {{no matching function for call to 'e'}}