]> granicus.if.org Git - clang/commitdiff
Patch to allow matching 0 with an objective-c pointer type
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 8 Dec 2009 20:04:24 +0000 (20:04 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 8 Dec 2009 20:04:24 +0000 (20:04 +0000)
in objective-c++ mode. Fixes radar 7443165

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90874 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExprCXX.cpp
test/SemaObjCXX/composite-objc-pointertype.mm [new file with mode: 0644]

index 567b488caf0ab82e940bd0590e9bbb4822a33cc4..be33c067657da5cc09d100e05d2ab0dfc5b608fb 100644 (file)
@@ -1881,8 +1881,8 @@ QualType Sema::FindCompositePointerType(Expr *&E1, Expr *&E2) {
   assert(getLangOptions().CPlusPlus && "This function assumes C++");
   QualType T1 = E1->getType(), T2 = E2->getType();
 
-  if (!T1->isPointerType() && !T1->isMemberPointerType() &&
-      !T2->isPointerType() && !T2->isMemberPointerType())
+  if (!T1->isAnyPointerType() && !T1->isMemberPointerType() &&
+      !T2->isAnyPointerType() && !T2->isMemberPointerType())
    return QualType();
 
   // C++0x 5.9p2
diff --git a/test/SemaObjCXX/composite-objc-pointertype.mm b/test/SemaObjCXX/composite-objc-pointertype.mm
new file mode 100644 (file)
index 0000000..8bbfa07
--- /dev/null
@@ -0,0 +1,18 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+@interface Foo
+@end
+
+@implementation Foo
+- (id)test {
+        id bar;
+    Class cl;
+    Foo *f;
+
+    (void)((bar!= 0) ? bar : 0);
+    (void)((cl != 0) ? cl : 0);
+    (void)((f != 0) ? 0 : f);
+    return (0 == 1) ? 0 : bar;
+}
+@end
+