blob: 088e385f9508e1fed4f81dc0b8d2b7a8dca11651 [file] [log] [blame]
John McCall5fb5df92012-06-20 06:18:46 +00001// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-fragile -verify -pedantic -Wno-objc-root-class %s
2// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-fragile -verify -x objective-c++ -Wno-objc-root-class %s
Charles Li85dec552015-12-10 01:07:17 +00003// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-fragile -verify -x objective-c++ -Wno-objc-root-class -std=c++98 %s
4// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-fragile -verify -x objective-c++ -Wno-objc-root-class -std=c++11 %s
Chris Lattner8917c5a2008-01-25 19:37:24 +00005// rdar://5707001
6
7@interface NSNumber;
8- () METH;
Chris Lattnerfd2fe822008-06-02 21:31:07 +00009- (unsigned) METH2;
Chris Lattner8917c5a2008-01-25 19:37:24 +000010@end
11
Chris Lattner9a53fdc2008-10-26 23:29:41 +000012struct SomeStruct {
13 int x, y, z, q;
14};
15
Chris Lattner77927cc2008-01-25 19:43:26 +000016void test1() {
Chris Lattner8917c5a2008-01-25 19:37:24 +000017 id objects[] = {[NSNumber METH]};
Chris Lattner77927cc2008-01-25 19:43:26 +000018}
19
Richard Trieu553b2b22011-12-15 00:38:15 +000020void test2(NSNumber x) { // expected-error {{interface type 'NSNumber' cannot be passed by value; did you forget * in 'NSNumber'}}
Steve Naroff32606412009-02-20 22:59:16 +000021 id objects[] = {[x METH]};
Chris Lattnerbd2d6342008-07-21 06:12:56 +000022}
23
24void test3(NSNumber *x) {
Chris Lattner77927cc2008-01-25 19:43:26 +000025 id objects[] = {[x METH]};
Chris Lattner8917c5a2008-01-25 19:37:24 +000026}
27
Chris Lattner77927cc2008-01-25 19:43:26 +000028
Chris Lattnerfd2fe822008-06-02 21:31:07 +000029// rdar://5977581
Chris Lattnerbd2d6342008-07-21 06:12:56 +000030void test4() {
Chris Lattnerfd2fe822008-06-02 21:31:07 +000031 unsigned x[] = {[NSNumber METH2]+2};
32}
33
Chris Lattner9a53fdc2008-10-26 23:29:41 +000034void test5(NSNumber *x) {
35 unsigned y[] = {
36 [4][NSNumber METH2]+2, // expected-warning {{use of GNU 'missing =' extension in designator}}
37 [4][x METH2]+2 // expected-warning {{use of GNU 'missing =' extension in designator}}
38 };
39
40 struct SomeStruct z = {
Charles Li85dec552015-12-10 01:07:17 +000041 .x = [x METH2], // ok in C++98.
42#if __cplusplus >= 201103L
43 // expected-error@-2 {{non-constant-expression cannot be narrowed from type 'unsigned int' to 'int' in initializer list}}
44 // expected-note@-3 {{insert an explicit cast to silence this issue}}
45#endif
Chris Lattner9a53fdc2008-10-26 23:29:41 +000046 .x [x METH2] // expected-error {{expected '=' or another designator}}
Charles Li85dec552015-12-10 01:07:17 +000047#if __cplusplus >= 201103L
48 // expected-error@-2 {{non-constant-expression cannot be narrowed from type 'unsigned int' to 'int' in initializer list}}
49 // expected-note@-3 {{insert an explicit cast to silence this issue}}
50#endif
Chris Lattner9a53fdc2008-10-26 23:29:41 +000051 };
52}
Fariborz Jahanian95239112009-11-06 21:48:47 +000053
54// rdar://7370882
55@interface SemicolonsAppDelegate
56{
57 id i;
58}
59@property (assign) id window;
60@end
61
62@implementation SemicolonsAppDelegate
63{
64 id i;
65}
Fariborz Jahanian2f487122009-11-06 22:15:27 +000066 @synthesize window=i;
Fariborz Jahanian95239112009-11-06 21:48:47 +000067@end
68
69
70