]> granicus.if.org Git - clang/commitdiff
Fixed a bug reported by Chris, involving assiging 0 to a qualified object type.
authorFariborz Jahanian <fjahanian@apple.com>
Thu, 3 Jan 2008 18:46:52 +0000 (18:46 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Thu, 3 Jan 2008 18:46:52 +0000 (18:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45542 91177308-0d34-0410-b5e6-96231b3b80d8

Sema/SemaExpr.cpp
test/Sema/objc-comptypes-8.m [new file with mode: 0644]

index 0778bbd108d01e2104f319a13b2b9c868bd32886..6c9d8ba5ea09bd53836471c3d69576aa7a7cc8c6 100644 (file)
@@ -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 (file)
index 0000000..c22e88c
--- /dev/null
@@ -0,0 +1,12 @@
+// RUN: clang -fsyntax-only %s
+
+@protocol MyProtocol
+@end
+
+id<MyProtocol> obj_p = 0;
+
+int main()
+{
+  obj_p = 0;
+}
+