1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s -triple=i686-pc-linux-gnu -std=c++11 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc using size_t = decltype(sizeof(0)); 4*f4a2713aSLionel Sambuc struct noreturn_t {} constexpr noreturn = {}; 5*f4a2713aSLionel Sambuc 6*f4a2713aSLionel Sambuc void *operator new [[noreturn]] (size_t, noreturn_t); 7*f4a2713aSLionel Sambuc void operator delete [[noreturn]] (void*, noreturn_t); 8*f4a2713aSLionel Sambuc good_news()9*f4a2713aSLionel Sambucvoid good_news() 10*f4a2713aSLionel Sambuc { 11*f4a2713aSLionel Sambuc auto p = new int[2][[]]; 12*f4a2713aSLionel Sambuc auto q = new int[[]][2]; 13*f4a2713aSLionel Sambuc auto r = new int*[[]][2][[]]; 14*f4a2713aSLionel Sambuc auto s = new (int(*[[]])[2][[]]); 15*f4a2713aSLionel Sambuc } 16*f4a2713aSLionel Sambuc bad_news(int * ip)17*f4a2713aSLionel Sambucvoid bad_news(int *ip) 18*f4a2713aSLionel Sambuc { 19*f4a2713aSLionel Sambuc // attribute-specifiers can go almost anywhere in a new-type-id... 20*f4a2713aSLionel Sambuc auto r = new int[[]{return 1;}()][2]; // expected-error {{expected ']'}} 21*f4a2713aSLionel Sambuc auto s = new int*[[]{return 1;}()][2]; // expected-error {{expected ']'}} 22*f4a2713aSLionel Sambuc // ... but not here: 23*f4a2713aSLionel Sambuc auto t = new (int(*)[[]]); // expected-error {{an attribute list cannot appear here}} 24*f4a2713aSLionel Sambuc auto u = new (int(*)[[]{return 1;}()][2]); // expected-error {{C++11 only allows consecutive left square brackets when introducing an attribute}} \ 25*f4a2713aSLionel Sambuc expected-error {{variably modified type}} \ 26*f4a2713aSLionel Sambuc expected-error {{a lambda expression may not appear inside of a constant expression}} 27*f4a2713aSLionel Sambuc } 28*f4a2713aSLionel Sambuc good_deletes()29*f4a2713aSLionel Sambucvoid good_deletes() 30*f4a2713aSLionel Sambuc { 31*f4a2713aSLionel Sambuc delete [&]{ return (int*)0; }(); 32*f4a2713aSLionel Sambuc } 33*f4a2713aSLionel Sambuc bad_deletes()34*f4a2713aSLionel Sambucvoid bad_deletes() 35*f4a2713aSLionel Sambuc { 36*f4a2713aSLionel Sambuc // 'delete []' is always array delete, per [expr.delete]p1. 37*f4a2713aSLionel Sambuc // FIXME: Give a better diagnostic. 38*f4a2713aSLionel Sambuc delete []{ return (int*)0; }(); // expected-error {{expected expression}} 39*f4a2713aSLionel Sambuc } 40