1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 #include <stddef.h>
3 
4 struct A {
5   void *operator new(size_t);
6 };
7 
8 namespace NS {
9   void *operator new(size_t);; // expected-error {{'operator new' cannot be declared inside a namespace}}
10 }
11 
12 static void *operator new(size_t); // expected-error {{static declaration of 'operator new' follows non-static declaration}} expected-note {{previous}}
13 static void *operator new(size_t, int, int); // expected-error {{'operator new' cannot be declared static in global scope}}
14 
15 struct B {
16   void operator new(size_t);  // expected-error {{'operator new' must return type 'void *'}}
17 };
18 
19 struct C {
20   void *operator new(); // expected-error {{'operator new' must have at least one parameter}}
21 };
22 
23 struct D {
24   void *operator new(bool); // expected-error {{'operator new' takes type size_t}}
25 };
26 
27 struct E {
28   void *operator new(size_t = 0); // expected-error {{parameter of 'operator new' cannot have a default argument}}
29 };
30 
31 struct F {
32   template<typename T> void *operator new(size_t, int);
33 };
34 
35 struct G {
36   template<typename T> T operator new(size_t, int); // expected-error {{'operator new' cannot have a dependent return type; use 'void *' instead}}
37 };
38 
39 struct H {
40   template<typename T> void *operator new(T, int); // expected-error {{'operator new' cannot take a dependent type as first parameter; use size_t}}
41 };
42 
43 struct I {
44   template<typename T> void *operator new(size_t); // expected-error {{'operator new' template must have at least two parameters}}
45 };
46