summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/AST')
-rw-r--r--clang/lib/AST/ASTContext.cpp14
-rw-r--r--clang/lib/AST/Expr.cpp8
2 files changed, 21 insertions, 1 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 4caf16c4b09..62364bab318 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -1781,7 +1781,19 @@ bool ASTContext::isObjCObjectPointerType(QualType Ty) const {
//===----------------------------------------------------------------------===//
/// typesAreBlockCompatible - This routine is called when comparing two
-/// block types. Types must be strictly compatible here.
+/// block types. Types must be strictly compatible here. For example,
+/// C unfortunately doesn't produce an error for the following:
+///
+/// int (*emptyArgFunc)();
+/// int (*intArgList)(int) = emptyArgFunc;
+///
+/// For blocks, we will produce an error for the following (similar to C++):
+///
+/// int (^emptyArgBlock)();
+/// int (^intArgBlock)(int) = emptyArgBlock;
+///
+/// FIXME: When the dust settles on this integration, fold this into mergeTypes.
+///
bool ASTContext::typesAreBlockCompatible(QualType lhs, QualType rhs) {
if (lhs.getCVRQualifiers() != rhs.getCVRQualifiers())
return false;
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index f72ff4f6ca9..9452db4677a 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -423,6 +423,12 @@ Expr::isLvalueResult Expr::isLvalue(ASTContext &Ctx) const {
return LV_Valid;
break;
}
+ case BlockDeclRefExprClass: {
+ const BlockDeclRefExpr *BDR = cast<BlockDeclRefExpr>(this);
+ if (BDR->isByRef() && isa<VarDecl>(BDR->getDecl()))
+ return LV_Valid;
+ break;
+ }
case MemberExprClass: { // C99 6.5.2.3p4
const MemberExpr *m = cast<MemberExpr>(this);
return m->isArrow() ? LV_Valid : m->getBase()->isLvalue(Ctx);
@@ -1453,4 +1459,6 @@ Stmt::child_iterator BlockExprExpr::child_begin() {
Stmt::child_iterator BlockExprExpr::child_end() {
return reinterpret_cast<Stmt**>(&BodyExpr)+1;
}
+Stmt::child_iterator BlockDeclRefExpr::child_begin(){return child_iterator();}
+Stmt::child_iterator BlockDeclRefExpr::child_end() { return child_iterator();}
OpenPOWER on IntegriCloud