From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11505 invoked by alias); 4 Nov 2014 13:43:40 -0000 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 Received: (qmail 11495 invoked by uid 89); 4 Nov 2014 13:43:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,MSGID_FROM_MTA_HEADER,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-HELO: e06smtp13.uk.ibm.com Received: from e06smtp13.uk.ibm.com (HELO e06smtp13.uk.ibm.com) (195.75.94.109) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Tue, 04 Nov 2014 13:43:39 +0000 Received: from /spool/local by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 4 Nov 2014 13:43:36 -0000 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 4 Nov 2014 13:43:34 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 0DB39219005E for ; Tue, 4 Nov 2014 13:43:08 +0000 (GMT) Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id sA4DhX6s61538522 for ; Tue, 4 Nov 2014 13:43:33 GMT Received: from d06av02.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id sA4DhWcI024850 for ; Tue, 4 Nov 2014 06:43:33 -0700 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with SMTP id sA4DhRje024520; Tue, 4 Nov 2014 06:43:27 -0700 Message-Id: <201411041343.sA4DhRje024520@d06av02.portsmouth.uk.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Tue, 04 Nov 2014 14:43:27 +0100 Subject: Re: [PATCH v4] Make chained function calls in expressions work To: sivachandra@google.com (Siva Chandra) Date: Tue, 04 Nov 2014 13:43:00 -0000 From: "Ulrich Weigand" Cc: gdb-patches@sourceware.org (gdb-patches) In-Reply-To: from "Siva Chandra" at Nov 03, 2014 01:22:18 PM MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14110413-0013-0000-0000-000001BACAD3 X-SW-Source: 2014-11/txt/msg00060.txt.bz2 Siva Chandra wrote: > On Mon, Nov 3, 2014 at 11:55 AM, Siva Chandra wrote: > >>>+/* Return true is T is a class or a union. False otherwise. */ > >>>+ > >>>+int > >>>+class_or_union_p (const struct type *t) > >>>+{ > >>>+ return (TYPE_CODE (t) == TYPE_CODE_STRUCT > >>>+ || TYPE_CODE (t) == TYPE_CODE_UNION); > >>>+} > >> > >> I understand we need to do this for classes with member functions (so that > >> f().g() will work) -- do we really need it for classes without member > >> functions (or plain C structs)? > > > > We could have a struct like this in C++: > > > > struct Derived : public virtual Base > > { > > ... > > }; > > > > Do you mean we should have a language check before reserving space on the stack? > > Sorry for revisiting but I thought I can be a bit more elaborate on > this. To complete the example, I am talking about a case like this: > > struct Base > { > int base; > }; > > struct Derived : public virtual Base > { > int derived; > }; > > Derived does not have any methods, but will be returned in a hidden > param as it has a virtual base class. Well, if it already is returned in a hidden parameter, then we already fall into the if (hidden_first_param_p) case, so we don't need to do the extra copy back to the stack, right? > Even for simple structs like this: > > struct Simple > { > int simple; > }; > > the return value could be a reference argument for a subsequent > inferior function and hence would still need to be have an address. Well, that's true. For simple structs, we would have to create a temporary at the point of call when using a reference; we discussed adding this anyway (it's necessary for scalars as well) ... Bye, Ulrich -- Dr. Ulrich Weigand GNU/Linux compilers and toolchain Ulrich.Weigand@de.ibm.com