Fixed a bug reported by Chris, involving assiging 0 to a qualified object type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45542 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp
index 0778bbd..6c9d8ba 100644
--- a/Sema/SemaExpr.cpp
+++ b/Sema/SemaExpr.cpp
@@ -1174,7 +1174,8 @@
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 0000000..c22e88c
--- /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;
+}
+