From patchwork Mon Oct 25 17:44:03 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 69171 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 40C9BB7043 for ; Tue, 26 Oct 2010 15:37:58 +1100 (EST) Received: (qmail 18540 invoked by alias); 26 Oct 2010 04:37:56 -0000 Received: (qmail 18443 invoked by uid 22791); 26 Oct 2010 04:37:55 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (140.186.70.92) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 26 Oct 2010 04:37:50 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PAR5u-0006Yc-A4 for gcc-patches@gcc.gnu.org; Mon, 25 Oct 2010 13:44:27 -0400 Received: from mel.act-europe.fr ([194.98.77.210]:42907) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PAR5u-0006YT-0p for gcc-patches@gcc.gnu.org; Mon, 25 Oct 2010 13:44:26 -0400 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 9888ECB02D2 for ; Mon, 25 Oct 2010 19:44:15 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bRPC0YCjTaZF for ; Mon, 25 Oct 2010 19:44:15 +0200 (CEST) Received: from [192.168.1.2] (bon31-9-83-155-120-49.fbx.proxad.net [83.155.120.49]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 663FCCB0220 for ; Mon, 25 Oct 2010 19:44:15 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix infinite loop on pointer to discriminated type Date: Mon, 25 Oct 2010 19:44:03 +0200 User-Agent: KMail/1.9.9 MIME-Version: 1.0 Message-Id: <201010251944.03516.ebotcazou@adacore.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Recent changes have exposed a latent issue in update_pointer_to: we fail to clear the TYPE_POINTER_TO/TYPE_REFERENCE_TO fields of the old type after redirecting its pointer and reference types. Tested on i586-suse-linux, applied on the mainline. 2010-10-25 Eric Botcazou * gcc-interface/utils.c (update_pointer_to): Clear TYPE_POINTER_TO and TYPE_REFERENCE_TO of the old type after redirecting its pointer and reference types. 2010-10-25 Eric Botcazou * gnat.dg/pointer_discr1.adb: New test. * gnat.dg/pointer_discr1_pkg1.ads: New helper. * gnat.dg/pointer_discr1_pkg2.ads: Likewise. * gnat.dg/pointer_discr1_pkg3.ads: Likewise. Index: gcc-interface/utils.c =================================================================== --- gcc-interface/utils.c (revision 165910) +++ gcc-interface/utils.c (working copy) @@ -3427,6 +3427,7 @@ update_pointer_to (tree old_type, tree n for (; ptr; ptr = TYPE_NEXT_PTR_TO (ptr)) for (t = TYPE_MAIN_VARIANT (ptr); t; t = TYPE_NEXT_VARIANT (t)) TREE_TYPE (t) = new_type; + TYPE_POINTER_TO (old_type) = NULL_TREE; /* Chain REF and its variants at the end. */ new_ref = TYPE_REFERENCE_TO (new_type); @@ -3443,6 +3444,7 @@ update_pointer_to (tree old_type, tree n for (; ref; ref = TYPE_NEXT_REF_TO (ref)) for (t = TYPE_MAIN_VARIANT (ref); t; t = TYPE_NEXT_VARIANT (t)) TREE_TYPE (t) = new_type; + TYPE_REFERENCE_TO (old_type) = NULL_TREE; } /* Now deal with the unconstrained array case. In this case the pointer