brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.5 KiB · 62ab581 Raw
142 lines · cpp
1// RUN: %clang_cc1 -verify=expected,omp4 -fopenmp -fopenmp-version=45 -std=c++11 -o - %s2// RUN: %clang_cc1 -verify=expected,omp5 -fopenmp -o - -std=c++11 %s -Wuninitialized3 4// RUN: not %clang_cc1 -fopenmp -std=c++11 -fopenmp-targets=aaa-bbb-ccc-ddd -o - %s 2>&1 | FileCheck %s5 6// RUN: %clang_cc1 -verify=expected,omp4 -fopenmp-simd -fopenmp-version=45 -std=c++11 -o - %s7// RUN: %clang_cc1 -verify=expected,omp5 -fopenmp-simd -std=c++11 -o - %s8// 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 %s10// RUN: not %clang_cc1 -fopenmp -std=c++11 -triple nvptx-nvidia-cuda -o - %s 2>&1 | FileCheck --check-prefix CHECK-UNSUPPORTED-HOST-TARGET %s11// CHECK-UNSUPPORTED-HOST-TARGET: error: target '{{nvptx64-nvidia-cuda|nvptx-nvidia-cuda}}' is not a supported OpenMP host target12// RUN: not %clang_cc1 -fopenmp -std=c++11 -fopenmp-targets=hexagon-linux-gnu -o - %s 2>&1 | FileCheck --check-prefix CHECK-UNSUPPORTED-DEVICE-TARGET %s13// 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-target-device -fopenmp-host-ir-file-path 1111.bc -o - 2>&1 | FileCheck --check-prefix NO-HOST-BC %s16// NO-HOST-BC: provided host compiler IR file '1111.bc' is required to generate code for OpenMP target regions but cannot be found17 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_HOST19// 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>&120// 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>&121 22#if defined(REGION_HOST) || defined(REGION_DEVICE)23void foo() {24#ifdef REGION_HOST25#pragma omp target // expected-error {{Offloading entry for target region in _Z3foov is incorrect: either the address or the ID is invalid.}}26  ;27#endif28#ifdef REGION_DEVICE29#pragma omp target30  ;31#endif32}33#pragma omp declare target to(foo)34void bar() {35#ifdef REGION_HOST36#pragma omp target37  ;38#endif39#ifdef REGION_DEVICE40#pragma omp target41  ;42#endif43}44#else45void foo() {46}47 48class 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 68int 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 target82  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 target89  ;90  #pragma omp target91  {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 target100      {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 target112  L2:113  foo();114  #pragma omp target115  {116    return 1; // expected-error {{cannot return from OpenMP region}}117  }118 119  [[]] // expected-error {{an attribute list cannot appear here}}120  #pragma omp target121  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 134template <class> struct a { static bool b; };135template <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 target137  {138    int d ; e(d); // expected-error {{no matching function for call to 'e'}}139  }140}141#endif142