1 // RUN: %clang_cc1 -fms-compatibility -fsyntax-only -verify -std=c++11 %s
2 
3 #include <stddef.h>
4 
5 struct arbitrary_t {} arbitrary;
6 void *operator new(size_t size, arbitrary_t);
7 
f()8 void f() {
9   // Expect no error in MSVC compatibility mode
10   int *p = new(arbitrary) int[4];
11 }
12 
13 class noncopyable { noncopyable(const noncopyable&); } extern nc; // expected-note {{here}}
14 void *operator new[](size_t, noncopyable);
15 void *operator new(size_t, const noncopyable&);
16 void *q = new (nc) int[4]; // expected-error {{calling a private constructor}}
17 
18 struct bitfield { int n : 3; } bf; // expected-note {{here}}
19 void *operator new[](size_t, int &); // expected-note {{passing argument to parameter here}}
20 void *operator new(size_t, const int &);
21 void *r = new (bf.n) int[4]; // expected-error {{non-const reference cannot bind to bit-field}}
22 
23 struct base {};
24 struct derived : private base {} der; // expected-note {{here}}
25 void *operator new[](size_t, base &);
26 void *operator new(size_t, derived &);
27 void *s = new (der) int[4]; // expected-error {{private}}
28 
29 struct explicit_ctor { explicit explicit_ctor(int); };
30 struct explicit_ctor_tag {} ect;
31 void *operator new[](size_t, explicit_ctor_tag, explicit_ctor);
32 void *operator new(size_t, explicit_ctor_tag, int);
33 void *t = new (ect, 0) int[4];
34 void *u = new (ect, {0}) int[4]; // expected-warning {{braces around scalar init}}
35