aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2012-02-23 22:51:36 +0000
committerFariborz Jahanian <fjahanian@apple.com>2012-02-23 22:51:36 +0000
commitf64bc202a2bcdf7b10f418ad52aaa7366c8ffef9 (patch)
treec62e51d37baf9aaa9b50ed0961de1bb111f4438d /test
parent9428772f16e379bcad35254251f96e3d1077c730 (diff)
objective-c++: Type of an objc string literal is NSString, not 'id'.
// rdar://10907410 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151296 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m2
-rw-r--r--test/PCH/objc_exprs.m2
-rw-r--r--test/SemaObjC/NSString-type.m10
-rw-r--r--test/SemaObjCXX/NSString-type.mm10
4 files changed, 22 insertions, 2 deletions
diff --git a/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m b/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m
index eba72bac9f..96bc7a9b3e 100644
--- a/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m
+++ b/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m
@@ -48,7 +48,7 @@ void createFoo4() {
}
void createFoo5() {
- MyClass *obj = @"";
+ MyClass *obj = (id)@"";
double d = [obj doubleM]; // no-warning
}
diff --git a/test/PCH/objc_exprs.m b/test/PCH/objc_exprs.m
index c37968b7b9..1f971e7941 100644
--- a/test/PCH/objc_exprs.m
+++ b/test/PCH/objc_exprs.m
@@ -6,7 +6,7 @@
// RUN: %clang_cc1 -fblocks -include-pch %t -fsyntax-only -verify %s
// Expressions
-int *A1 = (objc_string)0; // expected-warning {{aka 'id'}}
+int *A1 = (objc_string)0; // expected-warning {{aka 'NSString *'}}
char A2 = (objc_encode){}; // expected-error {{not a compile-time constant}} \
expected-warning {{char [2]}}
diff --git a/test/SemaObjC/NSString-type.m b/test/SemaObjC/NSString-type.m
new file mode 100644
index 0000000000..3b4857ae0e
--- /dev/null
+++ b/test/SemaObjC/NSString-type.m
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fblocks -fsyntax-only -verify %s
+// rdar://10907410
+
+void test(id pid, Class pclass) {
+ void (^block)(void) = @"help"; // expected-error {{initializing 'void (^)(void)' with an expression of incompatible type 'NSString *'}}
+ void (^block1)(void) = pid;
+ void (^block2)(void) = @"help"; // expected-error {{initializing 'void (^)(void)' with an expression of incompatible type 'NSString *'}}
+ void (^block3)(void) = @"help"; // expected-error {{initializing 'void (^)(void)' with an expression of incompatible type 'NSString *'}}
+}
+
diff --git a/test/SemaObjCXX/NSString-type.mm b/test/SemaObjCXX/NSString-type.mm
new file mode 100644
index 0000000000..10338667b7
--- /dev/null
+++ b/test/SemaObjCXX/NSString-type.mm
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fblocks -fsyntax-only -verify %s
+// rdar://10907410
+
+void test(id pid, Class pclass) {
+ void (^block)(void) = @"help"; // expected-error {{cannot initialize a variable of type 'void (^)()' with an rvalue of type 'NSString *'}}
+ void (^block1)(void) = pid;
+ void (^block2)(void) = @"help"; // expected-error {{cannot initialize a variable of type 'void (^)()' with an rvalue of type 'NSString *'}}
+ void (^block3)(void) = @"help"; // expected-error {{cannot initialize a variable of type 'void (^)()' with an rvalue of type 'NSString *'}}
+}
+