]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/SemaObjC/warn-missing-super.m
Vendor import of clang release_34 branch r197841 (effectively, 3.4 RC3):
[FreeBSD/FreeBSD.git] / test / SemaObjC / warn-missing-super.m
1 @protocol NSCopying @end
2
3 __attribute__((objc_root_class))
4 @interface NSObject <NSCopying>
5 - (void)dealloc;
6 @end
7
8 @implementation NSObject
9 - (void)dealloc {
10   // Root class, shouldn't warn
11 }
12 - (void)finalize {
13   // Root class, shouldn't warn
14 }
15 @end
16
17 @interface Subclass1 : NSObject
18 - (void)dealloc;
19 - (void)finalize;
20 @end
21
22 @implementation Subclass1
23 - (void)dealloc {
24 }
25 - (void)finalize {
26 }
27 @end
28
29 @interface Subclass2 : NSObject
30 - (void)dealloc;
31 - (void)finalize;
32 @end
33
34 @implementation Subclass2
35 - (void)dealloc {
36   [super dealloc];  // Shouldn't warn
37 }
38 - (void)finalize {
39   [super finalize];  // Shouldn't warn
40 }
41 @end
42
43 // RUN: %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck %s
44 // CHECK: warn-missing-super.m:24:1: warning: method possibly missing a [super dealloc] call
45 // CHECK: 1 warning generated.
46
47 // RUN: %clang_cc1 -fsyntax-only -fobjc-gc %s 2>&1 | FileCheck --check-prefix=CHECK-GC %s
48 // CHECK-GC: warn-missing-super.m:24:1: warning: method possibly missing a [super dealloc] call
49 // CHECK-GC: warn-missing-super.m:26:1: warning: method possibly missing a [super finalize] call
50 // CHECK-GC: 2 warnings generated.
51
52 // RUN: %clang_cc1 -fsyntax-only -fobjc-gc-only %s 2>&1 | FileCheck --check-prefix=CHECK-GC-ONLY %s
53 // CHECK-GC-ONLY: warn-missing-super.m:26:1: warning: method possibly missing a [super finalize] call
54 // CHECK-GC-ONLY: 1 warning generated.
55
56 // RUN: not %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin10 -fobjc-arc %s 2>&1 | FileCheck --check-prefix=CHECK-ARC %s
57 // CHECK-ARC: warn-missing-super.m:36:10: error: ARC forbids explicit message send of 'dealloc'
58 // CHECK-ARC: 1 error generated.