From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14413 invoked by alias); 13 Oct 2009 21:24:35 -0000 Received: (qmail 14345 invoked by uid 22791); 13 Oct 2009 21:24:34 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from NaN.false.org (HELO nan.false.org) (208.75.86.248) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 13 Oct 2009 21:24:29 +0000 Received: from nan.false.org (localhost [127.0.0.1]) by nan.false.org (Postfix) with ESMTP id E631110EB5; Tue, 13 Oct 2009 21:26:20 +0000 (GMT) Received: from caradoc.them.org (209.195.188.212.nauticom.net [209.195.188.212]) by nan.false.org (Postfix) with ESMTP id C7D5D10E84; Tue, 13 Oct 2009 21:26:20 +0000 (GMT) Received: from drow by caradoc.them.org with local (Exim 4.69) (envelope-from ) id 1Mxor4-0008UD-PD; Tue, 13 Oct 2009 17:24:26 -0400 Date: Tue, 13 Oct 2009 21:24:00 -0000 From: Daniel Jacobowitz To: Keith Seitz Cc: gdb-patches@sourceware.org Subject: Re: [RFA] Add method overload resolution to expression parser Message-ID: <20091013212426.GA26169@caradoc.them.org> Mail-Followup-To: Keith Seitz , gdb-patches@sourceware.org References: <4A9D628B.1070300@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4A9D628B.1070300@redhat.com> User-Agent: Mutt/1.5.20 (2009-06-14) 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: 2009-10/txt/msg00288.txt.bz2 On Tue, Sep 01, 2009 at 11:06:03AM -0700, Keith Seitz wrote: > +/* Cleanup for 'nonempty_typelist' */ > +static struct cleanup *typelist_cleanup; Does this cleanup get more complicated uses? As it stands after this patch, it's just a more confusing way to write a call to free. IMO having cleanups created inside the parser is confusing. > +/* Constructs a fake method with the given parameter types. This is > + used to do overload resolution by the expression parser. The > + logical counterpart is compare_parameters in valops.c. */ > + > +static struct type * > +make_params (int num_types, struct type **param_types) > +{ > + struct type *type = XZALLOC (struct type); > + TYPE_MAIN_TYPE (type) = XZALLOC (struct main_type); > + TYPE_LENGTH (type) = 1; > + TYPE_CODE (type) = TYPE_CODE_METHOD; > + TYPE_VPTR_FIELDNO (type) = -1; > + TYPE_CHAIN (type) = type; > + TYPE_NFIELDS (type) = num_types; > + TYPE_FIELDS (type) = (struct field *) > + TYPE_ZALLOC (type, sizeof (struct field) * num_types); > + > + while (num_types-- > 0) > + TYPE_FIELD_TYPE (type, num_types) = param_types[num_types]; > + > + make_cleanup (free_param_types, type); > + return type; > +} And this is even more confusing... how does this cleanup eventually get run? We shouldn't leak it back to the top level. And I suspect that since nothing ever copies types, if this type makes it into the value history we're going to have a problem. I also wonder why TYPE_INSTANCE is necesary. All it seems to do is construct the temporary type. Can't we do that in the parser, instead, and use UNOP_CAST? -- Daniel Jacobowitz CodeSourcery