aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/objc.dg/const-cfstring-2.m
diff options
context:
space:
mode:
authorGeoffrey Keating <geoffk@apple.com>2005-03-04 20:17:11 +0000
committerGeoffrey Keating <geoffk@apple.com>2005-03-04 20:17:11 +0000
commit8fb36317f1b3cd85655af61504bb31bf33364dd1 (patch)
tree0eb2bbc4dad75d90f41114820f3ee7088d24961c /gcc/testsuite/objc.dg/const-cfstring-2.m
parente7205ceb9c1707750c7ea129d8087eb1a9c685dc (diff)
Merge changes between apple-ppc-merge-20041026 and apple-gcc-4049
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/apple-local-200502-branch@95897 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/objc.dg/const-cfstring-2.m')
-rw-r--r--gcc/testsuite/objc.dg/const-cfstring-2.m26
1 files changed, 26 insertions, 0 deletions
diff --git a/gcc/testsuite/objc.dg/const-cfstring-2.m b/gcc/testsuite/objc.dg/const-cfstring-2.m
new file mode 100644
index 00000000000..57b8d95a7d4
--- /dev/null
+++ b/gcc/testsuite/objc.dg/const-cfstring-2.m
@@ -0,0 +1,26 @@
+/* APPLE LOCAL file constant CFStrings */
+/* Test the -Wnonportable-cfstrings option, which should give
+ warnings if non-ASCII characters are embedded in constant
+ CFStrings. This will only work on MacOS X 10.2 and later. */
+/* Developed by Ziemowit Laski <zlaski@apple.com>. */
+
+/* { dg-do compile { target *-*-darwin* } } */
+/* { dg-options "-fconstant-cfstrings -Wnonportable-cfstrings" } */
+
+#import <Foundation/NSString.h>
+#import <CoreFoundation/CFString.h>
+
+#ifndef __CONSTANT_CFSTRINGS__
+#error The -fconstant-cfstrings option is not functioning properly
+#endif
+
+void foo(void) {
+ NSString *s1 = @"Compile-time string literal";
+ CFStringRef s2 = CFSTR("Compile-time string literal");
+ NSString *s3 = @"Non-ASCII literal - \222"; /* { dg-warning "non-ASCII character in CFString literal" } */
+ CFStringRef s4 = CFSTR("\222 - Non-ASCII literal"); /* { dg-warning "non-ASCII character in CFString literal" } */
+ CFStringRef s5 = CFSTR("Non-ASCII (\222) literal"); /* { dg-warning "non-ASCII character in CFString literal" } */
+ NSString *s6 = @"\0Embedded NUL"; /* { dg-warning "embedded NUL in CFString literal" } */
+ CFStringRef s7 = CFSTR("Embedded \0NUL"); /* { dg-warning "embedded NUL in CFString literal" } */
+ CFStringRef s8 = CFSTR("Embedded NUL\0"); /* { dg-warning "embedded NUL in CFString literal" } */
+}