[lld][WebAssembly] Reinstate mistakenly disabled test. NFC
[llvm-project.git] / clang / test / SemaCXX / new-delete-0x.cpp
blob972ad1d1b07eff988a1b28ee1436bc62addd4aa4
1 // RUN: %clang_cc1 -fsyntax-only -verify %s -triple=i686-pc-linux-gnu -std=c++11
3 using size_t = decltype(sizeof(0));
4 struct noreturn_t {} constexpr noreturn = {};
6 void *operator new [[noreturn]] (size_t, noreturn_t);
7 void operator delete [[noreturn]] (void*, noreturn_t);
9 void good_news()
11 auto p = new int[2][[]];
12 auto q = new int[[]][2];
13 auto r = new int*[[]][2][[]];
14 auto s = new (int(*[[]])[2][[]]);
17 void bad_news(int *ip)
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}} \
25 expected-error {{variably modified type}} \
26 expected-error {{a lambda expression may not appear inside of a constant expression}}
29 void good_deletes()
31 delete [&]{ return (int*)0; }();
34 void bad_deletes()
36 // 'delete []' is always array delete, per [expr.delete]p1.
37 delete []{ return (int*)0; }(); // expected-error {{'[]' after delete interpreted as 'delete[]'}}