diff options
| -rw-r--r-- | clang/Sema/SemaExpr.cpp | 3 | ||||
| -rw-r--r-- | clang/test/Sema/objc-comptypes-8.m | 12 |
2 files changed, 14 insertions, 1 deletions
diff --git a/clang/Sema/SemaExpr.cpp b/clang/Sema/SemaExpr.cpp index 0778bbd108d..6c9d8ba5ea0 100644 --- a/clang/Sema/SemaExpr.cpp +++ b/clang/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/clang/test/Sema/objc-comptypes-8.m b/clang/test/Sema/objc-comptypes-8.m new file mode 100644 index 00000000000..c22e88c8805 --- /dev/null +++ b/clang/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; +} + |

