[cfe-commits] r59459 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/SemaObjC/compare-qualified-id.m
Steve Naroff
snaroff at apple.com
Mon Nov 17 11:49:18 PST 2008
Author: snaroff
Date: Mon Nov 17 13:49:16 2008
New Revision: 59459
URL: http://llvm.org/viewvc/llvm-project?rev=59459&view=rev
Log:
Fix <rdar://problem/6316324> [sema] spurious warning on comparison of qualified id.
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaObjC/compare-qualified-id.m
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=59459&r1=59458&r2=59459&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Nov 17 13:49:16 2008
@@ -2182,7 +2182,15 @@
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());
Modified: cfe/trunk/test/SemaObjC/compare-qualified-id.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/compare-qualified-id.m?rev=59459&r1=59458&r2=59459&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/compare-qualified-id.m (original)
+++ cfe/trunk/test/SemaObjC/compare-qualified-id.m Mon Nov 17 13:49:16 2008
@@ -26,7 +26,7 @@
@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;
}
More information about the cfe-commits
mailing list