blob: 9e3b4928b14154e2685d37ed0e7d69bea0f2906a [file] [log] [blame]
Richard Smith6ee326a2012-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; }();
Richard Smith64fe36e2012-10-17 06:45:09 +000030}
31
32void bad_deletes()
33{
34 // 'delete []' is always array delete, per [expr.delete]p1.
35 // FIXME: Give a better diagnostic.
36 delete []{ return (int*)0; }(); // expected-error {{expected expression}}
Richard Smith6ee326a2012-04-10 01:32:12 +000037}