aboutsummaryrefslogtreecommitdiff
path: root/test/SemaObjC/format-strings-objc.m
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-07-26 00:57:24 +0000
committerChris Lattner <sabre@nondot.org>2008-07-26 00:57:24 +0000
commit6ac6ddc861ccc42f3025c4209b7c031bcd8f43f9 (patch)
treea2654e6a3604cc456975e7183f4a31abb89f90d6 /test/SemaObjC/format-strings-objc.m
parent62f5f7ffad57e0c2af2b308af3735351505937cb (diff)
move all objc sema tests into a new SemaObjC directory. Next step is to
remove the objc- prefix from the tests that use it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54084 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaObjC/format-strings-objc.m')
-rw-r--r--test/SemaObjC/format-strings-objc.m36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/SemaObjC/format-strings-objc.m b/test/SemaObjC/format-strings-objc.m
new file mode 100644
index 0000000000..bdf12082a7
--- /dev/null
+++ b/test/SemaObjC/format-strings-objc.m
@@ -0,0 +1,36 @@
+// RUN: clang -fsyntax-only -verify %s
+
+//===----------------------------------------------------------------------===//
+// The following code is reduced using delta-debugging from
+// Foundation.h (Mac OS X).
+//
+// It includes the basic definitions for the test cases below.
+// Not including Foundation.h directly makes this test case both svelt and
+// portable to non-Mac platforms.
+//===----------------------------------------------------------------------===//
+
+typedef signed char BOOL;
+typedef unsigned int NSUInteger;
+@class NSString, Protocol;
+extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2)));
+typedef struct _NSZone NSZone;
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+@protocol NSObject - (BOOL)isEqual:(id)object; @end
+@protocol NSCopying - (id)copyWithZone:(NSZone *)zone; @end
+@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone; @end
+@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; @end
+@interface NSObject <NSObject> {} @end
+typedef float CGFloat;
+@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding> - (NSUInteger)length; @end
+@interface NSSimpleCString : NSString {} @end
+@interface NSConstantString : NSSimpleCString @end
+extern void *_NSConstantStringClassReference;
+
+//===----------------------------------------------------------------------===//
+// Test cases.
+//===----------------------------------------------------------------------===//
+
+void check_nslog(unsigned k) {
+ NSLog(@"%d%%", k); // no-warning
+ NSLog(@"%s%lb%d", "unix", 10,20); // expected-warning {{lid conversion '%lb'}}
+}