Strip paren expressions when trying to diagnose "cast as lvalue"

extension.

llvm-svn: 69100
This commit is contained in:
Daniel Dunbar 2009-04-14 23:26:44 +00:00
parent 184e65d363
commit 9351c02bef
2 changed files with 2 additions and 1 deletions

View File

@ -775,7 +775,7 @@ Expr::isModifiableLvalueResult Expr::isModifiableLvalue(ASTContext &Ctx) const {
// 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 (const CStyleCastExpr *CE = dyn_cast<CStyleCastExpr>(IgnoreParens()))
if (CE->getSubExpr()->isLvalue(Ctx) == LV_Valid)
return MLV_LValueCast;
return MLV_InvalidExpression;

View File

@ -34,6 +34,7 @@ void test4() {
// rdar://6319320
void test5(int *X, float *P) {
(float*)X = P; // expected-error {{assignment to cast is illegal, lvalue casts are not supported}}
((float*)X) = P; // expected-error {{assignment to cast is illegal, lvalue casts are not supported}}
}
void test6() {