aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/Expr.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-11-17 19:51:54 +0000
committerChris Lattner <sabre@nondot.org>2008-11-17 19:51:54 +0000
commitca354faa7e9b99af17070c82b9662a5fca76422c (patch)
tree381438fabd51dbd86619c85fae784f535ee1ca21 /lib/AST/Expr.cpp
parenta8069f102f1e7b67927be2e500ee1518e25aafbb (diff)
Implement rdar://6319320: give a good diagnostic for cases where people
are trying to use the old GCC "casts as lvalue" extension. We don't and will hopefully never support this. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59460 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Expr.cpp')
-rw-r--r--lib/AST/Expr.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index 29d9a11de7..d2c9ea9573 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -495,7 +495,15 @@ Expr::isModifiableLvalueResult Expr::isModifiableLvalue(ASTContext &Ctx) const {
case LV_NotObjectType: return MLV_NotObjectType;
case LV_IncompleteVoidType: return MLV_IncompleteVoidType;
case LV_DuplicateVectorComponents: return MLV_DuplicateVectorComponents;
- case LV_InvalidExpression: return MLV_InvalidExpression;
+ case LV_InvalidExpression:
+ // If the top level is a C-style cast, and the subexpression is a valid
+ // lvalue, then this is probably a use of the old-school "cast as lvalue"
+ // GCC extension. We don't support it, but we want to produce good
+ // diagnostics when it happens so that the user knows why.
+ if (const CStyleCastExpr *CE = dyn_cast<CStyleCastExpr>(this))
+ if (CE->getSubExpr()->isLvalue(Ctx) == LV_Valid)
+ return MLV_LValueCast;
+ return MLV_InvalidExpression;
}
QualType CT = Ctx.getCanonicalType(getType());