Lines Matching full:new
1 // RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx98-23,precxx20 %s -triple=i686-pc-linux-gnu -Wno-new-returns-null -std=c++98
2 // RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx98-23,precxx20 %s -triple=i686-pc-linux-gnu -Wno-new-returns-null -std=c++11
3 // RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx98-23,precxx20 %s -triple=i686-pc-linux-gnu -Wno-new-returns-null -std=c++14
4 // RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx98-23,cxx17,precxx20 %s -triple=i686-pc-linux-gnu -Wno-new-returns-null -std=c++17
5 // RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx98-23,cxx17,cxx20 %s -triple=i686-pc-linux-gnu -Wno-new-returns-null -std=c++20
6 // RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx98-23,cxx17,cxx20 %s -triple=i686-pc-linux-gnu -Wno-new-returns-null -std=c++23
7 // RUN: %clang_cc1 -fsyntax-only -verify=expected,since-cxx26,cxx17,cxx20 %s -triple=i686-pc-linux-gnu -Wno-new-returns-null -std=c++2c
9 // RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx98-23,precxx20 %s -triple=i686-pc-linux-gnu -Wno-new-returns-null -std=c++98 -fexperimental-new-constant-interpreter -DNEW_INTERP
10 // RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx98-23,precxx20 %s -triple=i686-pc-linux-gnu -Wno-new-returns-null -std=c++11 -fexperimental-new-constant-interpreter -DNEW_INTERP
11 // RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx98-23,precxx20 %s -triple=i686-pc-linux-gnu -Wno-new-returns-null -std=c++14 -fexperimental-new-constant-interpreter -DNEW_INTERP
12 // RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx98-23,cxx17,precxx20 %s -triple=i686-pc-linux-gnu -Wno-new-returns-null -std=c++17 -fexperimental-new-constant-interpreter -DNEW_INTERP
13 // RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx98-23,cxx17,cxx20 %s -triple=i686-pc-linux-gnu -Wno-new-returns-null -std=c++20 -fexperimental-new-constant-interpreter -DNEW_INTERP
14 // RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx98-23,cxx17,cxx20 %s -triple=i686-pc-linux-gnu -Wno-new-returns-null -std=c++23 -fexperimental-new-constant-interpreter -DNEW_INTERP
15 // RUN: %clang_cc1 -fsyntax-only -verify=expected,since-cxx26,cxx17,cxx20 %s -triple=i686-pc-linux-gnu -Wno-new-returns-null -std=c++2c -fexperimental-new-constant-interpreter -DNEW_INTERP
34 // A special new, to verify that the global version isn't used.
35 void* operator new(size_t, S*); // expected-note {{candidate}}
49 inline void *operator new(size_t) { // no warning, due to __attribute__((used))
54 void* operator new(const size_t); // expected-note {{candidate}}
55 void* operator new(size_t, int*); // expected-note 2{{candidate}}
56 void* operator new(size_t, float*); // expected-note 2{{candidate}}
57 void* operator new(size_t, S); // expected-note {{candidate}}
63 int *pi = new int;
64 float *pf = new (pi) float();
65 pi = new int(1);
66 pi = new int('c');
67 const int *pci = new const int();
68 S *ps = new S(1, 2, 3.4);
69 ps = new (pf) (S)(1, 2, 3.4);
70 S *(*paps)[2] = new S*[*pi][2];
72 ia4 *pai = new (int[3][4]);
73 pi = ::new int;
74 U *pu = new (ps) U;
75 V *pv = new (ps) V;
77 pi = new (S(1.0f, 2)) int;
79 (void)new int[true];
83 foo* f1 = new foo;
84 foo* f2 = new foo[2];
87 x* f3 = new y;
90 (void)new int[]{};
91 (void)new int[]{1, 2, 3};
92 (void)new char[]{"hello"};
103 (void)new; // expected-error {{expected a type}}
104 (void)new 4; // expected-error {{expected a type}}
105 (void)new () int; // expected-error {{expected expression}}
106 (void)new int[1.1];
115 (void)new int[1][i]; // expected-note {{read of non-const variable 'i' is not allowed in a constant expression}}
116 (void)new (int[1][i]); // expected-note {{read of non-const variable 'i' is not allowed in a constant expression}}
124 (void)new (int[i]); // expected-warning {{when type is in parentheses}}
125 (void)new int(*(S*)0); // expected-error {{no viable conversion from 'S' to 'int'}}
126 (void)new int(1, 2); // expected-error {{excess elements in scalar initializer}}
127 (void)new S(1); // expected-error {{no matching constructor}}
128 (void)new S(1, 1); // expected-error {{call to constructor of 'S' is ambiguous}}
129 (void)new const int; // expected-error {{default initialization of an object of const type 'const int'}}
130 (void)new float*(ip); // expected-error {{cannot initialize a new value of type 'float *' with an lvalue of type 'int *'}}
132 (void)new int[-1];
138 (void)new int[2000000000]; // expected-error {{array is too large}}
139 (void)new int[*(S*)0];
148 (void)::S::new int; // expected-error {{expected unqualified-id}}
149 (void)new (0, 0) int; // expected-error {{no matching function for call to 'operator new'}}
150 (void)new (0L) int; // expected-error {{call to 'operator new' is ambiguous}}
152 (void)::new ((S*)0) U; // expected-error {{no matching 'operator new' function for non-allocating placement new expression; include <new>}}
154 (void)new U; // expected-error {{no matching function for call to 'operator new'}}
155 (void)new (int[]); // expected-error {{array size must be specified in new expression with no initializer}}
156 (void)new int&; // expected-error {{cannot allocate reference type 'int &' with new}}
157 (void)new int[]; // expected-error {{array size must be specified in new expression with no initializer}}
158 (void)new int[](); // expected-error {{cannot determine allocated array size from initializer}}
161 (void)new int[]{}; // expected-error {{array size must be specified in new expression with no initializer}}
168 (void)new(buffer) X; // expected-error {{no matching 'operator new' function for non-allocating placement new expression; include <new>}}
169 (void)new(+buffer) X; // expected-error {{no matching 'operator new' function for non-allocating placement new expression; include <new>}}
170 (void)new(&buffer) X; // expected-error {{no matching 'operator new' function for non-allocating placement new expression; include <new>}}
236 static void *operator new(signed char) throw(); // expected-error {{'operator new' takes type size_t}}
237 static int operator new[] (size_t) throw(); // expected-error {{operator new[]' must return type 'void *'}}
250 new Thai(dict);
254 void* operator new(T size, int); // expected-error {{'operator new' cannot take a dependent type as first parameter; use size_t}}
316 void* operator new(size_t, void*);
320 using X12::operator new;
325 return new (g) X13();
344 new X15(); // expected-error {{calling a private constructor}}
348 namespace PR5918 { // Look for template operator new overloads.
349 struct S { template<typename T> static void* operator new(size_t, T); };
351 (void)new(0) S;
358 (void)new int[10](1, 2); // precxx20-error {{array 'new' cannot have initialization arguments}}
361 (void)new T(1, 2); // precxx20-error {{array 'new' cannot have initialization arguments}}
366 (void)new T[1](i); // precxx20-error {{array 'new' cannot have initialization arguments}}
371 (void)new T(i); // precxx20-error {{array 'new' cannot have initialization arguments}}
377 new W[2](1, 2, 3); // precxx20-error {{array 'new' cannot have initialization arguments}}
386 void* operator new(size_t);
390 void* operator new(size_t, void*); // expected-note {{declared private here}}
394 void* operator new(size_t); // expected-note {{declared private here}}
401 (void)new S1();
402 (void)new (0L) S1(); // expected-error {{is a private member}}
403 (void)new S2(); // expected-error {{is a private member}}
422 return new (int[T::value]); // expected-warning{{when type is in parentheses, array cannot have dynamic size}}
460 void* operator new(const size_t size);
461 template<class T> void* operator new(const size_t, const int, T*);
478 // the unexpected placement 'operator new'.
482 void *operator new(size_t s, double d = 0);
490 return new A<int>();
496 new DoesNotExist; // expected-error {{unknown type name 'DoesNotExist'}}
513 return new B[5];
560 inline void *operator new[](size_t, const PlacementArg &) throw () {
571 S() { new Inner[1]; }
579 new (*(PlacementArg*)0) T[1]; // expected-warning 2 {{binding dereferenced null pointer to reference has undefined behavior}}
597 CopyCounter* f = new CopyCounter[10](CopyCounter()); // precxx20-error {{cannot have initialization arguments}}
607 Foo() : a_(new scoped_array<int>[5]) { }
617 Foo2() : a_(new scoped_array2<int>[5]) { }
631 new MessageLoop;
654 inline void *operator new(size_t); // expected-error {{'operator new' cannot be declared inside a namespace}}
658 inline void* operator new(); // expected-error {{'operator new' must have at least one parameter}}
663 void f() { this->::new; } // expected-error {{expected unqualified-id}}
670 return new int[]{v...}; // expected-error {{cannot initialize}}
678 // constant-folding in array bounds in new-expressions.
679 int (*const_fold)[12] = new int[3][&const_fold + 12 - &const_fold];