From 68e167df8e7ace73965fe501605a0d5196b51ce0 Mon Sep 17 00:00:00 2001 From: Steve Naroff Date: Wed, 10 Dec 2008 17:49:55 +0000 Subject: Fix Bogus block type compatibility warning. llvm-svn: 60842 --- clang/lib/AST/ASTContext.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'clang/lib/AST') diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 35647cf02aa..ba61332a44f 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/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(lbase); + const FunctionTypeProto *rproto = dyn_cast(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); -- cgit v1.2.3