]> granicus.if.org Git - clang/commitdiff
Fix <rdar://problem/6316324> [sema] spurious warning on comparison of qualified id.
authorSteve Naroff <snaroff@apple.com>
Mon, 17 Nov 2008 19:49:16 +0000 (19:49 +0000)
committerSteve Naroff <snaroff@apple.com>
Mon, 17 Nov 2008 19:49:16 +0000 (19:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59459 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/SemaObjC/compare-qualified-id.m

index 686a8f40083e8ac797ae3f219b99bea697afad0b..a5066a8cd7f430f0b3af63f9cc8952927a17ad0b 100644 (file)
@@ -2182,7 +2182,15 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation loc,
 
   if ((lType->isObjCQualifiedIdType() || rType->isObjCQualifiedIdType())) {
     if (lType->isPointerType() || rType->isPointerType()) {
-      if (!Context.typesAreCompatible(lType, rType)) {
+      const PointerType *LPT = lType->getAsPointerType();
+      const PointerType *RPT = rType->getAsPointerType();
+      bool LPtrToVoid = LPT ? 
+        Context.getCanonicalType(LPT->getPointeeType())->isVoidType() : false;
+      bool RPtrToVoid = RPT ? 
+        Context.getCanonicalType(RPT->getPointeeType())->isVoidType() : false;
+        
+      if (!LPtrToVoid && !RPtrToVoid &&
+          !Context.typesAreCompatible(lType, rType)) {
         Diag(loc, diag::ext_typecheck_comparison_of_distinct_pointers,
              lType.getAsString(), rType.getAsString(),
              lex->getSourceRange(), rex->getSourceRange());
index 91640669aea00b0942842fdbb6b7f9823dbfbb05..1bcbd0edc0657e1c144c8c23d74a8916025d0614 100644 (file)
@@ -26,7 +26,7 @@ extern NSString * const NSTaskDidTerminateNotification;
 @implementation XCPropertyExpansionContext
 - (NSString *)expandedValueForProperty:(NSString *)property {
   id <XCPropertyValues> cachedValueNode = [_propNamesToPropValuesCache objectForKey:property]; // expected-warning {{method '-objectForKey:' not found (return type defaults to 'id')}}
-  if (cachedValueNode == ((void *)0)) { } // expected-warning {{comparison of distinct pointer types ('id<XCPropertyValues>' and 'void *')}}
+  if (cachedValueNode == ((void *)0)) { }
   NSString * expandedValue = [cachedValueNode evaluateAsStringInContext:self withNestingState:((void *)0)];
   return expandedValue;
 }