From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 67284 invoked by alias); 1 Jul 2015 13:24:13 -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 67275 invoked by uid 89); 1 Jul 2015 13:24:13 -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 13:24:12 +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 D5A933500F8; Wed, 1 Jul 2015 13:24:10 +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 t61DO7kd030482 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 1 Jul 2015 09:24:09 -0400 Date: Wed, 01 Jul 2015 13:24:00 -0000 From: Jan Kratochvil To: Yao Qi Cc: gdb-patches@sourceware.org, Phil Muldoon Subject: Re: [patchv2] compile: Fix crash on cv-qualified self-reference Message-ID: <20150701132406.GA13975@host1.jankratochvil.net> References: <20150418172843.GA17777@host1.jankratochvil.net> <20150516132555.GB17266@host1.jankratochvil.net> <86lhf0p1hf.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <86lhf0p1hf.fsf@gmail.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes X-SW-Source: 2015-07/txt/msg00024.txt.bz2 On Wed, 01 Jul 2015 13:21:32 +0200, Yao Qi wrote: > Jan Kratochvil writes: > > > + quals = 0; > > + if (TYPE_CONST (type)) > > + quals |= GCC_QUALIFIER_CONST; > > + if (TYPE_VOLATILE (type)) > > + quals |= GCC_QUALIFIER_VOLATILE; > > + if (TYPE_RESTRICT (type)) > > + quals |= GCC_QUALIFIER_RESTRICT; > > + result = C_CTX (context)->c_ops->build_qualified_type (C_CTX (context), > > + result, quals); > > insert_type (context, type, result); > > Can we use convert_qualified instead? I find code we added here is > quite similar to convert_qualified. Not directly to use convert_qualified() but convert_qualified() could be split in halves and one half could be used here, I agree. > > for (i = 0; i < TYPE_NFIELDS (type); ++i) > > @@ -329,10 +342,13 @@ static gcc_type > > convert_type_basic (struct compile_c_instance *context, struct type *type) > > { > > /* If we are converting a qualified type, first convert the > > - unqualified type and then apply the qualifiers. */ > > + unqualified type and then apply the qualifiers, except for the > > + types handling qualifiers on their own. */ > > if ((TYPE_INSTANCE_FLAGS (type) & (TYPE_INSTANCE_FLAG_CONST > > | TYPE_INSTANCE_FLAG_VOLATILE > > - | TYPE_INSTANCE_FLAG_RESTRICT)) != 0) > > + | TYPE_INSTANCE_FLAG_RESTRICT)) != 0 > > + && (TYPE_CODE (type) != TYPE_CODE_STRUCT > > + && TYPE_CODE (type) != TYPE_CODE_UNION)) > > return convert_qualified (context, type); > > It looks right to me, however, isn't cleaner to do in this way? > > /* Comments on why we do this first */ > if (TYPE_CODE (type) == TYPE_CODE_STRUCT > || TYPE_CODE (type) == TYPE_CODE_UNION) > return convert_struct_or_union (context, type); > > /* If we are converting a qualified type, first convert the > unqualified type and then apply the qualifiers. */ > if ((TYPE_INSTANCE_FLAGS (type) & (TYPE_INSTANCE_FLAG_CONST > | TYPE_INSTANCE_FLAG_VOLATILE > | TYPE_INSTANCE_FLAG_RESTRICT)) != 0) > return convert_qualified (context, type); > > switch (TYPE_CODE (type)) > { > /* Don't need to handle TYPE_CODE_STRUCT and TYPE_CODE_UNION > here. */ > } 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). > Otherwise, the patch looks good to me. OK, thanks. Just it causes a regression with latest GCC now as I have asked Alexandre Oliva off-list how it really should be fixed. Jan