| 1 |
// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wuninitialized |
| 2 |
// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++98 %s -Wuninitialized |
| 3 |
// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++11 %s -Wuninitialized |
| 4 |
|
| 5 |
// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wuninitialized |
| 6 |
// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -std=c++98 %s -Wuninitialized |
| 7 |
// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -std=c++11 %s -Wuninitialized |
| 8 |
|
| 9 |
int temp; // expected-note 7 {{'temp' declared here}} |
| 10 |
|
| 11 |
#pragma omp declare reduction // expected-error {{expected '(' after 'declare reduction'}} |
| 12 |
#pragma omp declare reduction { // expected-error {{expected '(' after 'declare reduction'}} |
| 13 |
#pragma omp declare reduction( // expected-error {{expected identifier or one of the following operators: '+', '-', '*', '&', '|', '^', '&&', or '||'}} |
| 14 |
#pragma omp declare reduction(# // expected-error {{expected identifier or one of the following operators: '+', '-', '*', '&', '|', '^', '&&', or '||'}} |
| 15 |
#pragma omp declare reduction(/ // expected-error {{expected identifier or one of the following operators: '+', '-', '*', '&', '|', '^', '&&', or '||'}} |
| 16 |
#pragma omp declare reduction(+ // expected-error {{expected ':'}} |
| 17 |
#pragma omp declare reduction(operator // expected-error {{expected identifier or one of the following operators: '+', '-', '*', '&', '|', '^', '&&', or '||'}} |
| 18 |
#pragma omp declare reduction(operator: // expected-error {{expected identifier or one of the following operators: '+', '-', '*', '&', '|', '^', '&&', or '||'}} expected-error {{expected a type}} |
| 19 |
#pragma omp declare reduction(oper: // expected-error {{expected a type}} |
| 20 |
#pragma omp declare reduction(oper; // expected-error {{expected ':'}} expected-error {{expected a type}} |
| 21 |
#pragma omp declare reduction(fun : int // expected-error {{expected ':'}} expected-error {{expected expression}} |
| 22 |
#pragma omp declare reduction(+ : const int: // expected-error {{reduction type cannot be qualified with 'const', 'volatile' or 'restrict'}} |
| 23 |
#pragma omp declare reduction(- : volatile int: // expected-error {{reduction type cannot be qualified with 'const', 'volatile' or 'restrict'}} |
| 24 |
#pragma omp declare reduction(* : int; // expected-error {{expected ','}} expected-error {{expected a type}} |
| 25 |
#pragma omp declare reduction(& : double char: // expected-error {{cannot combine with previous 'double' declaration specifier}} expected-error {{expected expression}} |
| 26 |
#pragma omp declare reduction(^ : double, char, : // expected-error {{expected a type}} expected-error {{expected expression}} |
| 27 |
#pragma omp declare reduction(&& : int, S: // expected-error {{unknown type name 'S'}} expected-error {{expected expression}} |
| 28 |
#pragma omp declare reduction(|| : int, double : temp += omp_in) // expected-error 2 {{only 'omp_in' or 'omp_out' variables are allowed in combiner expression}} |
| 29 |
#pragma omp declare reduction(| : char, float : omp_out += ::temp) // expected-error 2 {{only 'omp_in' or 'omp_out' variables are allowed in combiner expression}} |
| 30 |
#pragma omp declare reduction(fun : long : omp_out += omp_in) { // expected-warning {{extra tokens at the end of '#pragma omp declare reduction' are ignored}} expected-error {{expected 'initializer'}} |
| 31 |
#pragma omp declare reduction(fun : unsigned : omp_out += ::temp)) // expected-warning {{extra tokens at the end of '#pragma omp declare reduction' are ignored}} expected-error {{expected 'initializer'}} expected-error {{only 'omp_in' or 'omp_out' variables are allowed in combiner expression}} |
| 32 |
#pragma omp declare reduction(fun : long & : omp_out += omp_in) // expected-error {{reduction type cannot be a reference type}} |
| 33 |
#pragma omp declare reduction(fun : long(void) : omp_out += omp_in) // expected-error {{reduction type cannot be a function type}} |
| 34 |
#pragma omp declare reduction(fun : long[3] : omp_out += omp_in) // expected-error {{reduction type cannot be an array type}} |
| 35 |
#pragma omp declare reduction(fun23 : long, int, long : omp_out += omp_in) // expected-error {{redefinition of user-defined reduction for type 'long'}} expected-note {{previous definition is here}} |
| 36 |
|
| 37 |
template <class T> |
| 38 |
class Class1 { |
| 39 |
T a; |
| 40 |
public: |
| 41 |
Class1() : a() {} |
| 42 |
#pragma omp declare reduction(fun : T : temp) // expected-error {{only 'omp_in' or 'omp_out' variables are allowed in combiner expression}} |
| 43 |
#pragma omp declare reduction(fun1 : T : omp_out++) // expected-note {{previous definition is here}} expected-error {{reduction type cannot be a reference type}} |
| 44 |
#pragma omp declare reduction(fun1 : T : omp_out += omp_in) // expected-error {{redefinition of user-defined reduction for type 'T'}} |
| 45 |
#pragma omp declare reduction(fun2 : T, T : omp_out++) // expected-error {{reduction type cannot be a reference type}} expected-error {{redefinition of user-defined reduction for type 'T'}} expected-note {{previous definition is here}} |
| 46 |
#pragma omp declare reduction(foo : T : omp_out += this->a) // expected-error {{invalid use of 'this' outside of a non-static member function}} |
| 47 |
}; |
| 48 |
|
| 49 |
Class1<char &> e; // expected-note {{in instantiation of template class 'Class1<char &>' requested here}} |
| 50 |
|
| 51 |
template <class T> |
| 52 |
class Class2 : public Class1<T> { |
| 53 |
#pragma omp declare reduction(fun : T : omp_out += omp_in) |
| 54 |
}; |
| 55 |
|
| 56 |
#pragma omp declare reduction(fun222 : long : omp_out += omp_in) // expected-note {{previous definition is here}} |
| 57 |
#pragma omp declare reduction(fun222 : long : omp_out += omp_in) // expected-error {{redefinition of user-defined reduction for type 'long'}} |
| 58 |
#pragma omp declare reduction(fun1 : long : omp_out += omp_in) initializer // expected-error {{expected '(' after 'initializer'}} |
| 59 |
#pragma omp declare reduction(fun2 : long : omp_out += omp_in) initializer { // expected-error {{expected '(' after 'initializer'}} expected-error {{expected expression}} expected-warning {{extra tokens at the end of '#pragma omp declare reduction' are ignored}} |
| 60 |
#pragma omp declare reduction(fun3 : long : omp_out += omp_in) initializer[ |
| 61 |
// expected-error@-1 {{expected '(' after 'initializer'}} |
| 62 |
// expected-error@-2 {{expected variable name or 'this' in lambda capture list}} |
| 63 |
// expected-error@-3 {{expected ')'}} |
| 64 |
// expected-note@-4 {{to match this '('}} |
| 65 |
#pragma omp declare reduction(fun4 : long : omp_out += omp_in) initializer() // expected-error {{expected expression}} |
| 66 |
#pragma omp declare reduction(fun5 : long : omp_out += omp_in) initializer(temp) // expected-error {{only 'omp_priv' or 'omp_orig' variables are allowed in initializer expression}} |
| 67 |
#pragma omp declare reduction(fun6 : long : omp_out += omp_in) initializer(omp_orig // expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 68 |
#pragma omp declare reduction(fun7 : long : omp_out += omp_in) initializer(omp_priv Class1 < int > ()) // expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 69 |
#pragma omp declare reduction(fun77 : long : omp_out += omp_in) initializer(omp_priv Class2 < int > ()) // expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 70 |
#pragma omp declare reduction(fun8 : long : omp_out += omp_in) initializer(omp_priv 23) // expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 71 |
#pragma omp declare reduction(fun88 : long : omp_out += omp_in) initializer(omp_priv 23)) // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-warning {{extra tokens at the end of '#pragma omp declare reduction' are ignored}} |
| 72 |
#pragma omp declare reduction(fun9 : long : omp_out += omp_priv) initializer(omp_in = 23) // expected-error {{use of undeclared identifier 'omp_priv'}} |
| 73 |
#pragma omp declare reduction(fun10 : long : omp_out += omp_in) initializer(omp_priv = 23) |
| 74 |
|
| 75 |
template <typename T> |
| 76 |
T fun(T arg) { |
| 77 |
#pragma omp declare reduction(red : T : omp_out++) |
| 78 |
{ |
| 79 |
#pragma omp declare reduction(red : T : omp_out++) // expected-note {{previous definition is here}} |
| 80 |
#pragma omp declare reduction(red : T : omp_out++) // expected-error {{redefinition of user-defined reduction for type 'T'}} |
| 81 |
#pragma omp declare reduction(fun : T : omp_out += omp_in) initializer(omp_priv = 23) |
| 82 |
} |
| 83 |
return arg; |
| 84 |
} |
| 85 |
|
| 86 |
template <typename T> |
| 87 |
T foo(T arg) { |
| 88 |
T i; |
| 89 |
{ |
| 90 |
#pragma omp declare reduction(red : T : omp_out++) |
| 91 |
#pragma omp declare reduction(red1 : T : omp_out++) // expected-note {{previous definition is here}} |
| 92 |
#pragma omp declare reduction(red1 : int : omp_out++) // expected-error {{redefinition of user-defined reduction for type 'int'}} |
| 93 |
#pragma omp parallel reduction (red : i) |
| 94 |
{ |
| 95 |
} |
| 96 |
#pragma omp parallel reduction (red1 : i) |
| 97 |
{ |
| 98 |
} |
| 99 |
#pragma omp parallel reduction (red2 : i) // expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max' or declare reduction for type 'int'}} |
| 100 |
{ |
| 101 |
} |
| 102 |
} |
| 103 |
{ |
| 104 |
#pragma omp declare reduction(red1 : int : omp_out++) // expected-note {{previous definition is here}} |
| 105 |
#pragma omp declare reduction(red : T : omp_out++) |
| 106 |
#pragma omp declare reduction(red1 : T : omp_out++) // expected-error {{redefinition of user-defined reduction for type 'int'}} |
| 107 |
#pragma omp parallel reduction (red : i) |
| 108 |
{ |
| 109 |
} |
| 110 |
#pragma omp parallel reduction (red1 : i) |
| 111 |
{ |
| 112 |
} |
| 113 |
#pragma omp parallel reduction (red2 : i) // expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max' or declare reduction for type 'int'}} |
| 114 |
{ |
| 115 |
} |
| 116 |
} |
| 117 |
return arg; |
| 118 |
} |
| 119 |
|
| 120 |
#pragma omp declare reduction(foo : int : ({int a = omp_in; a = a * 2; omp_out += a; })) |
| 121 |
int main() { |
| 122 |
Class1<int> c1; |
| 123 |
int i; |
| 124 |
#pragma omp parallel reduction (::fun : c1) |
| 125 |
{ |
| 126 |
} |
| 127 |
#pragma omp parallel reduction (::Class1<int>::fun : c1) |
| 128 |
{ |
| 129 |
} |
| 130 |
#pragma omp parallel reduction (::Class2<int>::fun : i) // expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max' or declare reduction for type 'int'}} |
| 131 |
{ |
| 132 |
} |
| 133 |
return fun(15) + foo(15); // expected-note {{in instantiation of function template specialization 'foo<int>' requested here}} |
| 134 |
} |
| 135 |
|
| 136 |
#if __cplusplus == 201103L |
| 137 |
struct A { |
| 138 |
A() {} |
| 139 |
A(const A &) = default; |
| 140 |
}; |
| 141 |
|
| 142 |
int A_TEST() { |
| 143 |
A test, test1; |
| 144 |
#pragma omp declare reduction(+ : A : omp_out) initializer(omp_priv = A()) allocate(test) // expected-warning {{extra tokens at the end of '#pragma omp declare reduction' are ignored}} |
| 145 |
#pragma omp parallel reduction(+ : test) reduction(::operator+: test1) // expected-error {{unable to resolve declare reduction construct for type 'A'}} |
| 146 |
{} |
| 147 |
return 0; |
| 148 |
} |
| 149 |
|
| 150 |
struct U |
| 151 |
{ |
| 152 |
void foo(U&, bool); |
| 153 |
U(); |
| 154 |
}; |
| 155 |
template <int N> |
| 156 |
struct S |
| 157 |
{ |
| 158 |
int s; |
| 159 |
// expected-note@+1 {{'foo' declared here}} |
| 160 |
void foo(S &x) {}; |
| 161 |
// expected-error@+1 {{too many arguments to function call, expected single argument 'x', have 2 arguments}} |
| 162 |
#pragma omp declare reduction (foo : U, S : omp_out.foo(omp_in, false)) |
| 163 |
#pragma omp declare reduction (xxx : U, S : bar(omp_in)) // expected-error {{non-const lvalue reference to type 'S<1>' cannot bind to a value of unrelated type 'U'}} |
| 164 |
static void bar(S &x); // expected-note {{passing argument to parameter 'x' here}} |
| 165 |
}; |
| 166 |
// expected-note@+1 {{in instantiation of template class 'S<1>' requested here}} |
| 167 |
#pragma omp declare reduction (bar : S<1> : omp_out.foo(omp_in)) |
| 168 |
|
| 169 |
#endif |