From patchwork Sun May 26 08:46:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 246372 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 71D9B2C0040 for ; Sun, 26 May 2013 18:48:49 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=Sf90rNyuPKp1LbQv MzOtZ/Co9nmIoRNJefPUGuIh0TuT4wH5skg8U/Go7pbJJrBjGBwL57WZQbLHaCaV w9CMtd9hkO81XtAueOqAd9LEuylKv+Il5LapfudBAnUtR+3KnYNytUFRMXJuFSXg LhrRSEV/CTUbvokQwBdoW234iTI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=1kK8d9X5M+OfSWsk1VWWdY cwNq4=; b=LnWZkWx0rG4SvpgGpYIf/kLp+VQGQ2FtcjzOPD77Jx5g5BSlSxZa5y NLLIT603uAKX+I6g5VoB7fVtliP76SCVhjoyxrkDBxJPxAAH3d1a93IKukPtSCEA OWgEeXubDqJ4hVsuTtLsilLzQJI0d6jLNmT3PXRb1x8AuvhoPsMqk= Received: (qmail 6004 invoked by alias); 26 May 2013 08:48:42 -0000 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 Received: (qmail 5992 invoked by uid 89); 26 May 2013 08:48:42 -0000 X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.1 Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Sun, 26 May 2013 08:48:41 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 8E6D12647CC7 for ; Sun, 26 May 2013 10:47:13 +0200 (CEST) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KhY9TnHvn15N for ; Sun, 26 May 2013 10:47:13 +0200 (CEST) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 6600B2647C14 for ; Sun, 26 May 2013 10:47:13 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix ICE on type completed by private type in Ada 2012 Date: Sun, 26 May 2013 10:46:24 +0200 Message-ID: <3378011.JcsKqSDbyF@polaris> User-Agent: KMail/4.7.2 (Linux/3.1.10-1.19-desktop; KDE/4.7.2; x86_64; ; ) MIME-Version: 1.0 X-Virus-Found: No In Ada 2012, you can complete an incomplete type with a private type, so you can have 3 different views for a single type. As the attached testcase shows, this can lead to an ICE when the completion is a tagged private type because the full view is elaborated prematurely. Tested on x86_64-suse-linux, applied on the mainline. 2013-05-26 Eric Botcazou * gcc-interface/decl.c (gnat_to_gnu_entity): Do not prematurely elaborate the full view of a type with a freeze node. * gcc-interface/trans.c (process_type): Add explicit predicate. 2013-05-26 Eric Botcazou * gnat.dg/incomplete3.ad[sb]: New test. Index: gcc-interface/decl.c =================================================================== --- gcc-interface/decl.c (revision 199335) +++ gcc-interface/decl.c (working copy) @@ -288,7 +288,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entit If we are defining the node, we should not have already processed it. In that case, we will abort below when we try to save a new GCC tree for this object. We also need to handle the case of getting a dummy - type when a Full_View exists. */ + type when a Full_View exists but be careful so as not to trigger its + premature elaboration. */ if ((!definition || (is_type && imported_p)) && present_gnu_tree (gnat_entity)) { @@ -297,7 +298,9 @@ gnat_to_gnu_entity (Entity_Id gnat_entit if (TREE_CODE (gnu_decl) == TYPE_DECL && TYPE_IS_DUMMY_P (TREE_TYPE (gnu_decl)) && IN (kind, Incomplete_Or_Private_Kind) - && Present (Full_View (gnat_entity))) + && Present (Full_View (gnat_entity)) + && (present_gnu_tree (Full_View (gnat_entity)) + || No (Freeze_Node (Full_View (gnat_entity))))) { gnu_decl = gnat_to_gnu_entity (Full_View (gnat_entity), NULL_TREE, 0); Index: gcc-interface/trans.c =================================================================== --- gcc-interface/trans.c (revision 199330) +++ gcc-interface/trans.c (working copy) @@ -8723,7 +8723,7 @@ process_type (Entity_Id gnat_entity) if (Present (Freeze_Node (gnat_entity)) || (IN (Ekind (gnat_entity), Incomplete_Or_Private_Kind) && Present (Full_View (gnat_entity)) - && Freeze_Node (Full_View (gnat_entity)) + && Present (Freeze_Node (Full_View (gnat_entity))) && !present_gnu_tree (Full_View (gnat_entity)))) { elaborate_entity (gnat_entity);