From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 104609 invoked by alias); 1 Jul 2015 11:21:40 -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 104587 invoked by uid 89); 1 Jul 2015 11:21:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f47.google.com Received: from mail-pa0-f47.google.com (HELO mail-pa0-f47.google.com) (209.85.220.47) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 01 Jul 2015 11:21:39 +0000 Received: by pabvl15 with SMTP id vl15so21862084pab.1 for ; Wed, 01 Jul 2015 04:21:37 -0700 (PDT) X-Received: by 10.68.252.106 with SMTP id zr10mr54409019pbc.79.1435749697319; Wed, 01 Jul 2015 04:21:37 -0700 (PDT) Received: from E107787-LIN (gcc1-power7.osuosl.org. [140.211.15.137]) by mx.google.com with ESMTPSA id ng13sm1953346pdb.82.2015.07.01.04.21.34 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 01 Jul 2015 04:21:36 -0700 (PDT) From: Yao Qi To: Jan Kratochvil Cc: gdb-patches@sourceware.org, Phil Muldoon Subject: Re: [patchv2] compile: Fix crash on cv-qualified self-reference References: <20150418172843.GA17777@host1.jankratochvil.net> <20150516132555.GB17266@host1.jankratochvil.net> Date: Wed, 01 Jul 2015 11:21:00 -0000 In-Reply-To: <20150516132555.GB17266@host1.jankratochvil.net> (Jan Kratochvil's message of "Sat, 16 May 2015 15:25:55 +0200") Message-ID: <86lhf0p1hf.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2015-07/txt/msg00008.txt.bz2 Jan Kratochvil writes: > + quals =3D 0; > + if (TYPE_CONST (type)) > + quals |=3D GCC_QUALIFIER_CONST; > + if (TYPE_VOLATILE (type)) > + quals |=3D GCC_QUALIFIER_VOLATILE; > + if (TYPE_RESTRICT (type)) > + quals |=3D GCC_QUALIFIER_RESTRICT; > + result =3D C_CTX (context)->c_ops->build_qualified_type (C_CTX (contex= t), > + 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. >=20=20 > for (i =3D 0; i < TYPE_NFIELDS (type); ++i) > @@ -329,10 +342,13 @@ static gcc_type > convert_type_basic (struct compile_c_instance *context, struct type *typ= e) > { > /* 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)) !=3D 0) > + | TYPE_INSTANCE_FLAG_RESTRICT)) !=3D 0 > + && (TYPE_CODE (type) !=3D TYPE_CODE_STRUCT > + && TYPE_CODE (type) !=3D 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) =3D=3D TYPE_CODE_STRUCT || TYPE_CODE (type) =3D=3D 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)) !=3D 0) return convert_qualified (context, type); switch (TYPE_CODE (type)) { /* Don't need to handle TYPE_CODE_STRUCT and TYPE_CODE_UNION here. */ } Otherwise, the patch looks good to me. --=20 Yao (=E9=BD=90=E5=B0=A7)