Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] Emit a warning for ineffective set VAR = EXP command
@ 2012-04-27 13:48 Tristan Gingold
  2012-04-27 13:54 ` Pierre Muller
                   ` (2 more replies)
  0 siblings, 3 replies; 30+ messages in thread
From: Tristan Gingold @ 2012-04-27 13:48 UTC (permalink / raw)
  To: gdb-patches@sourceware.org ml

Hi,

the 'set VAR=EXP' command is a real trap for Ada (and maybe other languages such as Pascal users), because the '=' is interpreted as BINOP_EQUAL instead of BINOP_ASSIGN.  You often do not realize that the current language is not C where you are using to command for registers or convenience variables.

I simply propose to emit a warning if the expression is not an assignment (or a comma expression).

No regressions on x86_64 GNU/Linux.

Ok for trunk ?

2012-04-27  Tristan Gingold  <gingold@adacore.com>

	* printcmd.c (set_command): Emit a warning if the expression is not
	an assignment.

diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index d441dfe..79e38f2 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1080,6 +1080,12 @@ 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)"));
+
   evaluate_expression (expr);
   do_cleanups (old_chain);
 }


^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2012-05-10 14:11 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-27 13:48 [RFA] Emit a warning for ineffective set VAR = EXP command 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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox