diff options
Diffstat (limited to 'test/SemaObjC')
-rw-r--r-- | test/SemaObjC/cocoa.m | 2 | ||||
-rw-r--r-- | test/SemaObjC/default-synthesize.m | 81 | ||||
-rw-r--r-- | test/SemaObjC/duplicate-property-class-extension.m | 13 | ||||
-rw-r--r-- | test/SemaObjC/exprs.m | 2 | ||||
-rw-r--r-- | test/SemaObjC/format-strings-objc.m | 11 | ||||
-rw-r--r-- | test/SemaObjC/method-arg-decay.m | 2 | ||||
-rw-r--r-- | test/SemaObjC/property-13.m | 2 | ||||
-rw-r--r-- | test/SemaObjC/property-not-lvalue.m | 14 | ||||
-rw-r--r-- | test/SemaObjC/protocol-warn.m | 55 |
9 files changed, 177 insertions, 5 deletions
diff --git a/test/SemaObjC/cocoa.m b/test/SemaObjC/cocoa.m index 9c92731..a8cfb72 100644 --- a/test/SemaObjC/cocoa.m +++ b/test/SemaObjC/cocoa.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -target-cpu pentium4 %s -print-stats +// RUN: %clang -arch x86_64 %s -fsyntax-only -Xclang -print-stats #ifdef __APPLE__ #include <Cocoa/Cocoa.h> #endif diff --git a/test/SemaObjC/default-synthesize.m b/test/SemaObjC/default-synthesize.m new file mode 100644 index 0000000..be2397b --- /dev/null +++ b/test/SemaObjC/default-synthesize.m @@ -0,0 +1,81 @@ +// RUN: %clang_cc1 -fsyntax-only -fobjc-nonfragile-abi2 -verify %s + +@interface NSString @end + +@interface NSObject @end + +@interface SynthItAll +@property int howMany; +@property (retain) NSString* what; +@end + +@implementation SynthItAll +//@synthesize howMany, what; +@end + + +@interface SynthSetter : NSObject +@property (nonatomic) int howMany; // REM: nonatomic to avoid warnings about only implementing one of the pair +@property (nonatomic, retain) NSString* what; +@end + +@implementation SynthSetter +//@synthesize howMany, what; + +- (int) howMany { + return howMany; +} +// - (void) setHowMany: (int) value + +- (NSString*) what { + return what; +} +// - (void) setWhat: (NSString*) value +@end + + +@interface SynthGetter : NSObject +@property (nonatomic) int howMany; // REM: nonatomic to avoid warnings about only implementing one of the pair +@property (nonatomic, retain) NSString* what; +@end + +@implementation SynthGetter +//@synthesize howMany, what; + +// - (int) howMany +- (void) setHowMany: (int) value { + howMany = value; +} + +// - (NSString*) what +- (void) setWhat: (NSString*) value { + if (what != value) { + } +} +@end + + +@interface SynthNone : NSObject +@property int howMany; +@property (retain) NSString* what; +@end + +@implementation SynthNone +//@synthesize howMany, what; // REM: Redundant anyway + +- (int) howMany { + return howMany; +} +- (void) setHowMany: (int) value { + howMany = value; +} + +- (NSString*) what { + return what; +} +- (void) setWhat: (NSString*) value { + if (what != value) { + } +} +@end + diff --git a/test/SemaObjC/duplicate-property-class-extension.m b/test/SemaObjC/duplicate-property-class-extension.m new file mode 100644 index 0000000..bdf4786c --- /dev/null +++ b/test/SemaObjC/duplicate-property-class-extension.m @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +@interface Foo +@property (readonly) char foo; +@end + +@interface Foo () +@property (readwrite) char foo; // expected-note {{property declared here}} +@end + +@interface Foo () +@property (readwrite) char foo; // expected-error {{property has a previous declaration}} +@end diff --git a/test/SemaObjC/exprs.m b/test/SemaObjC/exprs.m index f4424f5..33b1444 100644 --- a/test/SemaObjC/exprs.m +++ b/test/SemaObjC/exprs.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -fsyntax-only -verify +// RUN: %clang_cc1 %s -fsyntax-only -verify -Wno-unreachable-code // rdar://6597252 Class test1(Class X) { diff --git a/test/SemaObjC/format-strings-objc.m b/test/SemaObjC/format-strings-objc.m index e7550a7..7abfe96 100644 --- a/test/SemaObjC/format-strings-objc.m +++ b/test/SemaObjC/format-strings-objc.m @@ -29,15 +29,24 @@ extern void *_NSConstantStringClassReference; typedef const struct __CFString * CFStringRef; extern void CFStringCreateWithFormat(CFStringRef format, ...) __attribute__((format(CFString, 1, 2))); +int printf(const char * restrict, ...) ; + //===----------------------------------------------------------------------===// // Test cases. //===----------------------------------------------------------------------===// void check_nslog(unsigned k) { NSLog(@"%d%%", k); // no-warning - NSLog(@"%s%lb%d", "unix", 10,20); // expected-warning {{lid conversion '%lb'}} + NSLog(@"%s%lb%d", "unix", 10,20); // expected-warning {{invalid conversion specifier 'b'}} } // Check type validation extern void NSLog2(int format, ...) __attribute__((format(__NSString__, 1, 2))); // expected-error {{format argument not an NSString}} extern void CFStringCreateWithFormat2(int *format, ...) __attribute__((format(CFString, 1, 2))); // expected-error {{format argument not a CFString}} + +// <rdar://problem/7068334> - Catch use of long long with int arguments. +void rdar_7068334() { + long long test = 500; + printf("%i ",test); // expected-warning{{conversion specifies type 'int' but the argument has type 'long long'}} + NSLog(@"%i ",test); // expected-warning{{conversion specifies type 'int' but the argument has type 'long long'}} +} diff --git a/test/SemaObjC/method-arg-decay.m b/test/SemaObjC/method-arg-decay.m index 82bdc6d..f600029 100644 --- a/test/SemaObjC/method-arg-decay.m +++ b/test/SemaObjC/method-arg-decay.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -checker-cfref -verify %s +// RUN: %clang_cc1 -analyzer-check-objc-mem -verify %s typedef signed char BOOL; typedef int NSInteger; typedef unsigned int NSUInteger; diff --git a/test/SemaObjC/property-13.m b/test/SemaObjC/property-13.m index f34ec56..6d56dab 100644 --- a/test/SemaObjC/property-13.m +++ b/test/SemaObjC/property-13.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify %s -Wno-unreachable-code @interface NSObject + alloc; diff --git a/test/SemaObjC/property-not-lvalue.m b/test/SemaObjC/property-not-lvalue.m index f1bda09..473ef86 100644 --- a/test/SemaObjC/property-not-lvalue.m +++ b/test/SemaObjC/property-not-lvalue.m @@ -18,3 +18,17 @@ void foo() { f.size.width = 2.2; // expected-error {{cannot assign to a sub-structure of an ivar using property assignment syntax}} f.size.inner.dim = 200; // expected-error {{cannot assign to a sub-structure of an ivar using property assignment syntax}} } + +// radar 7628953 + +@interface Gorf { +} +- (NSSize)size; +@end + +@implementation Gorf +- (void)MyView_sharedInit { + self.size.width = 2.2; // expected-error {{cannot assign to a sub-structure returned via a getter using property assignment syntax}} +} +- (NSSize)size {} +@end diff --git a/test/SemaObjC/protocol-warn.m b/test/SemaObjC/protocol-warn.m new file mode 100644 index 0000000..d0c51e3 --- /dev/null +++ b/test/SemaObjC/protocol-warn.m @@ -0,0 +1,55 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// radar 7638810 + +@protocol NSObject @end + +@interface NSObject <NSObject> @end + +@interface UIResponder : NSObject +@end + +@implementation UIResponder +@end + +@interface UIView : UIResponder +@end + +@implementation UIView +@end + +@interface UIWebTiledView : UIView +@end + +@implementation UIWebTiledView +@end + +@interface UIWebDocumentView : UIWebTiledView +@end + +@implementation UIWebDocumentView +@end + +@interface UIWebBrowserView : UIWebDocumentView +@end + +@implementation UIWebBrowserView +@end + +@interface UIPDFView : UIView +@end + +@implementation UIPDFView +@end + +@interface UIWebPDFView : UIPDFView +@end + +@implementation UIWebPDFView +@end + +UIWebPDFView *getView() +{ + UIWebBrowserView *browserView; + UIWebPDFView *pdfView; + return pdfView ? pdfView : browserView; // expected-warning {{incompatible pointer types returning 'UIView<NSObject> *', expected 'UIWebPDFView *'}} +} |