Debian Codegraph @

gcc/testsuite/g++.dg/gomp/declare-variant-5.C

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