Debian Codegraph @

gcc/testsuite/g++.dg/ext/builtin-operator-new-2.C

raw
1 // { dg-do compile }
2
3 #include <new>
4
5 void *operator new (std::size_t, float, double); // { dg-message "selected function declared here" }
6 void operator delete (void *, float, double); // { dg-message "selected function declared here" }
7
8 void
9 foo (void *x)
10 {
11 void *a = __builtin_operator_new (32, 1.f, 32.); // { dg-error "call to '__builtin_operator_new' does not select replaceable global allocation function" }
12 __builtin_operator_delete (a, 1.f, 32.); // { dg-error "call to '__builtin_operator_delete' does not select replaceable global deallocation function" }
13 void *b = __builtin_operator_new (32, x); // { dg-error "call to '__builtin_operator_new' does not select replaceable global allocation function" }
14 void *c = __builtin_operator_new (32, 1LL, 1L, 1); // { dg-error "no matching function for call to 'operator new\\\(int, long long int, long int, int\\\)'" }
15 __builtin_operator_delete (c, 1LL, 1L, 1); // { dg-error "no matching function for call to 'operator delete\\\(void\\\*&, long long int, long int, int\\\)'" }
16 void *d = __builtin_operator_new (); // { dg-error "no matching function for call to 'operator new\\\(\\\)'" }
17 __builtin_operator_delete (); // { dg-error "no matching function for call to 'operator delete\\\(\\\)'" }
18 }
19
20 template <int N>
21 void
22 bar (void *x)
23 {
24 void *a = __builtin_operator_new (32, 1.f, 32.); // { dg-error "call to '__builtin_operator_new' does not select replaceable global allocation function" }
25 __builtin_operator_delete (a, 1.f, 32.); // { dg-error "call to '__builtin_operator_delete' does not select replaceable global deallocation function" }
26 void *b = __builtin_operator_new (32, x); // { dg-error "call to '__builtin_operator_new' does not select replaceable global allocation function" }
27 void *c = __builtin_operator_new (32, 1LL, 1L, 1); // { dg-error "no matching function for call to 'operator new\\\(int, long long int, long int, int\\\)'" }
28 __builtin_operator_delete (c, 1LL, 1L, 1); // { dg-error "no matching function for call to 'operator delete\\\(void\\\*&, long long int, long int, int\\\)'" }
29 void *d = __builtin_operator_new (); // { dg-error "no matching function for call to 'operator new\\\(\\\)'" }
30 __builtin_operator_delete (); // { dg-error "no matching function for call to 'operator delete\\\(\\\)'" }
31 }
32
33 template <typename T, typename U, typename V>
34 void
35 baz (void *x, T sz, V v)
36 {
37 U a = __builtin_operator_new (sz, 1.f, 32.); // { dg-error "call to '__builtin_operator_new' does not select replaceable global allocation function" }
38 __builtin_operator_delete (a, 1.f, 32.); // { dg-error "call to '__builtin_operator_delete' does not select replaceable global deallocation function" }
39 U b = __builtin_operator_new (sz, x); // { dg-error "call to '__builtin_operator_new' does not select replaceable global allocation function" }
40 U c = __builtin_operator_new (sz, v, 1L, 1); // { dg-error "no matching function for call to 'operator new\\\(int&, long long int&, long int, int\\\)'" }
41 __builtin_operator_delete (c, v, 1L, 1); // { dg-error "no matching function for call to 'operator delete\\\(void\\\*&, long long int&, long int, int\\\)'" }
42 }
43
44 void
45 qux (void *x, void *y)
46 {
47 bar <0> (x);
48 baz <int, void *, long long> (y, 32, 1LL);
49 }