xref: /minix3/external/bsd/llvm/dist/clang/test/Parser/objc-init.m (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-fragile -verify -pedantic -Wno-objc-root-class %s
2*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-fragile -verify -x objective-c++ -Wno-objc-root-class %s
3*f4a2713aSLionel Sambuc// rdar://5707001
4*f4a2713aSLionel Sambuc
5*f4a2713aSLionel Sambuc@interface NSNumber;
6*f4a2713aSLionel Sambuc- () METH;
7*f4a2713aSLionel Sambuc- (unsigned) METH2;
8*f4a2713aSLionel Sambuc@end
9*f4a2713aSLionel Sambuc
10*f4a2713aSLionel Sambucstruct SomeStruct {
11*f4a2713aSLionel Sambuc  int x, y, z, q;
12*f4a2713aSLionel Sambuc};
13*f4a2713aSLionel Sambuc
14*f4a2713aSLionel Sambucvoid test1() {
15*f4a2713aSLionel Sambuc	id objects[] = {[NSNumber METH]};
16*f4a2713aSLionel Sambuc}
17*f4a2713aSLionel Sambuc
18*f4a2713aSLionel Sambucvoid test2(NSNumber x) { // expected-error {{interface type 'NSNumber' cannot be passed by value; did you forget * in 'NSNumber'}}
19*f4a2713aSLionel Sambuc	id objects[] = {[x METH]};
20*f4a2713aSLionel Sambuc}
21*f4a2713aSLionel Sambuc
22*f4a2713aSLionel Sambucvoid test3(NSNumber *x) {
23*f4a2713aSLionel Sambuc	id objects[] = {[x METH]};
24*f4a2713aSLionel Sambuc}
25*f4a2713aSLionel Sambuc
26*f4a2713aSLionel Sambuc
27*f4a2713aSLionel Sambuc// rdar://5977581
28*f4a2713aSLionel Sambucvoid test4() {
29*f4a2713aSLionel Sambuc  unsigned x[] = {[NSNumber METH2]+2};
30*f4a2713aSLionel Sambuc}
31*f4a2713aSLionel Sambuc
32*f4a2713aSLionel Sambucvoid test5(NSNumber *x) {
33*f4a2713aSLionel Sambuc  unsigned y[] = {
34*f4a2713aSLionel Sambuc    [4][NSNumber METH2]+2,   // expected-warning {{use of GNU 'missing =' extension in designator}}
35*f4a2713aSLionel Sambuc    [4][x METH2]+2   // expected-warning {{use of GNU 'missing =' extension in designator}}
36*f4a2713aSLionel Sambuc  };
37*f4a2713aSLionel Sambuc
38*f4a2713aSLionel Sambuc  struct SomeStruct z = {
39*f4a2713aSLionel Sambuc    .x = [x METH2], // ok.
40*f4a2713aSLionel Sambuc    .x [x METH2]    // expected-error {{expected '=' or another designator}}
41*f4a2713aSLionel Sambuc  };
42*f4a2713aSLionel Sambuc}
43*f4a2713aSLionel Sambuc
44*f4a2713aSLionel Sambuc// rdar://7370882
45*f4a2713aSLionel Sambuc@interface SemicolonsAppDelegate
46*f4a2713aSLionel Sambuc{
47*f4a2713aSLionel Sambuc  id i;
48*f4a2713aSLionel Sambuc}
49*f4a2713aSLionel Sambuc@property (assign) id window;
50*f4a2713aSLionel Sambuc@end
51*f4a2713aSLionel Sambuc
52*f4a2713aSLionel Sambuc@implementation SemicolonsAppDelegate
53*f4a2713aSLionel Sambuc{
54*f4a2713aSLionel Sambuc  id i;
55*f4a2713aSLionel Sambuc}
56*f4a2713aSLionel Sambuc  @synthesize window=i;
57*f4a2713aSLionel Sambuc@end
58*f4a2713aSLionel Sambuc
59*f4a2713aSLionel Sambuc
60*f4a2713aSLionel Sambuc
61