| 1 |
// Test parsing of #pragma omp declare variant |
| 2 |
// { dg-do compile } |
| 3 |
|
| 4 |
int fn0 (int); |
| 5 |
int fn20 (int); |
| 6 |
|
| 7 |
#pragma omp declare variant (fn0) match (user={condition(0)}) |
| 8 |
int a; // { dg-error "not immediately followed by function declaration or definition" } |
| 9 |
|
| 10 |
#pragma omp declare variant (fn0) match (user={condition(0)}) |
| 11 |
int fn1 (int a), fn2 (int a); // { dg-error "not immediately followed by a single function declaration or definition" } |
| 12 |
|
| 13 |
#pragma omp declare variant (fn0) match (user={condition(0)}) |
| 14 |
int b, fn3 (int a); // { dg-error "not immediately followed by function declaration or definition" } |
| 15 |
|
| 16 |
#pragma omp declare variant (fn0) match (user={condition(0)}) |
| 17 |
int fn4 (int a), c; // { dg-error "not immediately followed by function declaration or definition" } |
| 18 |
|
| 19 |
#pragma omp declare variant (fn0) match (user={condition(0)}) |
| 20 |
extern "C" // { dg-error "not immediately followed by function declaration or definition" } |
| 21 |
{ |
| 22 |
int fn5 (int a); |
| 23 |
} |
| 24 |
|
| 25 |
#pragma omp declare variant (fn0) match (user={condition(0)}) // { dg-error "not immediately followed by function declaration or definition" } |
| 26 |
namespace N1 |
| 27 |
{ |
| 28 |
int fn6 (int a); |
| 29 |
} |
| 30 |
|
| 31 |
#pragma omp declare variant (fn0) match (user={condition(0)}) |
| 32 |
struct A |
| 33 |
{ // { dg-error "not immediately followed by function declaration or definition" } |
| 34 |
int fn7 (int a); |
| 35 |
}; |
| 36 |
|
| 37 |
#pragma omp declare variant (fn0) match (user={condition(0)}) |
| 38 |
template <typename T> |
| 39 |
struct B |
| 40 |
{ // { dg-error "not immediately followed by function declaration or definition" } |
| 41 |
int fn8 (int a); |
| 42 |
}; |
| 43 |
|
| 44 |
struct C |
| 45 |
{ |
| 46 |
#pragma omp declare variant (fn0) match (user={condition(0)}) // { dg-error "not immediately followed by function declaration or definition" } |
| 47 |
public: // { dg-error "expected unqualified-id before" } |
| 48 |
int fn9 (int a); |
| 49 |
}; |
| 50 |
|
| 51 |
int t; |
| 52 |
|
| 53 |
#pragma omp declare variant (fn0) match (user={condition(0)}) |
| 54 |
#pragma omp declare variant (fn20) match (implementation={vendor(unknown)}) |
| 55 |
#pragma omp threadprivate(t) // { dg-error "not immediately followed by function declaration or definition" } |
| 56 |
int fn10 (int a); |
| 57 |
|
| 58 |
struct D |
| 59 |
{ |
| 60 |
int d; |
| 61 |
int fn11 (int a); |
| 62 |
#pragma omp declare variant (fn11) match (user={condition(sizeof (e) == sizeof (this->e))}) // { dg-error "has no member named" } |
| 63 |
template <int N> // { dg-error "was not declared" "" { target *-*-* } .-1 } |
| 64 |
int fn12 (int a); |
| 65 |
int e; |
| 66 |
}; |
| 67 |
|
| 68 |
#pragma omp declare variant (1 + 2) match (user={condition(0)}) // { dg-error "before numeric constant" } |
| 69 |
int fn13 (int); |
| 70 |
|
| 71 |
#pragma omp declare variant (t) match (user={condition(0)}) // { dg-error "'t' cannot be used as a function" } |
| 72 |
int fn14 (int); |
| 73 |
|
| 74 |
long fn15 (char, short); |
| 75 |
|
| 76 |
#pragma omp declare variant (fn15) match (implementation={vendor(unknown)}) // { dg-error "variant 'long int fn15\\\(char, short int\\\)' and base 'int fn16\\\(int, long long int\\\)' have incompatible types" } |
| 77 |
int fn16 (int, long long); |
| 78 |
|
| 79 |
#pragma omp declare variant (memcpy) match (implementation={vendor(llvm)}) // { dg-error "'memcpy' was not declared in this scope" } |
| 80 |
void *fn17 (void *, const void *, __SIZE_TYPE__); |
| 81 |
|
| 82 |
#pragma omp declare variant (__builtin_memmove) match (implementation={vendor(gnu)}) // { dg-error "variant '\[^'\n\r]*' is a built-in" } |
| 83 |
void *fn18 (void *, const void *, __SIZE_TYPE__); |
| 84 |
|
| 85 |
struct E { int e; }; |
| 86 |
|
| 87 |
void fn19 (E, int); |
| 88 |
|
| 89 |
#pragma omp declare variant (fn19)match(user={condition(0)}) // { dg-error {could not convert 'i' from 'int' to 'E'} } |
| 90 |
void fn20 (int i, E e); |
| 91 |
|
| 92 |
struct F { operator int () const { return 42; } int f; }; |
| 93 |
void fn21 (int, F); |
| 94 |
|
| 95 |
#pragma omp declare variant ( fn21 ) match (user = { condition ( 1 - 1 ) } ) // { dg-error "variant 'void fn21\\\(int, F\\\)' and base 'void fn22\\\(F, F\\\)' have incompatible types" } |
| 96 |
void fn22 (F, F); |
| 97 |
|
| 98 |
#pragma omp declare variant (fn19) match (user={condition(0)}) // { dg-error {could not convert 'f' from 'F' to 'E'} } |
| 99 |
void fn23 (F f, int i); |
| 100 |
|
| 101 |
void fn24 (int); |
| 102 |
struct U { int u; }; |
| 103 |
struct T |
| 104 |
{ |
| 105 |
void fn25 (int); |
| 106 |
int t; |
| 107 |
}; |
| 108 |
struct S : public U, T |
| 109 |
{ |
| 110 |
#pragma omp declare variant (fn25) match (user={condition(true)}) // { dg-error "variant 'void T::fn25\\\(int\\\)' and base 'void S::fn26\\\(int\\\)' have incompatible types" } |
| 111 |
void fn26 (int); |
| 112 |
#pragma omp declare variant (fn24) match (user={condition(true)}) // { dg-error "variant 'void fn24\\\(int\\\)' and base 'void S::fn27\\\(int\\\)' have incompatible types" } |
| 113 |
void fn27 (int); |
| 114 |
struct s; |
| 115 |
}; |
| 116 |
|
| 117 |
void fn30 (int) throw (); |
| 118 |
#pragma omp declare variant (fn30) match (user={condition(true)}) // { dg-error "variant 'void fn30\\\(int\\\)' and base 'void fn31\\\(int\\\)' have incompatible types" "" { target c++17 } } |
| 119 |
void fn31 (int); |
| 120 |
|
| 121 |
struct W |
| 122 |
{ |
| 123 |
int fn32 (int) const; |
| 124 |
#pragma omp declare variant (fn32) match (user={condition(true)}) // { dg-error "variant 'int W::fn32\\\(int\\\) const' and base 'int W::fn33\\\(int\\\)' have incompatible types" } |
| 125 |
int fn33 (int); |
| 126 |
int fn34 (int) volatile; |
| 127 |
#pragma omp declare variant (fn34) match (user={condition(true)}) // { dg-error "variant 'int W::fn34\\\(int\\\) volatile' and base 'int W::fn35\\\(int\\\) const volatile' have incompatible types" } |
| 128 |
int fn35 (int) const volatile; // { dg-error "passing 'const volatile W' as 'this' argument discards qualifiers" "" { target *-*-* } .-1 } |
| 129 |
int fn36 (int); |
| 130 |
#pragma omp declare variant (fn36) match (user={condition(true)}) // { dg-error "variant 'int W::fn36\\\(int\\\)' and base 'int W::fn37\\\(int\\\) volatile' have incompatible types" } |
| 131 |
int fn37 (int) volatile; // { dg-error "passing 'volatile W' as 'this' argument discards qualifiers" "" { target *-*-* } .-1 } |
| 132 |
int fn38 (int) throw (); |
| 133 |
#pragma omp declare variant (fn38) match (user={condition(true)}) // { dg-error "variant 'int W::fn38\\\(int\\\)' and base 'int W::fn39\\\(int\\\)' have incompatible types" "" { target c++17 } } |
| 134 |
|
| 135 |
int fn39 (int); |
| 136 |
int fn40 (int); |
| 137 |
#pragma omp declare variant (fn40) match (user={condition(true)}) // { dg-error "variant 'int W::fn40\\\(int\\\)' and base 'int W::fn41\\\(int\\\)' have incompatible types" "" { target c++17 } } |
| 138 |
int fn41 (int) throw (); |
| 139 |
}; |