| 1 |
// PR c++/79664 |
| 2 |
// { dg-do compile } |
| 3 |
// { dg-options "-std=c++14 -fopenmp -Winvalid-constexpr -pedantic-errors" } |
| 4 |
|
| 5 |
constexpr int |
| 6 |
f1 () |
| 7 |
{ |
| 8 |
int i = 0; |
| 9 |
#pragma omp parallel for // { dg-error "OpenMP directives may not appear in 'constexpr' functions" } |
| 10 |
for (i = 0; i < 10; ++i) |
| 11 |
; |
| 12 |
return 0; |
| 13 |
} |
| 14 |
|
| 15 |
constexpr int |
| 16 |
f2 () |
| 17 |
{ |
| 18 |
int i = 0; |
| 19 |
#pragma omp parallel // { dg-error "OpenMP directives may not appear in 'constexpr' functions" } |
| 20 |
i = 5; |
| 21 |
return 0; |
| 22 |
} |
| 23 |
|
| 24 |
constexpr int |
| 25 |
f3 () |
| 26 |
{ |
| 27 |
int i = 0; |
| 28 |
#pragma omp task // { dg-error "OpenMP directives may not appear in 'constexpr' functions" } |
| 29 |
i = 5; |
| 30 |
return 0; |
| 31 |
} |
| 32 |
|
| 33 |
constexpr int |
| 34 |
f4 () |
| 35 |
{ |
| 36 |
int i = 0; |
| 37 |
#pragma omp for // { dg-error "OpenMP directives may not appear in 'constexpr' functions" } |
| 38 |
for (i = 0; i < 10; ++i) |
| 39 |
; |
| 40 |
return 0; |
| 41 |
} |
| 42 |
|
| 43 |
constexpr int |
| 44 |
f5 () |
| 45 |
{ |
| 46 |
int i = 0; |
| 47 |
#pragma omp taskloop // { dg-error "OpenMP directives may not appear in 'constexpr' functions" } |
| 48 |
for (i = 0; i < 10; ++i) |
| 49 |
; |
| 50 |
return 0; |
| 51 |
} |
| 52 |
|
| 53 |
constexpr int |
| 54 |
f6 () |
| 55 |
{ |
| 56 |
int i = 0; |
| 57 |
#pragma omp target teams // { dg-error "OpenMP directives may not appear in 'constexpr' functions" } |
| 58 |
i = 5; |
| 59 |
return 0; |
| 60 |
} |
| 61 |
|
| 62 |
constexpr int |
| 63 |
f7 () |
| 64 |
{ |
| 65 |
int i = 0; |
| 66 |
#pragma omp target data map(tofrom:i) // { dg-error "OpenMP directives may not appear in 'constexpr' functions" } |
| 67 |
i = 5; |
| 68 |
return 0; |
| 69 |
} |
| 70 |
|
| 71 |
constexpr int |
| 72 |
f8 () |
| 73 |
{ |
| 74 |
int i = 0; |
| 75 |
#pragma omp target // { dg-error "OpenMP directives may not appear in 'constexpr' functions" } |
| 76 |
i = 5; |
| 77 |
return 0; |
| 78 |
} |
| 79 |
|
| 80 |
constexpr int |
| 81 |
f9 () |
| 82 |
{ |
| 83 |
int i = 0; |
| 84 |
#pragma omp sections // { dg-error "OpenMP directives may not appear in 'constexpr' functions" } |
| 85 |
{ |
| 86 |
#pragma omp section // { dg-error "OpenMP directives may not appear in 'constexpr' functions" } |
| 87 |
i = 5; |
| 88 |
} |
| 89 |
return 0; |
| 90 |
} |
| 91 |
|
| 92 |
constexpr int |
| 93 |
f10 () |
| 94 |
{ |
| 95 |
int i = 0; |
| 96 |
#pragma omp ordered // { dg-error "OpenMP directives may not appear in 'constexpr' functions" } |
| 97 |
i = 1; |
| 98 |
return 0; |
| 99 |
} |
| 100 |
|
| 101 |
constexpr int |
| 102 |
f11 () |
| 103 |
{ |
| 104 |
int i = 0; |
| 105 |
#pragma omp critical // { dg-error "OpenMP directives may not appear in 'constexpr' functions" } |
| 106 |
i = 1; |
| 107 |
return 0; |
| 108 |
} |
| 109 |
|
| 110 |
constexpr int |
| 111 |
f12 () |
| 112 |
{ |
| 113 |
int i = 0; |
| 114 |
#pragma omp single // { dg-error "OpenMP directives may not appear in 'constexpr' functions" } |
| 115 |
i = 1; |
| 116 |
return 0; |
| 117 |
} |
| 118 |
|
| 119 |
constexpr int |
| 120 |
f13 () |
| 121 |
{ |
| 122 |
int i = 0; |
| 123 |
#pragma omp master // { dg-error "OpenMP directives may not appear in 'constexpr' functions" } |
| 124 |
i = 1; |
| 125 |
return 0; |
| 126 |
} |
| 127 |
|
| 128 |
constexpr int |
| 129 |
f14 () |
| 130 |
{ |
| 131 |
int i = 0; |
| 132 |
#pragma omp taskgroup // { dg-error "OpenMP directives may not appear in 'constexpr' functions" } |
| 133 |
i = 1; |
| 134 |
return 0; |
| 135 |
} |
| 136 |
|
| 137 |
constexpr int |
| 138 |
f15 () |
| 139 |
{ |
| 140 |
int i = 0; |
| 141 |
#pragma omp target update to(i) // { dg-error "OpenMP directives may not appear in 'constexpr' functions" } |
| 142 |
i = 1; |
| 143 |
return 0; |
| 144 |
} |
| 145 |
|
| 146 |
constexpr int |
| 147 |
f16 () |
| 148 |
{ |
| 149 |
int i = 0; |
| 150 |
#pragma omp target update to(i) // { dg-error "OpenMP directives may not appear in 'constexpr' functions" } |
| 151 |
return 0; |
| 152 |
} |
| 153 |
|
| 154 |
constexpr int |
| 155 |
f17 () |
| 156 |
{ |
| 157 |
int i = 0; |
| 158 |
#pragma omp target enter data map(to:i) // { dg-error "OpenMP directives may not appear in 'constexpr' functions" } |
| 159 |
return 0; |
| 160 |
} |
| 161 |
|
| 162 |
constexpr int |
| 163 |
f18 () |
| 164 |
{ |
| 165 |
int i = 0; |
| 166 |
#pragma omp target exit data map(from:i) // { dg-error "OpenMP directives may not appear in 'constexpr' functions" } |
| 167 |
return 0; |
| 168 |
} |