• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple %itanium_abi_triple -emit-llvm %s -fexceptions -fcxx-exceptions -o - -fsanitize-address-use-after-scope -fopenmp-version=45 | FileCheck %s --implicit-check-not='ret i32 {{6|7|8|9|10|12|13|14|15|19|21|22|23|24}}'
2 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple %itanium_abi_triple -fexceptions -fcxx-exceptions -emit-pch -o %t %s
3 // RUN: %clang_cc1 -fopenmp -x c++ -triple %itanium_abi_triple -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --implicit-check-not='ret i32 {{6|7|8|9|10|12|13|14|15|19|21|22|23|24}}'
4 // expected-no-diagnostics
5 
6 // CHECK-DAG:  ret i32 2
7 // CHECK-DAG:  ret i32 3
8 // CHECK-DAG:  ret i32 4
9 // CHECK-DAG:  ret i32 5
10 // CHECK-DAG:  ret i32 11
11 // CHECK-DAG:  ret i32 16
12 // CHECK-DAG:  ret i32 17
13 // CHECK-DAG:  ret i32 18
14 // CHECK-DAG:  ret i32 19
15 // CHECK-DAG:  ret i32 20
16 // CHECK-DAG:  ret i32 25
17 // CHECK-DAG:  ret i32 26
18 // CHECK-DAG:  ret i32 27
19 // CHECK-DAG:  ret i32 28
20 // CHECK-DAG:  ret i32 29
21 
22 #ifndef HEADER
23 #define HEADER
24 
foo()25 int foo() { return 2; }
26 
27 #pragma omp declare variant(foo) match(implementation = {vendor(llvm)})
bar()28 int bar() { return 3; }
29 
30 int bazzz();
31 #pragma omp declare variant(bazzz) match(implementation = {vendor(llvm)})
baz()32 int baz() { return 4; }
33 
34 int test();
35 #pragma omp declare variant(test) match(implementation = {vendor(llvm)})
call()36 int call() { return 5; }
37 
38 static int stat_unused_();
39 #pragma omp declare variant(stat_unused_) match(implementation = {vendor(llvm)})
stat_unused()40 static int stat_unused() { return 6; }
41 
42 static int stat_used_();
43 #pragma omp declare variant(stat_used_) match(implementation = {vendor(llvm)})
stat_used()44 static int stat_used() { return 7; }
45 
main()46 int main() { return bar() + baz() + call() + stat_used(); }
47 
test()48 int test() { return 8; }
stat_unused_()49 static int stat_unused_() { return 9; }
stat_used_()50 static int stat_used_() { return 10; }
51 
52 struct SpecialFuncs {
vdSpecialFuncs53   void vd() {}
54   SpecialFuncs();
55   ~SpecialFuncs();
56 
method_SpecialFuncs57   int method_() { return 11; }
58 #pragma omp declare variant(SpecialFuncs::method_)                             \
59     match(implementation = {vendor(llvm)})
methodSpecialFuncs60   int method() { return 12; }
61 #pragma omp declare variant(SpecialFuncs::method_)                             \
62     match(implementation = {vendor(llvm)})
63   int Method();
64 } s;
65 
Method()66 int SpecialFuncs::Method() { return 13; }
67 
68 struct SpecSpecialFuncs {
vdSpecSpecialFuncs69   void vd() {}
70   SpecSpecialFuncs();
71   ~SpecSpecialFuncs();
72 
73   int method_();
74 #pragma omp declare variant(SpecSpecialFuncs::method_)                         \
75     match(implementation = {vendor(llvm)})
methodSpecSpecialFuncs76   int method() { return 14; }
77 #pragma omp declare variant(SpecSpecialFuncs::method_)                         \
78     match(implementation = {vendor(llvm)})
79   int Method();
80 } s1;
81 
method_()82 int SpecSpecialFuncs::method_() { return 15; }
Method()83 int SpecSpecialFuncs::Method() { return 16; }
84 
xxx()85 void xxx() {
86   (void)s.method();
87   (void)s1.method();
88 }
89 
prio()90 int prio() { return 17; }
prio1()91 int prio1() { return 18; }
92 
93 #pragma omp declare variant(prio) match(implementation = {vendor(llvm)})
94 #pragma omp declare variant(prio1) match(implementation = {vendor(score(1): llvm)})
prio_()95 int prio_() { return 19; }
96 
prio2()97 static int prio2() { return 20; }
prio3()98 static int prio3() { return 21; }
prio4()99 static int prio4() { return 22; }
100 
101 #pragma omp declare variant(prio4) match(implementation = {vendor(score(3): llvm)})
102 #pragma omp declare variant(prio2) match(implementation = {vendor(score(5): llvm)})
103 #pragma omp declare variant(prio3) match(implementation = {vendor(score(1): llvm)})
prio1_()104 static int prio1_() { return 23; }
105 
int_fn()106 int int_fn() { return prio1_(); }
107 
fn_linkage_variant()108 int fn_linkage_variant() { return 24; }
109 extern "C" {
110 #pragma omp declare variant(fn_linkage_variant) match(implementation = {vendor(llvm)})
fn_linkage()111 int fn_linkage() { return 25; }
112 }
113 
fn_linkage_variant1()114 extern "C" int fn_linkage_variant1() { return 26; }
115 #pragma omp declare variant(fn_linkage_variant1) match(implementation = {vendor(llvm)})
fn_linkage1()116 int fn_linkage1() { return 27; }
117 
fn_variant2()118 int fn_variant2() { return 28; }
119 #pragma omp declare variant(fn_variant2) match(implementation = {vendor(llvm, ibm)})
fn2()120 int fn2() { return 29; }
121 
122 #endif // HEADER
123