This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[C++ PATCH] Remove unneeded code now we don't have casts as lvalue extension


Hi,
  As I mentioned in 
http://gcc.gnu.org/ml/gcc-patches/2007-05/msg00382.html, we have some dead 
code due to removal of the extension of casts as lvalues.  This patch 
removes the code that used to handle increments/decrements for casts as 
lvalues.

Before this patch for the following code:
typedef char * charptr;
typedef __SIZE_TYPE__ size_t;
char c[]={'A','B','C','D'};
int i=size_t(&c);
int *pp=&i;
void foo() { }
int main()
{
 charptr(*pp)++;        // { dg-warning "" } 
 return 0;
}
------------------- cut ------------------
We would the following error:
gcc/gcc/testsuite/g++.old-deja/g++.mike/warn1.C: In function 'int main()':
gcc/gcc/testsuite/g++.old-deja/g++.mike/warn1.C:12: error: lvalue required 
as left operand of assignment

Which is missing leading at best because there is no assignment.  With 
-pedantic we get an extra error:
gcc/gcc/testsuite/g++.old-deja/g++.mike/warn1.C:12: error: cast to 
non-reference type used as lvalue

Which is correct but we still get the other error message.
After this patch, we just get one error message:
gcc/gcc/testsuite/g++.old-deja/g++.mike/warn1.C: In function 'int main()':
gcc/gcc/testsuite/g++.old-deja/g++.mike/warn1.C:12: error: lvalue required 
as increment operand

Which is so much better and explains what is going on, rather than being 
so weird.

OK? Bootstrapped and tested on i686-linux-gnu with no regressions.

Thanks,
Andrew Pinsi

        * typeck.c (build_unary_op): Remove code that used to
        handle non lvalue increments/decrements.


Attachment: removedeadcode.diff.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]