blob: 02b81651d7a21d0d9f8cdbdedaa90e251913b426 [file] [log] [blame]
Nico Weber9a1ecf02011-08-22 17:25:57 +00001@protocol NSCopying @end
2
Patrick Beardb2f68202012-04-06 18:12:22 +00003__attribute__((objc_root_class))
Nico Weber9a1ecf02011-08-22 17:25:57 +00004@interface NSObject <NSCopying>
5- (void)dealloc;
6@end
7
8@implementation NSObject
9- (void)dealloc {
10 // Root class, shouldn't warn
11}
Nico Weber80cb6e62011-08-28 22:35:17 +000012- (void)finalize {
13 // Root class, shouldn't warn
14}
Nico Weber9a1ecf02011-08-22 17:25:57 +000015@end
16
17@interface Subclass1 : NSObject
18- (void)dealloc;
Nico Weber80cb6e62011-08-28 22:35:17 +000019- (void)finalize;
Nico Weber9a1ecf02011-08-22 17:25:57 +000020@end
21
22@implementation Subclass1
23- (void)dealloc {
Ted Kremenek4eb14ca2011-08-22 19:07:43 +000024}
Nico Weber80cb6e62011-08-28 22:35:17 +000025- (void)finalize {
26}
Nico Weber9a1ecf02011-08-22 17:25:57 +000027@end
28
29@interface Subclass2 : NSObject
30- (void)dealloc;
Nico Weber80cb6e62011-08-28 22:35:17 +000031- (void)finalize;
Nico Weber9a1ecf02011-08-22 17:25:57 +000032@end
33
34@implementation Subclass2
35- (void)dealloc {
36 [super dealloc]; // Shouldn't warn
37}
Nico Weber80cb6e62011-08-28 22:35:17 +000038- (void)finalize {
39 [super finalize]; // Shouldn't warn
40}
Nico Weber9a1ecf02011-08-22 17:25:57 +000041@end
Ted Kremenek4eb14ca2011-08-22 19:07:43 +000042
43// RUN: %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck %s
Patrick Beardb2f68202012-04-06 18:12:22 +000044// CHECK: warn-missing-super.m:24:1: warning: method possibly missing a [super dealloc] call
Ted Kremenek8cd8de42011-09-28 19:32:29 +000045// CHECK: 1 warning generated.
46
47// RUN: %clang_cc1 -fsyntax-only -fobjc-gc %s 2>&1 | FileCheck --check-prefix=CHECK-GC %s
Patrick Beardb2f68202012-04-06 18:12:22 +000048// 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
Ted Kremenek8cd8de42011-09-28 19:32:29 +000050// 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
Patrick Beardb2f68202012-04-06 18:12:22 +000053// CHECK-GC-ONLY: warn-missing-super.m:26:1: warning: method possibly missing a [super finalize] call
Ted Kremenek8cd8de42011-09-28 19:32:29 +000054// CHECK-GC-ONLY: 1 warning generated.
Ted Kremenek4eb14ca2011-08-22 19:07:43 +000055
John McCalld1e40d52011-10-02 01:16:38 +000056// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin10 -fobjc-arc %s 2>&1 | FileCheck --check-prefix=CHECK-ARC %s
Patrick Beardb2f68202012-04-06 18:12:22 +000057// CHECK-ARC: warn-missing-super.m:36:4: error: ARC forbids explicit message send of 'dealloc'
Nico Weber27f07762011-08-29 22:59:14 +000058// CHECK-ARC: 1 error generated.