brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.8 KiB · f8857ff Raw
92 lines · cpp
1// RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s2// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s3// RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -verify %s -ast-print | FileCheck %s4 5// RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s | FileCheck %s6// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -emit-pch -o %t %s7// RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -verify %s -ast-print | FileCheck %s8// expected-no-diagnostics9 10// It is unclear if we want to annotate the template instantiations, e.g., S<int>::foo, or not in the two11// situations shown below. Since it is always fair to drop assumptions, we do that for now.12 13#ifndef HEADER14#define HEADER15 16template <typename T>17struct S {18  int a;19// CHECK: template <typename T> struct S {20// CHECK{LITERAL}:     void foo() [[omp::assume("ompx_global_assumption")]] {21  void foo() {22    #pragma omp parallel23    {}24  }25};26 27// CHECK: template<> struct S<int> {28// CHECK{LITERAL}:     void foo() [[omp::assume("ompx_global_assumption")]] {29 30#pragma omp begin assumes no_openmp31// CHECK{LITERAL}: [[omp::assume("omp_no_openmp")]] void S_with_assumes_no_call() [[omp::assume("ompx_global_assumption")]] {32void S_with_assumes_no_call() {33  S<int> s;34  s.a = 0;35}36// CHECK{LITERAL}: [[omp::assume("omp_no_openmp")]] void S_with_assumes_call() [[omp::assume("ompx_global_assumption")]] {37void S_with_assumes_call() {38  S<int> s;39  s.a = 0;40  // If this is executed we have UB!41  s.foo();42}43#pragma omp end assumes44 45// CHECK{LITERAL}: void S_without_assumes() [[omp::assume("ompx_global_assumption")]] {46void S_without_assumes() {47  S<int> s;48  s.foo();49}50 51#pragma omp assumes ext_global_assumption52 53// Same as the struct S above but the order in which we instantiate P is different, first outside of an assumes.54template <typename T>55struct P {56// CHECK: template <typename T> struct P {57// CHECK{LITERAL}:    [[omp::assume("ompx_global_assumption")]] void foo() {58  int a;59  void foo() {60    #pragma omp parallel61    {}62  }63};64 65// TODO: Avoid the duplication here:66 67// CHECK: template<> struct P<int> {68// CHECK{LITERAL}:     [[omp::assume("ompx_global_assumption")]] [[omp::assume("ompx_global_assumption")]] void foo() {69 70// CHECK{LITERAL}: [[omp::assume("ompx_global_assumption")]] void P_without_assumes() {71void P_without_assumes() {72  P<int> p;73  p.foo();74}75 76#pragma omp begin assumes no_openmp77// CHECK{LITERAL}: [[omp::assume("omp_no_openmp")]] [[omp::assume("ompx_global_assumption")]] void P_with_assumes_no_call() {78void P_with_assumes_no_call() {79  P<int> p;80  p.a = 0;81}82// CHECK{LITERAL}: [[omp::assume("omp_no_openmp")]] [[omp::assume("ompx_global_assumption")]] void P_with_assumes_call() {83void P_with_assumes_call() {84  P<int> p;85  p.a = 0;86  // If this is executed we have UB!87  p.foo();88}89#pragma omp end assumes90 91#endif92