brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · beba4d9 Raw
35 lines · cpp
1// RUN: %clang_cc1 -fms-compatibility -fsyntax-only -verify -std=c++11 %s2 3#include <stddef.h>4 5struct arbitrary_t {} arbitrary;6void *operator new(size_t size, arbitrary_t);7 8void f() {9  // Expect no error in MSVC compatibility mode10  int *p = new(arbitrary) int[4];11}12 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 &); // expected-note {{passing argument to parameter here}}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];34void *u = new (ect, {0}) int[4]; // expected-warning {{braces around scalar init}}35