From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by sourceware.org (Postfix) with ESMTPS id 6AD77385AF85 for ; Tue, 18 Jul 2023 13:13:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6AD77385AF85 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-4fc8049fd8bso9043336e87.2 for ; Tue, 18 Jul 2023 06:13:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1689686011; x=1690290811; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=4bh2lKw3o0FrY4EaW+XYXapAcNUgAnm45SyeAvsxcHM=; b=QBl+EBxbc/Eihwv3o6VUQPdTLgifjXj23AEPhJ/uNZb2vlqgMZA0rrTHXObD/8METV SurP3KJ5++G5AacZzfeWLJMsiqGG/n8MmO3to2uBMNUtbXQY/hYq3V+YFQ7WvDPNZmvG jb4voCrIT+sSptY2wr/HnppUtXoQOO0hvdklLQh+MZSbFQAXutDczwtYIlsDYxd79s/i QpzLeV468SRUdP2QDAYm2I4vDJBvJ9+JILZIhm+377iv1+BxbYHlYvqhoo2AIw/iE6IT W78TmHQvXGKUOCQYzG4WZKahyUONNS+2rpxFCqxaa+zvttc3eegG0oPYo2as5xbhcOV8 517g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689686011; x=1690290811; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=4bh2lKw3o0FrY4EaW+XYXapAcNUgAnm45SyeAvsxcHM=; b=FWm3R2H1+C92sRyf8zjNelhaE5qKntfhWQnOM142nX5NCtlQotv0DeJSTwxmLFM/D3 mYUZRNzQOXSo/cPYV7VybgJC+vozUZYjYdrsmSYUj/KLh569ZuGG7i9rSMl3Lyz3FliV pjlp1Z7cMZGmHnZkCqHYVbrM+q6RDIH2Eu2LwBv5Bx3M14YnsJoFmixHVJbAUqzEQalz XphJhyruHnEwcFuZ9sQy/cCcMRI9+JoyrY8Dz6i8juQdq1GUI5dRtCvvslHAKyMqFBcs l3LvLC77tAAcTAeHDvShA0RB++MWsUUSnx/OboaoIP1Mkx+EMYJ8XUy3+T6ARBj2gBIX U/jg== X-Gm-Message-State: ABy/qLYiMfHZl0u/hgs3KkFPwWAIdkuBTEEi/AjdzXEgOBCGB+VEQDB9 wF1IFEjdWBb/0PMI5eMEZB6eIcyBs9xxtb2vkpw8Lw== X-Google-Smtp-Source: APBJJlHBjmAtQZvyAxTlMTBf/83VTSYpoCdrcPA9obSflpsyt+iOvsP8hVJInrjL6sQ7LLvxEGgKEA== X-Received: by 2002:a19:ca52:0:b0:4f8:6d54:72fb with SMTP id h18-20020a19ca52000000b004f86d5472fbmr8803339lfj.62.1689686011008; Tue, 18 Jul 2023 06:13:31 -0700 (PDT) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id i1-20020a05600c290100b003fbfa6066acsm2079643wmd.40.2023.07.18.06.13.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jul 2023 06:13:30 -0700 (PDT) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED] ada: Fix assertion failure introduced by latest change Date: Tue, 18 Jul 2023 15:13:29 +0200 Message-Id: <20230718131329.81009-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: From: Eric Botcazou The new processing is not properly guarded. gcc/ada/ * sem_ch13.adb (Replace_Type_References_Generic.Visible_Component): In the case of private discriminated types, explicitly check that we have a private declaration before examining its discriminant part. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch13.adb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index 4f97094aae5..585c0f33d8b 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -15593,8 +15593,6 @@ package body Sem_Ch13 is elsif Is_Private_Type (T) and then Has_Discriminants (T) then declare Decl : constant Node_Id := Declaration_Node (T); - Spec : constant List_Id := - Discriminant_Specifications (Original_Node (Decl)); Discr : Node_Id; @@ -15604,8 +15602,11 @@ package body Sem_Ch13 is -- name; then, if it exists, return the discriminant entity of -- the same name in the type, which is that of its full view. - if Present (Spec) then - Discr := First (Spec); + if Nkind (Decl) in N_Private_Extension_Declaration + | N_Private_Type_Declaration + and then Present (Discriminant_Specifications (Decl)) + then + Discr := First (Discriminant_Specifications (Decl)); while Present (Discr) loop if Chars (Defining_Identifier (Discr)) = Comp then -- 2.40.0