aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Sema/SemaExpr.cpp3
-rw-r--r--test/Sema/objc-comptypes-8.m12
2 files changed, 14 insertions, 1 deletions
diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp
index 0778bbd108..6c9d8ba5ea 100644
--- a/Sema/SemaExpr.cpp
+++ b/Sema/SemaExpr.cpp
@@ -1174,7 +1174,8 @@ Sema::AssignmentCheckResult
Sema::CheckSingleAssignmentConstraints(QualType lhsType, Expr *&rExpr) {
// C99 6.5.16.1p1: the left operand is a pointer and the right is
// a null pointer constant.
- if (lhsType->isPointerType() && rExpr->isNullPointerConstant(Context)) {
+ if ((lhsType->isPointerType() || lhsType->isObjcQualifiedIdType())
+ && rExpr->isNullPointerConstant(Context)) {
promoteExprToType(rExpr, lhsType);
return Compatible;
}
diff --git a/test/Sema/objc-comptypes-8.m b/test/Sema/objc-comptypes-8.m
new file mode 100644
index 0000000000..c22e88c880
--- /dev/null
+++ b/test/Sema/objc-comptypes-8.m
@@ -0,0 +1,12 @@
+// RUN: clang -fsyntax-only %s
+
+@protocol MyProtocol
+@end
+
+id<MyProtocol> obj_p = 0;
+
+int main()
+{
+ obj_p = 0;
+}
+