blob: 0875b66e2132e6c1b5fb75c59c797cfaaaf5c4c8 [file] [log] [blame]
Richard Smith6ee326a2012-04-10 01:32:12 +00001// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
2
3@interface X {}
4+ (X*) alloc;
5- (X*) init;
6- (int) getSize;
7- (void) setSize: (int) size;
8- (X*) getSelf;
9@end
10
11void f(X *noreturn) {
12 // An array size which is computed by a message send is OK.
13 int a[ [noreturn getSize] ];
14
15 // ... but is interpreted as an attribute where possible.
16 int b[ [noreturn] ]; // expected-warning {{'noreturn' only applies to function types}}
17
18 int c[ [noreturn getSize] + 1 ];
19
20 // An array size which is computed by a lambda is not OK.
21 int d[ [noreturn] { return 3; } () ]; // expected-error {{expected ']'}} expected-warning {{'noreturn' only applies}}
22
23 // A message send which contains a message send is OK.
24 [ [ X alloc ] init ];
25 [ [ int(), noreturn getSelf ] getSize ]; // expected-warning {{unused}}
26
27 // A message send which contains a lambda is OK.
28 [ [noreturn] { return noreturn; } () setSize: 4 ];
29 [ [bitand] { return noreturn; } () setSize: 5 ];
30 [[[[] { return [ X alloc ]; } () init] getSelf] getSize];
31
32 // An attribute is OK.
33 [[]];
34 [[int(), noreturn]];
35 [[class, test(foo 'x' bar),,,]];
Richard Smithc56298d2012-04-10 03:25:07 +000036 [[bitand, noreturn]];
Richard Smith6ce48a72012-04-11 04:01:28 +000037
38 [[noreturn]]int(e)();
39
40 // A function taking a noreturn function.
41 int(f)([[noreturn]] int());
42 f(e);
43
44 // Variables initialized by a message send.
45 int(g)([[noreturn getSelf] getSize]);
46 int(h)([[noreturn]{return noreturn;}() getSize]);
47
48 int i = g + h;
Richard Smith6ee326a2012-04-10 01:32:12 +000049}
50
51template<typename...Ts> void f(Ts ...x) {
52 [[test::foo(bar, baz)...]];
53 [[used(x)...]];
54 [[x...] { return [ X alloc ]; }() init];
55}