From patchwork Tue Apr 25 08:29:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 754639 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wBxGl4n9kz9s82 for ; Tue, 25 Apr 2017 18:30:06 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="WHwNR3KN"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=Gw168uWHSKlVn/WiY2oMQKIep9DQ9LY+1wKOQDcheta0eHQqKp vsjYCppNZyusf6tHojHmxMwK5UBS93hikw8gZb62Ke7y268Gzv3SvjdhTZccm4ZP PLmb1vwUqVYFJGshN7aG7l3b4JBMsImVoeNJXeOZkefwDkxWlhytTqR0I= 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:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=H1tp0jxLMIzv1deaHdepn5vDSO4=; b=WHwNR3KNf9bRgUG1oIFN RgZFGzGwm+ViEv+CPyIuz0zVhwnFdEtIoQPY2I1EtgXxH2mhXMdNnFPeRV8X2xVX Rr5NQBzpHIRRpWvqw4k+9NzSyl0Nu+u3ckHaVvsLDjd1Nf0MHvn0aKtMIQ+cFrKn nMA+HQAnmc8hXlayXgqYv4Y= Received: (qmail 11415 invoked by alias); 25 Apr 2017 08:29:56 -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 11379 invoked by uid 89); 25 Apr 2017 08:29:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS, T_FILL_THIS_FORM_SHORT autolearn=ham version=3.3.2 spammy= X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 25 Apr 2017 08:29:54 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 01F54129985; Tue, 25 Apr 2017 04:29:55 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id JNHe1S1ivbqw; Tue, 25 Apr 2017 04:29:54 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [205.232.38.10]) by rock.gnat.com (Postfix) with ESMTP id E2FE629DCA; Tue, 25 Apr 2017 04:29:54 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4192) id DEF90521; Tue, 25 Apr 2017 04:29:54 -0400 (EDT) Date: Tue, 25 Apr 2017 04:29:54 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Javier Miranda Subject: [Ada] Crash processing discriminants of private subtype Message-ID: <20170425082954.GA75839@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) The compiler may crash processing a private tagged record type has some component whose type is a subtype of a private type. After this patch the following test compiles without errors. package Other_Type is package BS is type Bounded_String is private; private type Super_String (Max_Length : Positive) is record null; end record; type Bounded_String is new Super_String (10); end; type S is new BS.Bounded_String; end; with Other_Type; package Pkg is type Key_Type is private; private type Key_Type is new Other_Type.S; end; package Pkg.Gen_Instance is type T is tagged null record; private subtype A_T is Key_Type; type Derived is new T with record -- Test X : A_T; end record; end; Command: gcc -c pkg-gen_instance.ads Tested on x86_64-pc-linux-gnu, committed on trunk 2017-04-25 Javier Miranda * exp_ch3.adb (Build_Initialization_Call): Handle subtypes of private types when searching for the underlying full view of a private type. Index: exp_ch3.adb =================================================================== --- exp_ch3.adb (revision 247143) +++ exp_ch3.adb (working copy) @@ -1451,6 +1451,12 @@ elsif Is_Generic_Actual_Type (Full_Type) then Full_Type := Base_Type (Full_Type); + elsif Ekind (Full_Type) = E_Private_Subtype + and then (not Has_Discriminants (Full_Type) + or else No (Discriminant_Constraint (Full_Type))) + then + Full_Type := Etype (Full_Type); + -- The loop has recovered the [underlying] full view, stop the -- traversal.