1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
|
/* This testcase is part of GDB, the GNU debugger.
Copyright 2017-2023 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <cstddef>
/* Code for operator() tests. */
struct test_unique_op_call
{
void operator() (int);
};
void
test_unique_op_call::operator() (int)
{}
struct test_op_call
{
void operator() ();
void operator() (int);
void operator() (long);
template<typename T>
void operator() (T *);
};
void
test_op_call::operator() (int)
{}
void
test_op_call::operator() ()
{}
void
test_op_call::operator() (long)
{}
template<typename T>
void
test_op_call::operator() (T *t)
{
}
/* Code for operator[] tests. */
struct test_unique_op_array
{
void operator[] (int);
};
void
test_unique_op_array::operator[] (int)
{}
struct test_op_array
{
void operator[] (int);
void operator[] (long);
template<typename T>
void operator[] (T *);
};
void
test_op_array::operator[] (int)
{}
void
test_op_array::operator[] (long)
{}
template<typename T>
void
test_op_array::operator[] (T *t)
{}
/* Code for operator new tests. */
static int dummy;
struct test_op_new
{
void *operator new (size_t);
};
void *
test_op_new::operator new (size_t)
{
return &dummy;
}
/* Code for operator delete tests. */
struct test_op_delete
{
void operator delete (void *);
};
void
test_op_delete::operator delete (void *)
{
}
/* Code for operator new[] tests. */
struct test_op_new_array
{
void *operator new[] (size_t);
};
void *
test_op_new_array::operator new[] (size_t)
{
return &dummy;
}
/* Code for operator delete[] tests. */
struct test_op_delete_array
{
void operator delete[] (void *);
};
void
test_op_delete_array::operator delete[] (void *)
{
}
/* Code for user-defined conversion tests. */
struct test_op_conversion_res;
struct test_op_conversion
{
operator const volatile test_op_conversion_res **() const volatile;
};
test_op_conversion::operator const volatile test_op_conversion_res **()
const volatile
{
return NULL;
}
/* Code for the assignment operator tests. */
struct test_op_assign
{
test_op_assign operator= (const test_op_assign &);
};
test_op_assign
test_op_assign::operator= (const test_op_assign &)
{
return test_op_assign ();
}
/* Code for the arrow operator tests. */
struct test_op_arrow
{
test_op_arrow operator-> ();
};
test_op_arrow
test_op_arrow::operator-> ()
{
return test_op_arrow ();
}
/* Code for the logical/arithmetic operators tests. */
struct E
{
};
#define GEN_OP(NS, ...) \
namespace test_ops { \
void operator __VA_ARGS__ {} \
} \
namespace test_op_ ## NS { \
void operator __VA_ARGS__ {} \
}
GEN_OP (PLUS_A, += (E, E) )
GEN_OP (PLUS, + (E, E) )
GEN_OP (MINUS_A, -= (E, E) )
GEN_OP (MINUS, - (E, E) )
GEN_OP (MOD_A, %= (E, E) )
GEN_OP (MOD, % (E, E) )
GEN_OP (EQ, == (E, E) )
GEN_OP (NEQ, != (E, E) )
GEN_OP (LAND, && (E, E) )
GEN_OP (LOR, || (E, E) )
GEN_OP (SL_A, <<= (E, E) )
GEN_OP (SR_A, >>= (E, E) )
GEN_OP (SL, << (E, E) )
GEN_OP (SR, >> (E, E) )
GEN_OP (OE, |= (E, E) )
GEN_OP (BIT_O, | (E, E) )
GEN_OP (XOR_A, ^= (E, E) )
GEN_OP (XOR, ^ (E, E) )
GEN_OP (BIT_AND_A, &= (E, E) )
GEN_OP (BIT_AND, & (E, E) )
GEN_OP (LT, < (E, E) )
GEN_OP (LTE, <= (E, E) )
GEN_OP (GTE, >= (E, E) )
GEN_OP (GT, > (E, E) )
GEN_OP (MUL_A, *= (E, E) )
GEN_OP (MUL, * (E, E) )
GEN_OP (DIV_A, /= (E, E) )
GEN_OP (DIV, / (E, E) )
GEN_OP (NEG, ~ (E) )
GEN_OP (NOT, ! (E) )
GEN_OP (PRE_INC, ++ (E) )
GEN_OP (POST_INC, ++ (E, int) )
GEN_OP (PRE_DEC, -- (E) )
GEN_OP (POST_DEC, -- (E, int) )
GEN_OP (COMMA, , (E, E) )
int
main ()
{
test_op_call opcall;
opcall ();
opcall (1);
opcall (1l);
opcall ((int *) 0);
test_unique_op_call opcall2;
opcall2 (1);
test_op_array op_array;
op_array[1];
op_array[1l];
op_array[(int *) 0];
test_unique_op_array unique_op_array;
unique_op_array[1];
return 0;
}
|