From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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-Archive: List-Post: List-Help: Sender: gcc-patches-owner@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 08:37:00 -0000 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-Type: multipart/mixed; boundary="BXVAT5kNtrzKuDFl" Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-SW-Source: 2017-04/txt/msg01110.txt.bz2 --BXVAT5kNtrzKuDFl Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1048 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. --BXVAT5kNtrzKuDFl Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=difs Content-length: 655 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. --BXVAT5kNtrzKuDFl--