From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8991 invoked by alias); 1 Jul 2015 14:10:10 -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 8956 invoked by uid 89); 1 Jul 2015 14:10:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.5 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 01 Jul 2015 14:10:09 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id EA13436505E; Wed, 1 Jul 2015 14:10:07 +0000 (UTC) Received: from host1.jankratochvil.net (ovpn-116-41.ams2.redhat.com [10.36.116.41]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t61EA3xY001315 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 1 Jul 2015 10:10:06 -0400 Date: Wed, 01 Jul 2015 14:10:00 -0000 From: Jan Kratochvil To: Pedro Alves Cc: Yao Qi , gdb-patches@sourceware.org, Phil Muldoon Subject: Re: [patchv2] compile: Fix crash on cv-qualified self-reference Message-ID: <20150701141003.GA19545@host1.jankratochvil.net> References: <20150418172843.GA17777@host1.jankratochvil.net> <20150516132555.GB17266@host1.jankratochvil.net> <86lhf0p1hf.fsf@gmail.com> <20150701132406.GA13975@host1.jankratochvil.net> <5593F10D.4020903@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5593F10D.4020903@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes X-SW-Source: 2015-07/txt/msg00042.txt.bz2 On Wed, 01 Jul 2015 15:54:21 +0200, Pedro Alves wrote: > On 07/01/2015 02:24 PM, Jan Kratochvil wrote: > > > I can change it that way but when you ask "isn't cleaner" then no, I think > > your hack is even a bit more ugly than my ugly hack. > > > > There should be two virtual methods, one pure for 'switch (TYPE_CODE (type))' > > and the other one checking TYPE_INSTANCE_FLAG* in superclass overriden only by > > TYPE_CODE_STRUCT and TYPE_CODE_UNION (there would be no TYPE_CODE_*, though). > > What would be the method name? class Type { protected: virtual GccType convert_unqualified ()=0; public: explicit virtual GccType operator() { if (instance_flags==0) return convert_unqualified(); ... } }; class StructType:public Type { protected: virtual GccType convert_unqualified () { assert(0) } public: explicit virtual GccType operator() override { ... } }; class IntegerType:public Type { protected: virtual GccType convert_unqualified () { assert(instance_flags==0); ... } }; Althoughth qualifications could be possibly also subclassed which would look differently again. My point was that the current code does not make much sense to clean up as it cannot be clean in C. > There's nothing preventing adding a new type_FOO function that takes a type > pointer as parameter and hides the TYPE_CODE checks inside. From the > caller's perspective, it'll be the same. Once we get to C++ and if we > consider objectifying type, then converting that function to a method will > be trivial. Do you mean simulation of C++ virtual method table by a struct of pointers, like in other cases in GDB? Jan