From: Tristan Gingold <gingold@adacore.com>
To: <Paul_Koning@Dell.com> <Paul_Koning@Dell.com>
Cc: <brobecker@adacore.com>, <macro@codesourcery.com>,
<gdb-patches@sourceware.org>
Subject: Re: [RFA] Emit a warning for ineffective set VAR = EXP command
Date: Wed, 09 May 2012 14:10:00 -0000 [thread overview]
Message-ID: <BAF1FC80-8A4C-4667-B7D2-5E67646BBDE5@adacore.com> (raw)
In-Reply-To: <46C50B2C-7910-4B36-B64B-D1C6C91627B8@dell.com>
On May 9, 2012, at 3:53 PM, <Paul_Koning@Dell.com> <Paul_Koning@Dell.com> wrote:
>
> On May 9, 2012, at 8:28 AM, Tristan Gingold wrote:
>
>>
>> On May 7, 2012, at 9:38 PM, Joel Brobecker wrote:
>>
>>>>> This warns about "set variable $j++" presumably -- should the warning be
>>>>> disabled for pre/post increments/decrements?
>>>>
>>>> I am not opposed to disable warnings for pre/post inc/dec.
>>>> But this usage is dubious (the help explicitly mentions VAR=EXP !)
>>>>
>>>> Opinion ?
>>>
>>> I think we should avoid the warning for pre/post inc/dec. This
>>> type of expression might be a little outside the method proposed
>>> in our documentation, but I think it's still a perfectly valid
>>> expression that results in an assignment being performed.
>>
>> I don't know who should approve this adjustment, but here is the version that deals with pre/post inc/dec.
>> Note that it still warns for expressions such as i++ * 2.
>
> If you had it walk through the elts[] list, would it then work for that case?
Is it worth the burden ?
>
> paul
>
>>
>> Tested on set-nowarns.exp.
>>
>> Tristan.
>>
>> 2012-05-09 Tristan Gingold <gingold@adacore.com>
>>
>> * printcmd.c (set_command): Add pre/post inc/dec.
>>
>> diff --git a/gdb/printcmd.c b/gdb/printcmd.c
>> index 79e38f2..fa76296 100644
>> --- a/gdb/printcmd.c
>> +++ b/gdb/printcmd.c
>> @@ -1080,11 +1080,21 @@ set_command (char *exp, int from_tty)
>> struct cleanup *old_chain =
>> make_cleanup (free_current_contents, &expr);
>>
>> - if (expr->nelts >= 1
>> - && expr->elts[0].opcode != BINOP_ASSIGN
>> - && expr->elts[0].opcode != BINOP_ASSIGN_MODIFY
>> - && expr->elts[0].opcode != BINOP_COMMA)
>> - warning (_("Expression is not an assignment (and might have no effect)"));
>> + if (expr->nelts >= 1)
>> + switch (expr->elts[0].opcode)
>> + {
>> + case UNOP_PREINCREMENT:
>> + case UNOP_POSTINCREMENT:
>> + case UNOP_PREDECREMENT:
>> + case UNOP_POSTDECREMENT:
>> + case BINOP_ASSIGN:
>> + case BINOP_ASSIGN_MODIFY:
>> + case BINOP_COMMA:
>> + break;
>> + default:
>> + warning
>> + (_("Expression is not an assignment (and might have no effect)"));
>> + }
>>
>> evaluate_expression (expr);
>> do_cleanups (old_chain);
>>
>
next prev parent reply other threads:[~2012-05-09 14:10 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-27 13:48 Tristan Gingold
2012-04-27 13:54 ` Pierre Muller
2012-04-27 16:09 ` Tom Tromey
2012-05-02 13:17 ` Tristan Gingold
2012-05-02 16:41 ` Doug Evans
2012-05-03 10:00 ` Tristan Gingold
2012-05-03 13:12 ` Doug Evans
2012-05-03 15:05 ` Joel Brobecker
2012-05-03 16:33 ` Doug Evans
2012-05-03 22:04 ` Joel Brobecker
2012-05-03 22:07 ` Doug Evans
2012-05-04 7:59 ` Tristan Gingold
2012-05-03 15:02 ` Joel Brobecker
2012-05-03 15:04 ` Tristan Gingold
2012-05-04 19:02 ` Maciej W. Rozycki
2012-05-07 10:30 ` Tristan Gingold
2012-05-07 19:36 ` Tom Tromey
2012-05-07 19:40 ` Paul_Koning
2012-05-07 20:38 ` Tom Tromey
2012-05-07 19:38 ` Joel Brobecker
2012-05-09 12:29 ` Tristan Gingold
2012-05-09 13:54 ` Paul_Koning
2012-05-09 14:10 ` Tristan Gingold [this message]
2012-05-09 14:12 ` Maciej W. Rozycki
2012-05-09 14:58 ` Paul_Koning
2012-05-09 15:38 ` Maciej W. Rozycki
2012-05-09 15:55 ` Paul_Koning
2012-05-09 14:17 ` Joel Brobecker
2012-05-10 14:11 ` Tristan Gingold
2012-05-08 6:06 ` Maciej W. Rozycki
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=BAF1FC80-8A4C-4667-B7D2-5E67646BBDE5@adacore.com \
--to=gingold@adacore.com \
--cc=Paul_Koning@Dell.com \
--cc=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=macro@codesourcery.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