From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4882 invoked by alias); 3 Feb 2009 01:20:29 -0000 Received: (qmail 4872 invoked by uid 22791); 3 Feb 2009 01:20:28 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 03 Feb 2009 01:20:24 +0000 Received: (qmail 32352 invoked from network); 3 Feb 2009 01:18:05 -0000 Received: from unknown (HELO orlando.local) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 3 Feb 2009 01:18:05 -0000 From: Pedro Alves To: Tom Tromey Subject: Re: RFA: fix PR gdb/2489 Date: Tue, 03 Feb 2009 01:20:00 -0000 User-Agent: KMail/1.9.10 Cc: gdb-patches@sourceware.org References: <200810212324.38183.pedro@codesourcery.com> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200902030121.48729.pedro@codesourcery.com> 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-02/txt/msg00048.txt.bz2 On Tuesday 03 February 2009 00:59:46, Tom Tromey wrote: > Pedro> + =A0for (i =3D TYPE_NFN_FIELDS (type) - 1; i >=3D0; --i) > Pedro> + =A0 =A0{ > Pedro> + =A0 =A0 =A0char *name =3D TYPE_FN_FIELDLIST_NAME (type, i); > Pedro> + =A0 =A0 =A0if (name && ! strncmp (name, fieldname, namelen)) > Pedro> + =A0 =A0 =A0 { > Pedro> + =A0 =A0 =A0 =A0 if (!type_name) > Pedro> + =A0 =A0 =A0 =A0 =A0 type_name =3D type_name_no_tag (type); > Pedro> + =A0 =A0 =A0 =A0 /* Omit constructors from the completion list. = =A0*/ > Pedro> + =A0 =A0 =A0 =A0 if (strcmp (type_name, name)) > Pedro> + =A0 =A0 =A0 =A0 =A0 { >=20 > Pedro> Can type_name ever be NULL here then? >=20 > The reason for the check here is that we compute type_name the first > time we need it. =A0It is initialized to NULL, but only set once. Oh, sorry, I guess I wasn't clear. I meant after the type_name_no_tag call, at the strcmp line. I mainly asked due to this: /* Return a typename for a struct/union/enum type without "struct ", "union ", or "enum ". If the type has a NULL name, return NULL. */ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ char * type_name_no_tag (const struct type *type) { if (TYPE_TAG_NAME (type) !=3D NULL) return TYPE_TAG_NAME (type); /* Is there code which expects this to return the name if there is no tag name? My guess is that this is mainly used for C++ in cases where the two will always be the same. */ return TYPE_NAME (type); } I don't know if that can happen here. That was also the reason I suggested an annonymous struct/class test. On Tuesday 03 February 2009 00:59:46, Tom Tromey wrote: > Pedro> (I wish we had a function we could call that abstracted and > Pedro> made easier to write/read these completion tests.) >=20 > I rewrote the tests to use the "complete" command rather than sending > a TAB. This makes them much simpler. >=20 Indeed! Much nicer. --=20 Pedro Alves