From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12920 invoked by alias); 2 Feb 2011 21:12:33 -0000 Received: (qmail 12907 invoked by uid 22791); 2 Feb 2011 21:12:32 -0000 X-SWARE-Spam-Status: No, hits=-6.3 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, 02 Feb 2011 21:12:26 +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 p12LCOSJ021663 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 2 Feb 2011 16:12:24 -0500 Received: from host1.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p12LCLrg001695 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 2 Feb 2011 16:12:23 -0500 Received: from host1.dyn.jankratochvil.net (localhost [127.0.0.1]) by host1.dyn.jankratochvil.net (8.14.4/8.14.4) with ESMTP id p12LCLHG012675; Wed, 2 Feb 2011 22:12:21 +0100 Received: (from jkratoch@localhost) by host1.dyn.jankratochvil.net (8.14.4/8.14.4/Submit) id p12LCKMx012674; Wed, 2 Feb 2011 22:12:20 +0100 Date: Wed, 02 Feb 2011 21:12:00 -0000 From: Jan Kratochvil To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: RFC: handle case arising from GCC PR 47510 Message-ID: <20110202211220.GA9781@host1.dyn.jankratochvil.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) 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: 2011-02/txt/msg00031.txt.bz2 Hi Tom, > --- a/gdb/dwarf2read.c > +++ b/gdb/dwarf2read.c [...] > + if (cu->language == language_cplus > + && TYPE_CODE (TYPE_TARGET_TYPE (this_type)) == TYPE_CODE_STRUCT > + && TYPE_TAG_NAME (TYPE_TARGET_TYPE (this_type)) == NULL > + && maybe_smash_one_typedef (this_type, dwarf2_name (die, cu))) > + { > + /* We turned this typedef into a real structure type, so > + make a pretend DIE to get new_symbol to do the right > + thing. */ > + struct die_info fake = *die; fake.attrs are invalid now while being accessed by new_symbol. > + > + fake.tag = DW_TAG_structure_type; > + new_symbol (&fake, TYPE_TARGET_TYPE (this_type), cu); > + } > --- /dev/null > +++ b/gdb/testsuite/gdb.cp/anon-struct.cc > @@ -0,0 +1,15 @@ > +class C { No copyright needed? > +public: > + C() {} > + ~C() {} If the destructor is not present maybe_smash_one_typedef() will not work. And GDB crashes now due to it, that should be sanity-protected anyway. > +}; > + > +typedef struct { > + C m; > +} t; > +typedef t S; > +S v; I would remove the intermediate type `S', it was there fore more illustrative purposes. > --- /dev/null > +++ b/gdb/testsuite/gdb.cp/anon-struct.exp > @@ -0,0 +1,25 @@ > +# Tests for anonymous union support. > +# Copyright 2011 Free Software Foundation, Inc. > + > +# This program is free software; you can redistribute it and/or modify > +# it under the terms of the GNU General Public License as published by > +# the Free Software Foundation; either version 3 of the License, or > +# (at your option) any later version. > +# > +# This program is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program. If not, see . > + > +set testfile anon-struct > +set srcfile ${testfile}.cc > +set binfile ${objdir}/${subdir}/${testfile} > +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug c++}] } { > + return -1 > +} > + > +gdb_test "ptype t::t" "type = void \\(t \\* const\\)" \ > + "print type of t::t" > diff --git a/gdb/valops.c b/gdb/valops.c > index 24c2269..0287092 100644 > --- a/gdb/valops.c > +++ b/gdb/valops.c > @@ -3238,25 +3238,32 @@ value_struct_elt_for_reference (struct type *domain, int offset, > j = -1; > - for (ii = 0; ii < TYPE_FN_FIELDLIST_LENGTH (t, i); > - ++ii) > + for (ii = 0; ii < len; ++ii) > { > /* Skip artificial methods. This is necessary if, > for example, the user wants to "print > subclass::subclass" with only one user-defined > - constructor. There is no ambiguity in this > - case. */ > + constructor. There is no ambiguity in this case. > + We are careful here to allow artificial methods > + if they are the unique result. */ > if (TYPE_FN_FIELD_ARTIFICIAL (f, ii)) > - continue; > + { > + if (j == -1) > + j = ii; > + continue; > + } > > /* Desired method is ambiguous if more than one > method is defined. */ > - if (j != -1) > + if (j != -1 && !TYPE_FN_FIELD_ARTIFICIAL (f, j)) > error (_("non-unique member `%s' requires " > "type instantiation"), name); > > j = ii; > } > + > + if (j == -1) > + error (_("no matching member function")); > } I do not fully grok this change, it goes half way. Why two artificial methods are not non-unique? Thanks, Jan