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]

Re: [C and C++ PATCH] Properly diagnose ++ or -- on non-lvalue (PR c++/37561)


On Fri, 14 Nov 2008, Jakub Jelinek wrote:

> Both C and C++ FE diagnose ++ or -- on non-lvalue only in some cases,
> but don't diagnose if an lvalue is casted to a wider integer type.
> 
> The problem is in a get_unwidened call, IMHO a left over from the days when
> GCC supported the cast-as-lvalue extension.  ATM get_unwidened does
> something only for NOP_EXPR/CONVERT_EXPR, for all others it returns the
> passed first argument unmodified.  And NOP_EXPR/CONVERT_EXPR is always
> non-lvalue and needs to be diagnosed by lvalue_or_else.  This patch
> removes the get_unwidened call and as argtype is now always the same as
> result_type, also changes all uses of result_type to argtype.
> 
> Bootstrapped/regtested on x86_64-linux, fixes g++.old-deja/g++.mike/warn1.C
> failures on 64-bit arches and the new tests also pass.
> 
> Ok for trunk?

The C parts are OK, although I think the testcase should cover all of 
preincrement/postincrement/predecrement/postdecrement.

-- 
Joseph S. Myers
joseph@codesourcery.com


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