blob: dcc2e9b8b12a34e58a8b6edfc740830fe218d08d [file] [log] [blame]
Richard Smith7bdcc4a2012-04-10 01:32:12 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s -triple=i686-pc-linux-gnu -std=c++11
2
3using size_t = decltype(sizeof(0));
4struct noreturn_t {} constexpr noreturn = {};
5
6void *operator new [[noreturn]] (size_t, noreturn_t);
7void operator delete [[noreturn]] (void*, noreturn_t);
8
9void good_news()
10{
11 auto p = new int[2][[]];
12 auto q = new int[[]][2];
13 auto r = new int*[[]][2][[]];
14 auto s = new (int(*[[]])[2][[]]);
15}
16
17void bad_news(int *ip)
18{
19 // attribute-specifiers can go almost anywhere in a new-type-id...
20 auto r = new int[[]{return 1;}()][2]; // expected-error {{expected ']'}}
21 auto s = new int*[[]{return 1;}()][2]; // expected-error {{expected ']'}}
22 // ... but not here:
23 auto t = new (int(*)[[]]); // expected-error {{an attribute list cannot appear here}}
24 auto u = new (int(*)[[]{return 1;}()][2]); // expected-error {{C++11 only allows consecutive left square brackets when introducing an attribute}} expected-error {{variably modified type}}
25}
26
27void good_deletes()
28{
29 delete [&]{ return (int*)0; }();
30 // FIXME: This appears to be legal.
31 delete []{ return (int*)0; }(); // unexpected-error {{expected expression}}
32}