10b458fd8b6321c11e8b22727e0e9b9960e93ff4dRichard Smith// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -triple=i686-pc-linux-gnu 20b458fd8b6321c11e8b22727e0e9b9960e93ff4dRichard Smith 30b458fd8b6321c11e8b22727e0e9b9960e93ff4dRichard Smithvoid ugly_news(int *ip) { 40b458fd8b6321c11e8b22727e0e9b9960e93ff4dRichard Smith // These are ill-formed according to one reading of C++98, and at the least 5ef8225444452a1486bd721f3285301fe84643b00Stephen Hines // have undefined behavior. 6ef8225444452a1486bd721f3285301fe84643b00Stephen Hines // FIXME: They're ill-formed in C++11. 70b458fd8b6321c11e8b22727e0e9b9960e93ff4dRichard Smith (void)new int[-1]; // expected-warning {{array size is negative}} 80b458fd8b6321c11e8b22727e0e9b9960e93ff4dRichard Smith (void)new int[2000000000]; // expected-warning {{array is too large}} 90b458fd8b6321c11e8b22727e0e9b9960e93ff4dRichard Smith} 10bd45d257a404ed1f87090c8a32b5dd75576b7d11Sebastian Redl 11bd45d257a404ed1f87090c8a32b5dd75576b7d11Sebastian Redl 12bd45d257a404ed1f87090c8a32b5dd75576b7d11Sebastian Redlstruct S { 13bd45d257a404ed1f87090c8a32b5dd75576b7d11Sebastian Redl S(int); 14bd45d257a404ed1f87090c8a32b5dd75576b7d11Sebastian Redl S(); 15bd45d257a404ed1f87090c8a32b5dd75576b7d11Sebastian Redl ~S(); 16bd45d257a404ed1f87090c8a32b5dd75576b7d11Sebastian Redl}; 17bd45d257a404ed1f87090c8a32b5dd75576b7d11Sebastian Redl 18bd45d257a404ed1f87090c8a32b5dd75576b7d11Sebastian Redlstruct T { // expected-note 2 {{not viable}} 19bd45d257a404ed1f87090c8a32b5dd75576b7d11Sebastian Redl T(int); // expected-note {{not viable}} 20bd45d257a404ed1f87090c8a32b5dd75576b7d11Sebastian Redl}; 21bd45d257a404ed1f87090c8a32b5dd75576b7d11Sebastian Redl 22bd45d257a404ed1f87090c8a32b5dd75576b7d11Sebastian Redlvoid fn() { 23bd45d257a404ed1f87090c8a32b5dd75576b7d11Sebastian Redl (void) new int[2] {1, 2}; 24bd45d257a404ed1f87090c8a32b5dd75576b7d11Sebastian Redl (void) new S[2] {1, 2}; 25ef8225444452a1486bd721f3285301fe84643b00Stephen Hines // C++11 [expr.new]p19: 26ef8225444452a1486bd721f3285301fe84643b00Stephen Hines // If the new-expression creates an object or an array of objects of class 27ef8225444452a1486bd721f3285301fe84643b00Stephen Hines // type, access and ambiguity control are done for the allocation function, 28ef8225444452a1486bd721f3285301fe84643b00Stephen Hines // the deallocation function (12.5), and the constructor (12.1). 29ef8225444452a1486bd721f3285301fe84643b00Stephen Hines // 30ef8225444452a1486bd721f3285301fe84643b00Stephen Hines // Note that this happens even if the array bound is constant and the 31ef8225444452a1486bd721f3285301fe84643b00Stephen Hines // initializer initializes every array element. 32ef8225444452a1486bd721f3285301fe84643b00Stephen Hines (void) new T[2] {1, 2}; // expected-error {{no matching constructor}} expected-note {{in implicit initialization of array element 2}} 33bd45d257a404ed1f87090c8a32b5dd75576b7d11Sebastian Redl} 34