blob: b929e618a0368893fe49b3328db563d030f64e6c [file] [log] [blame]
Richard Smithd6f9e732014-05-13 19:56:21 +00001// RUN: %clang_cc1 -fms-compatibility -fsyntax-only -verify -std=c++11 %s
Aaron Ballman324fbee2013-05-30 01:55:39 +00002
Aaron Ballman194a79e2013-05-30 02:17:14 +00003#include <stddef.h>
4
Aaron Ballman324fbee2013-05-30 01:55:39 +00005struct arbitrary_t {} arbitrary;
Aaron Ballman194a79e2013-05-30 02:17:14 +00006void *operator new(size_t size, arbitrary_t);
Aaron Ballman324fbee2013-05-30 01:55:39 +00007
8void f() {
9 // Expect no error in MSVC compatibility mode
10 int *p = new(arbitrary) int[4];
11}
Richard Smithd6f9e732014-05-13 19:56:21 +000012
13class noncopyable { noncopyable(const noncopyable&); } extern nc; // expected-note {{here}}
14void *operator new[](size_t, noncopyable);
15void *operator new(size_t, const noncopyable&);
16void *q = new (nc) int[4]; // expected-error {{calling a private constructor}}
17
18struct bitfield { int n : 3; } bf; // expected-note {{here}}
19void *operator new[](size_t, int &);
20void *operator new(size_t, const int &);
21void *r = new (bf.n) int[4]; // expected-error {{non-const reference cannot bind to bit-field}}
22
23struct base {};
24struct derived : private base {} der; // expected-note {{here}}
25void *operator new[](size_t, base &);
26void *operator new(size_t, derived &);
27void *s = new (der) int[4]; // expected-error {{private}}
28
29struct explicit_ctor { explicit explicit_ctor(int); };
30struct explicit_ctor_tag {} ect;
31void *operator new[](size_t, explicit_ctor_tag, explicit_ctor);
32void *operator new(size_t, explicit_ctor_tag, int);
33void *t = new (ect, 0) int[4];
Richard Smith420fa122015-02-12 01:50:05 +000034void *u = new (ect, {0}) int[4]; // expected-warning {{braces around scalar init}}