From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22061 invoked by alias); 27 Apr 2012 13:28:46 -0000 Received: (qmail 22053 invoked by uid 22791); 27 Apr 2012 13:28:46 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 27 Apr 2012 13:28:32 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 86E7E290033 for ; Fri, 27 Apr 2012 15:28:37 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GjqdJNc3vDdl for ; Fri, 27 Apr 2012 15:28:37 +0200 (CEST) Received: from ulanbator.act-europe.fr (ulanbator.act-europe.fr [10.10.1.67]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 74C2F290015 for ; Fri, 27 Apr 2012 15:28:37 +0200 (CEST) From: Tristan Gingold Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Subject: [RFA] Emit a warning for ineffective set VAR = EXP command Date: Fri, 27 Apr 2012 13:48:00 -0000 Message-Id: <8781499A-A489-42D0-80B1-75136331DBDB@adacore.com> To: "gdb-patches@sourceware.org ml" Mime-Version: 1.0 (Apple Message framework v1257) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-04/txt/msg00984.txt.bz2 Hi, the 'set VAR=3DEXP' command is a real trap for Ada (and maybe other languag= es such as Pascal users), because the '=3D' is interpreted as BINOP_EQUAL i= nstead 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 varia= bles. 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 * 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 =3D make_cleanup (free_current_contents, &expr); =20 + if (expr->nelts >=3D 1 + && expr->elts[0].opcode !=3D BINOP_ASSIGN + && expr->elts[0].opcode !=3D BINOP_ASSIGN_MODIFY + && expr->elts[0].opcode !=3D BINOP_COMMA) + warning (_("Expression is not an assignment (and might have no effect)= ")); + evaluate_expression (expr); do_cleanups (old_chain); }