blob: 5dcdb572925a2b89bf7960c7b2a09a3b852ffdcf [file] [log] [blame]
Nico Weber9a1ecf02011-08-22 17:25:57 +00001@protocol NSCopying @end
2
3@interface NSObject <NSCopying>
4- (void)dealloc;
5@end
6
7@implementation NSObject
8- (void)dealloc {
9 // Root class, shouldn't warn
10}
Nico Weber80cb6e62011-08-28 22:35:17 +000011- (void)finalize {
12 // Root class, shouldn't warn
13}
Nico Weber9a1ecf02011-08-22 17:25:57 +000014@end
15
16@interface Subclass1 : NSObject
17- (void)dealloc;
Nico Weber80cb6e62011-08-28 22:35:17 +000018- (void)finalize;
Nico Weber9a1ecf02011-08-22 17:25:57 +000019@end
20
21@implementation Subclass1
22- (void)dealloc {
Ted Kremenek4eb14ca2011-08-22 19:07:43 +000023}
Nico Weber80cb6e62011-08-28 22:35:17 +000024- (void)finalize {
25}
Nico Weber9a1ecf02011-08-22 17:25:57 +000026@end
27
28@interface Subclass2 : NSObject
29- (void)dealloc;
Nico Weber80cb6e62011-08-28 22:35:17 +000030- (void)finalize;
Nico Weber9a1ecf02011-08-22 17:25:57 +000031@end
32
33@implementation Subclass2
34- (void)dealloc {
35 [super dealloc]; // Shouldn't warn
36}
Nico Weber80cb6e62011-08-28 22:35:17 +000037- (void)finalize {
38 [super finalize]; // Shouldn't warn
39}
Nico Weber9a1ecf02011-08-22 17:25:57 +000040@end
Ted Kremenek4eb14ca2011-08-22 19:07:43 +000041
42// RUN: %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck %s
Nico Weber80cb6e62011-08-28 22:35:17 +000043// CHECK: warn-missing-super.m:23:1: warning: method possibly missing a [super dealloc] call
Ted Kremenek8cd8de42011-09-28 19:32:29 +000044// CHECK: 1 warning generated.
45
46// RUN: %clang_cc1 -fsyntax-only -fobjc-gc %s 2>&1 | FileCheck --check-prefix=CHECK-GC %s
47// CHECK-GC: warn-missing-super.m:23:1: warning: method possibly missing a [super dealloc] call
48// CHECK-GC: warn-missing-super.m:25:1: warning: method possibly missing a [super finalize] call
49// CHECK-GC: 2 warnings generated.
50
51// RUN: %clang_cc1 -fsyntax-only -fobjc-gc-only %s 2>&1 | FileCheck --check-prefix=CHECK-GC-ONLY %s
52// CHECK-GC-ONLY: warn-missing-super.m:25:1: warning: method possibly missing a [super finalize] call
53// CHECK-GC-ONLY: 1 warning generated.
Ted Kremenek4eb14ca2011-08-22 19:07:43 +000054
55// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fobjc-arc %s 2>&1 | FileCheck --check-prefix=CHECK-ARC %s
Nico Weber80cb6e62011-08-28 22:35:17 +000056// CHECK-ARC: warn-missing-super.m:35:4: error: ARC forbids explicit message send of 'dealloc'
Nico Weber27f07762011-08-29 22:59:14 +000057// CHECK-ARC: 1 error generated.