Richard Smith | d6f9e73 | 2014-05-13 19:56:21 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fms-compatibility -fsyntax-only -verify -std=c++11 %s |
Aaron Ballman | 324fbee | 2013-05-30 01:55:39 +0000 | [diff] [blame] | 2 | |
Aaron Ballman | 194a79e | 2013-05-30 02:17:14 +0000 | [diff] [blame] | 3 | #include <stddef.h> |
| 4 | |
Aaron Ballman | 324fbee | 2013-05-30 01:55:39 +0000 | [diff] [blame] | 5 | struct arbitrary_t {} arbitrary; |
Aaron Ballman | 194a79e | 2013-05-30 02:17:14 +0000 | [diff] [blame] | 6 | void *operator new(size_t size, arbitrary_t); |
Aaron Ballman | 324fbee | 2013-05-30 01:55:39 +0000 | [diff] [blame] | 7 | |
| 8 | void f() { |
| 9 | // Expect no error in MSVC compatibility mode |
| 10 | int *p = new(arbitrary) int[4]; |
| 11 | } |
Richard Smith | d6f9e73 | 2014-05-13 19:56:21 +0000 | [diff] [blame] | 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 &); |
| 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]; |
Richard Smith | 420fa12 | 2015-02-12 01:50:05 +0000 | [diff] [blame] | 34 | void *u = new (ect, {0}) int[4]; // expected-warning {{braces around scalar init}} |