This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C and C++ PATCH] Properly diagnose ++ or -- on non-lvalue (PR c++/37561)
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Jason Merrill <jason at redhat dot com>, Mark Mitchell <mark at codesourcery dot com>, gcc-patches at gcc dot gnu dot org
- Date: Fri, 14 Nov 2008 23:48:14 +0000 (UTC)
- Subject: Re: [C and C++ PATCH] Properly diagnose ++ or -- on non-lvalue (PR c++/37561)
- References: <20081114201952.GG17496@tyan-ft48-01.lab.bos.redhat.com>
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