| 1 |
// PR c++/31988 |
| 2 |
#include <new> |
| 3 |
|
| 4 |
class C |
| 5 |
{ |
| 6 |
public: |
| 7 |
void* operator new(std::size_t = 32) throw (std::bad_alloc); // { dg-error "9:the first parameter of .operator new. cannot have a default argument" } |
| 8 |
// { dg-error "dynamic exception specification" "" { target c++17 } .-1 } |
| 9 |
// { dg-warning "deprecated" "" { target { c++11 && { ! c++17 } } } .-2 } |
| 10 |
void* operator new[](std::size_t = 32) throw (std::bad_alloc); // { dg-error "9:the first parameter of .operator new. cannot have a default argument" } |
| 11 |
// { dg-error "dynamic exception specification" "" { target c++17 } .-1 } |
| 12 |
// { dg-warning "deprecated" "" { target { c++11 && { ! c++17 } } } .-2 } |
| 13 |
void* operator new(std::size_t = 32, const std::nothrow_t&) throw(); // { dg-error "9:the first parameter of .operator new. cannot have a default argument" } |
| 14 |
void* operator new[](std::size_t = 32, const std::nothrow_t&) throw(); // { dg-error "9:the first parameter of .operator new. cannot have a default argument" } |
| 15 |
}; |
| 16 |
|
| 17 |
class D |
| 18 |
{ |
| 19 |
public: |
| 20 |
void* operator new(std::size_t, |
| 21 |
const std::nothrow_t& = std::nothrow_t()) throw(); |
| 22 |
void* operator new[](std::size_t, |
| 23 |
const std::nothrow_t& = std::nothrow_t()) throw(); |
| 24 |
}; |
| 25 |
|
| 26 |
class E |
| 27 |
{ |
| 28 |
public: |
| 29 |
void* operator new(std::size_t = 0, // { dg-error "9:the first parameter of .operator new. cannot have a default argument" } |
| 30 |
const std::nothrow_t& = std::nothrow_t()) throw(); |
| 31 |
void* operator new[](std::size_t = 0, // { dg-error "9:the first parameter of .operator new. cannot have a default argument" } |
| 32 |
const std::nothrow_t& = std::nothrow_t()) throw(); |
| 33 |
}; |