]> granicus.if.org Git - clang/commitdiff
Strip paren expressions when trying to diagnose "cast as lvalue"
authorDaniel Dunbar <daniel@zuster.org>
Tue, 14 Apr 2009 23:26:44 +0000 (23:26 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 14 Apr 2009 23:26:44 +0000 (23:26 +0000)
extension.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69100 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/Expr.cpp
test/Sema/exprs.c

index 08ab5440b16fa7212100464b86ee2575960e3bd8..973e662b25f63d08caa0542549053b0a62010b8c 100644 (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;
index 9db8c9248de38894e6039e1d95e3ecf2e5a87441..617eaa086cf433861a300520a7c457814938c703 100644 (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() {