From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3361 invoked by alias); 13 Oct 2010 19:01:05 -0000 Received: (qmail 3353 invoked by uid 22791); 13 Oct 2010 19:01:04 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 13 Oct 2010 19:00:57 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o9DJ0UbQ016540 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 13 Oct 2010 15:00:30 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o9DJ0TLU029854; Wed, 13 Oct 2010 15:00:29 -0400 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o9DJ0SP0032000; Wed, 13 Oct 2010 15:00:29 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id 71BC03791BC; Wed, 13 Oct 2010 13:00:28 -0600 (MDT) From: Tom Tromey To: Ken Werner Cc: Joel Brobecker , Daniel Jacobowitz , Ulrich Weigand , gdb-patches@sourceware.org Subject: Re: [patch] fix pre-/post- in-/decrement References: <201010041301.o94D1QHV032611@d12av02.megacenter.de.ibm.com> <201010071438.00571.ken@linux.vnet.ibm.com> <201010131123.40225.ken@linux.vnet.ibm.com> Date: Wed, 13 Oct 2010 19:01:00 -0000 In-Reply-To: <201010131123.40225.ken@linux.vnet.ibm.com> (Ken Werner's message of "Wed, 13 Oct 2010 11:23:39 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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: 2010-10/txt/msg00233.txt.bz2 >>>>> "Ken" == Ken Werner writes: Tom> While I don't really mind having language checks in the expression Tom> evaluator, it seems like this particular error condition is something Tom> that could be detected in the C parser. Ken> Hmm interesting. I guess you are referring to c-exp.y as this Ken> generates the expression parser for both languages C and C++. Yeah. Ken> I don't see how to control the type of the result of an operator Ken> there. I'm still quite new to the GDB parsing internals and would Ken> appreciate any insights. It is probably a bit of a pain, since the IR generated by the parser is a bit unusual (as compilers go). However, it seems to me that it would be much friendlier for users to report this as a parse error rather than a runtime error. One option would be to write a C/C++ implementation of the language_defn la_post_parser method, which would look at the expression to see if this constraint is violated. Another option would be to try to implement it in the grammar. Tom> Also, I think the C++ rule is more complicated. I did not look through Tom> the standard to find it, but g++ at least gives an error for a simple Tom> scalar "x++ = 5". Ken> Yes, this behaviour seems correct to me and the patch ensures that Ken> a non- lvalue is returned in case of UNOP_POSTINCREMENT and Ken> UNOP_POSTDECREMENT as C and C++ do not differ here. Thanks for the correction and the links to the standard. Tom