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