summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/ASTContext.cpp6
-rw-r--r--clang/lib/CodeGen/CGBlocks.cpp15
2 files changed, 11 insertions, 10 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index cede0e55639..bdc7e4484c2 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -2701,9 +2701,9 @@ bool ASTContext::typesAreBlockCompatible(QualType lhs, QualType rhs) {
const FunctionType *rbase = rhs->getAsFunctionType();
const FunctionProtoType *lproto = dyn_cast<FunctionProtoType>(lbase);
const FunctionProtoType *rproto = dyn_cast<FunctionProtoType>(rbase);
- if (lproto && rproto)
- return !mergeTypes(lhs, rhs).isNull();
- return false;
+ if (lproto && rproto == 0)
+ return false;
+ return !mergeTypes(lhs, rhs).isNull();
}
/// areCompatVectorTypes - Return true if the two specified vector types are
diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp
index 16e926ba643..c05d3235dd8 100644
--- a/clang/lib/CodeGen/CGBlocks.cpp
+++ b/clang/lib/CodeGen/CGBlocks.cpp
@@ -412,18 +412,19 @@ const llvm::Type *BlockModule::getGenericExtendedBlockLiteralType() {
/// function type for the block, including the first block literal argument.
static QualType getBlockFunctionType(ASTContext &Ctx,
const BlockPointerType *BPT) {
- const FunctionProtoType *FTy = cast<FunctionProtoType>(BPT->getPointeeType());
+ const FunctionProtoType *FTy = dyn_cast<FunctionProtoType>(BPT->getPointeeType());
+ const clang::QualType ResType = BPT->getPointeeType()->getAsFunctionType()->getResultType();
llvm::SmallVector<QualType, 8> Types;
Types.push_back(Ctx.getPointerType(Ctx.VoidTy));
- for (FunctionProtoType::arg_type_iterator i = FTy->arg_type_begin(),
- e = FTy->arg_type_end(); i != e; ++i)
- Types.push_back(*i);
+ if (FTy)
+ for (FunctionProtoType::arg_type_iterator i = FTy->arg_type_begin(),
+ e = FTy->arg_type_end(); i != e; ++i)
+ Types.push_back(*i);
- return Ctx.getFunctionType(FTy->getResultType(),
- &Types[0], Types.size(),
- FTy->isVariadic(), 0);
+ return Ctx.getFunctionType(ResType, &Types[0], Types.size(),
+ FTy && FTy->isVariadic(), 0);
}
RValue CodeGenFunction::EmitBlockCallExpr(const CallExpr* E) {
OpenPOWER on IntegriCloud