xref: /minix3/external/bsd/llvm/dist/clang/test/SemaObjC/invalid-code.m (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fsyntax-only -verify -fobjc-exceptions -Wno-objc-root-class %s
2*f4a2713aSLionel Sambuc
3*f4a2713aSLionel Sambuc// rdar://6124613
4*f4a2713aSLionel Sambucvoid test1() {
5*f4a2713aSLionel Sambuc  void *xyzzy = 0;
6*f4a2713aSLionel Sambuc  void *p = @xyzzy; // expected-error {{unexpected '@' in program}}
7*f4a2713aSLionel Sambuc}
8*f4a2713aSLionel Sambuc
9*f4a2713aSLionel Sambuc// <rdar://problem/7495713>
10*f4a2713aSLionel Sambuc// This previously triggered a crash because the class has not been defined.
11*f4a2713aSLionel Sambuc@implementation RDar7495713 (rdar_7495713_cat)  // expected-error{{cannot find interface declaration for 'RDar7495713'}}
12*f4a2713aSLionel Sambuc- (id) rdar_7495713 {
13*f4a2713aSLionel Sambuc  __PRETTY_FUNCTION__; // expected-warning{{expression result unused}}
14*f4a2713aSLionel Sambuc}
15*f4a2713aSLionel Sambuc@end
16*f4a2713aSLionel Sambuc
17*f4a2713aSLionel Sambuc// <rdar://problem/7881045>
18*f4a2713aSLionel Sambuc// This previously triggered a crash because a ';' was expected after the @throw statement.
19*f4a2713aSLionel Sambucvoid foo() {
20*f4a2713aSLionel Sambuc  @throw (id)0 // expected-error{{expected ';' after @throw}}
21*f4a2713aSLionel Sambuc}
22*f4a2713aSLionel Sambuc
23*f4a2713aSLionel Sambuc// <rdar://problem/10415026>
24*f4a2713aSLionel Sambuc@class NSView;
25*f4a2713aSLionel Sambuc@implementation IBFillView(IBFillViewIntegration) // expected-error {{cannot find interface declaration for 'IBFillView'}}
26*f4a2713aSLionel Sambuc- (NSView *)ibDesignableContentView {
27*f4a2713aSLionel Sambuc    [Cake lie]; // expected-error {{undeclared}}
28*f4a2713aSLionel Sambuc    return self;
29*f4a2713aSLionel Sambuc}
30*f4a2713aSLionel Sambuc@end
31*f4a2713aSLionel Sambuc
32*f4a2713aSLionel Sambuc@interface I
33*f4a2713aSLionel Sambuc@end
34*f4a2713aSLionel Sambuc@interface I2
35*f4a2713aSLionel Sambuc@end
36*f4a2713aSLionel Sambuc
37*f4a2713aSLionel Sambuc@implementation I // expected-note {{started here}}
38*f4a2713aSLionel Sambuc-(void) foo {}
39*f4a2713aSLionel Sambuc
40*f4a2713aSLionel Sambuc@implementation I2 // expected-error {{missing '@end'}}
41*f4a2713aSLionel Sambuc-(void) foo2 {}
42*f4a2713aSLionel Sambuc@end
43*f4a2713aSLionel Sambuc
44*f4a2713aSLionel Sambuc@end // expected-error {{'@end' must appear in an Objective-C context}}
45*f4a2713aSLionel Sambuc
46*f4a2713aSLionel Sambuc@class ForwardBase;
47*f4a2713aSLionel Sambuc@implementation SomeI : ForwardBase // expected-error {{cannot find interface declaration for 'ForwardBase', superclass of 'SomeI'}} \
48*f4a2713aSLionel Sambuc                                    // expected-warning {{cannot find interface declaration for 'SomeI'}}
49*f4a2713aSLionel Sambuc-(void)meth {}
50*f4a2713aSLionel Sambuc@end
51*f4a2713aSLionel Sambuc
52*f4a2713aSLionel Sambuc@interface I3
53*f4a2713aSLionel Sambuc__attribute__((unavailable)) @interface I4 @end // expected-error {{Objective-C declarations may only appear in global scope}}
54*f4a2713aSLionel Sambuc@end
55