From: Ken Werner <ken@linux.vnet.ibm.com>
To: Tom Tromey <tromey@redhat.com>
Cc: Joel Brobecker <brobecker@adacore.com>,
Daniel Jacobowitz <dan@codesourcery.com>,
Ulrich Weigand <uweigand@de.ibm.com>,
gdb-patches@sourceware.org
Subject: Re: [patch] fix pre-/post- in-/decrement
Date: Wed, 13 Oct 2010 09:23:00 -0000 [thread overview]
Message-ID: <201010131123.40225.ken@linux.vnet.ibm.com> (raw)
In-Reply-To: <m3pqvff24r.fsf@fleche.redhat.com>
On Wednesday, October 13, 2010 1:00:04 am Tom Tromey wrote:
> >>>>> "Ken" == Ken Werner <ken@linux.vnet.ibm.com> writes:
> Ken> I overlooked that in case of C++ the various assignment,
> Ken> pre-increment and pre-decrement operators return lvalues while they
> Ken> return non-lvalues for C.
>
> I still had this patch in my queue, but I wasn't sure if it was
> obsoleted by something else...
First, thank you for looking at this. In my opinion the patch is still
relevant. The goal is to add unop support for vector types. The initial patch
contained (beside its main purpose) code to prevent post in-/decrement
operators from returning lvalues. Joel suggested this should be treated as a
separate patch. This is how this patch was born. It helps GDB to be more
accurate when it comes to the result types of unary operations.
> While I don't really mind having language checks in the expression
> evaluator, it seems like this particular error condition is something
> that could be detected in the C parser.
Hmm interesting. I guess you are referring to c-exp.y as this generates the
expression parser for both languages C and C++. I don't see how to control the
type of the result of an operator there. I'm still quite new to the GDB
parsing internals and would appreciate any insights.
> Also, I think the C++ rule is more complicated. I did not look through
> the standard to find it, but g++ at least gives an error for a simple
> scalar "x++ = 5".
Yes, this behaviour seems correct to me and the patch ensures that a non-
lvalue is returned in case of UNOP_POSTINCREMENT and UNOP_POSTDECREMENT as C
and C++ do not differ here. For BINOP_ASSIGN, BINOP_ASSIGN_MODIFY,
UNOP_PREINCREMENT and UNOP_PREDECREMENT C returns non-lvalues while C++
returns lvalues. This is why the patch checks the language and calls
value_non_lval for languages other than C++. I think the relevant sections of
the C++ standard are these:
5.3.2 Increment and decrement [expr.pre.incr]:
"The result is the updated operand; it is an lvalue, [..]"
5.2.6 Increment and decrement [expr.post.incr]
"The result is an rvalue."
5.17 Assignment and compound assignment operators [expr.ass]
"[...] return an lvalue with the type and value of the left operand after the
assignment has taken
place."
So, this patch doesn't conflict with the g++ behaviour you are seeing.
Regards
Ken Werner
next prev parent reply other threads:[~2010-10-13 9:23 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-17 12:58 [patch] GNU vector unop support Ken Werner
2010-09-28 16:04 ` Ken Werner
[not found] ` <20100930185634.GC6213@adacore.com>
2010-10-01 17:45 ` [patch] fix pre-/post- in-/decrement Ken Werner
2010-10-04 13:01 ` Ulrich Weigand
2010-10-04 19:47 ` Ken Werner
2010-10-04 20:45 ` Daniel Jacobowitz
2010-10-04 21:58 ` Ulrich Weigand
2010-10-04 22:59 ` Daniel Jacobowitz
2010-10-04 23:25 ` Ulrich Weigand
2010-10-05 1:17 ` Daniel Jacobowitz
2010-10-05 13:28 ` Ulrich Weigand
2010-10-05 13:42 ` Daniel Jacobowitz
2010-10-06 18:59 ` [rfc] Fix value_assign return value (Re: [patch] fix pre-/post- in-/decrement) Ulrich Weigand
2010-10-26 13:42 ` Daniel Jacobowitz
2010-12-01 16:51 ` Ulrich Weigand
2010-10-06 20:55 ` [patch] fix pre-/post- in-/decrement Vladimir Prus
2010-10-07 12:38 ` Ken Werner
2010-10-12 23:00 ` Tom Tromey
2010-10-13 8:45 ` Andreas Schwab
2010-10-13 9:23 ` Ken Werner [this message]
2010-10-13 16:07 ` Daniel Jacobowitz
2010-10-13 19:01 ` Tom Tromey
2010-10-19 7:38 ` Ken Werner
2010-11-02 8:23 ` Ken Werner
2010-11-02 20:31 ` Tom Tromey
2010-11-03 13:52 ` Ken Werner
2010-10-04 20:52 ` [patch] GNU vector unop support Ken Werner
2010-10-06 23:27 ` Joel Brobecker
2010-10-07 16:23 ` Ken Werner
2010-11-03 14:07 ` Ken Werner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201010131123.40225.ken@linux.vnet.ibm.com \
--to=ken@linux.vnet.ibm.com \
--cc=brobecker@adacore.com \
--cc=dan@codesourcery.com \
--cc=gdb-patches@sourceware.org \
--cc=tromey@redhat.com \
--cc=uweigand@de.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox