diff options
author | Marek Polacek <polacek@redhat.com> | 2015-06-04 08:17:45 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2015-06-04 08:17:45 +0000 |
commit | 9482b620d208237366e9d052918757cc5c17f519 (patch) | |
tree | 0ae98c0e9dd440292c437f415548e76661933de5 /gcc/c | |
parent | 0b98bb4e15faed6a72fa9a0f27a6e973cb8e5e70 (diff) | |
download | gcc-9482b620d208237366e9d052918757cc5c17f519.zip gcc-9482b620d208237366e9d052918757cc5c17f519.tar.gz gcc-9482b620d208237366e9d052918757cc5c17f519.tar.bz2 |
re PR c/66341 (Some casts wrongly produce a lvalue)
PR c/66341
* c-typeck.c (build_c_cast): Wrap VALUE into NON_LVALUE_EXPR if
it is a lvalue.
* gcc.dg/lvalue-8.c: New test.
From-SVN: r224115
Diffstat (limited to 'gcc/c')
-rw-r--r-- | gcc/c/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c/c-typeck.c | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 69344bb..d6be87f 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2015-06-04 Marek Polacek <polacek@redhat.com> + + PR c/66341 + * c-typeck.c (build_c_cast): Wrap VALUE into NON_LVALUE_EXPR if + it is a lvalue. + 2015-06-03 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org> * c-decl.c (warn_cxx_compat_finish_struct): New parameters code, record_loc. diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index f55d4c6..6b313f3 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -5195,7 +5195,7 @@ build_c_cast (location_t loc, tree type, tree expr) } /* Don't let a cast be an lvalue. */ - if (value == expr) + if (lvalue_p (value)) value = non_lvalue_loc (loc, value); /* Don't allow the results of casting to floating-point or complex |