aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2008-12-10 17:49:55 +0000
committerSteve Naroff <snaroff@apple.com>2008-12-10 17:49:55 +0000
commitc0febd58f5cbf4a93fd12f461863564dba0af76d (patch)
treefd4e05bcf41a5f0a88aee69376373b02d303deb7 /lib
parente58ee0ca7cfad6ee75a088e7a6a090526e18da50 (diff)
Fix <rdar://problem/6418623> Bogus block type compatibility warning.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60842 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/AST/ASTContext.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index 35647cf02a..ba61332a44 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -1920,7 +1920,13 @@ bool ASTContext::isObjCObjectPointerType(QualType Ty) const {
/// FIXME: When the dust settles on this integration, fold this into mergeTypes.
///
bool ASTContext::typesAreBlockCompatible(QualType lhs, QualType rhs) {
- return getCanonicalType(lhs) == getCanonicalType(rhs);
+ const FunctionType *lbase = lhs->getAsFunctionType();
+ const FunctionType *rbase = rhs->getAsFunctionType();
+ const FunctionTypeProto *lproto = dyn_cast<FunctionTypeProto>(lbase);
+ const FunctionTypeProto *rproto = dyn_cast<FunctionTypeProto>(rbase);
+ if (lproto && rproto)
+ return !mergeTypes(lhs, rhs).isNull();
+ return false;
}
/// areCompatVectorTypes - Return true if the two specified vector types are
@@ -2179,6 +2185,19 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) {
return RHS;
return getPointerType(ResultType);
}
+ case Type::BlockPointer:
+ {
+ // Merge two block pointer types, while trying to preserve typedef info
+ QualType LHSPointee = LHS->getAsBlockPointerType()->getPointeeType();
+ QualType RHSPointee = RHS->getAsBlockPointerType()->getPointeeType();
+ QualType ResultType = mergeTypes(LHSPointee, RHSPointee);
+ if (ResultType.isNull()) return QualType();
+ if (getCanonicalType(LHSPointee) == getCanonicalType(ResultType))
+ return LHS;
+ if (getCanonicalType(RHSPointee) == getCanonicalType(ResultType))
+ return RHS;
+ return getBlockPointerType(ResultType);
+ }
case Type::ConstantArray:
{
const ConstantArrayType* LCAT = getAsConstantArrayType(LHS);