From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by sourceware.org (Postfix) with ESMTPS id AC1B93882012 for ; Tue, 16 May 2023 08:41:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AC1B93882012 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-wr1-x42c.google.com with SMTP id ffacd0b85a97d-3063afa2372so12890150f8f.0 for ; Tue, 16 May 2023 01:41:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1684226487; x=1686818487; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=+eSzq0+ZndjT33wYhWhK0WJmxI+zaUGF9n6fixSCKPM=; b=HQGM0wL+tW2T/RA4WHmxk17tmJQb2ihlLMwsbYBXQ85SzA6fgevG9iezAQZwpd5iVC GQCtZpbmyEXz9+WlPOvuRxPfaRwhoQCph3nLwuv1Ol1Vnutx5I14TtGeAC3Xzc+p+GlS bDgGI8MC+3kCrQ+O/ddnMdE+LAAWvw7RD/5saKMJxfbNh8bSNeZBE6/xHsQzCE0pFEUX i53ueC8RoamyvEdvicVKHMe/4MK745J7jC7E1tUOi4xzHufautmYmqz5HJpr4ZdZHYP8 7wUW4T1857wSPz7GFbHUUp/t6In/LWWFSvaEptqlZWFkID+rWbFPjrY94sVpufMDbS8G f33Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684226487; x=1686818487; 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=+eSzq0+ZndjT33wYhWhK0WJmxI+zaUGF9n6fixSCKPM=; b=H3P0sOLL4Xh4oYrkXInXuBBXQwq/sPq6khevfzfPgdgAcO18FvgrpAQguYPUjL/oaz wwRbG+cwiDgFGyHN+PF5zcsrZ5JJ/314i1WIsoeb96wvhrrKdD3oTYVOn23ZR7rZqCZH oXDhkE8Y/DwcAf+JcxoKwXGFI0SQUeus0+rrRkh8TMHEM7URSgOeCBx3a28UEjRuCMqM cvnF55xmqq1l17729dn/xJT22PEhxWSoJS30Op/5cssklLSb8mIkpwYuxrfQguhpYKxr Pl79aF037fe0qCt9UR2Qa7IfeitUJxHrEKK9Hu+e8K3FeZpZRTlQAJtDsGVKmjDxnK8g hVwg== X-Gm-Message-State: AC+VfDyZYJXqmOx8PWjRVy6C0B9bu9RPwfIbFkEgB3VWVv6Dgagsmg6D XOFh0mCayLbipsqcy+fBVM26Jfw60tgZ6HAtcmQ/5g== X-Google-Smtp-Source: ACHHUZ4MAjTluU6DWtTzowtXFRqBdMbtiCgNodILAIVDp46jlZp6V2MCDLqCuhNqQW/KILMQjGXZFQ== X-Received: by 2002:adf:f5c6:0:b0:306:b3f8:690f with SMTP id k6-20020adff5c6000000b00306b3f8690fmr34112064wrp.36.1684226487424; Tue, 16 May 2023 01:41:27 -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 z5-20020adfec85000000b0030795249ffasm1771034wrn.92.2023.05.16.01.41.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 01:41:26 -0700 (PDT) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED] ada: Fix internal error on chain of predicated record types Date: Tue, 16 May 2023 10:41:25 +0200 Message-Id: <20230516084125.1502265-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.5 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 preanalysis of a predicate set on one of the record types was causing premature freezing of another record type. gcc/ada/ * sem_ch13.adb: Add with and use clauses for Expander. (Resolve_Aspect_Expressions) : Emulate a bona-fide preanalysis setup before calling Resolve_Aspect_Expression. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch13.adb | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index 1c757228241..a4a5084793e 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -38,6 +38,7 @@ with Exp_Ch3; use Exp_Ch3; with Exp_Disp; use Exp_Disp; with Exp_Tss; use Exp_Tss; with Exp_Util; use Exp_Util; +with Expander; use Expander; with Freeze; use Freeze; with Ghost; use Ghost; with Lib; use Lib; @@ -15625,15 +15626,29 @@ package body Sem_Ch13 is -- Preanalyze expression after type replacement to catch -- name resolution errors if the predicate function has -- not been built yet. + -- Note that we cannot use Preanalyze_Spec_Expression - -- because of the special handling required for - -- quantifiers, see comments on Resolve_Aspect_Expression - -- above. + -- directly because of the special handling required for + -- quantifiers (see comments on Resolve_Aspect_Expression + -- above) but we need to emulate it properly. if No (Predicate_Function (E)) then - Push_Type (E); - Resolve_Aspect_Expression (Expr); - Pop_Type (E); + declare + Save_In_Spec_Expression : constant Boolean := + In_Spec_Expression; + Save_Full_Analysis : constant Boolean := + Full_Analysis; + begin + In_Spec_Expression := True; + Full_Analysis := False; + Expander_Mode_Save_And_Set (False); + Push_Type (E); + Resolve_Aspect_Expression (Expr); + Pop_Type (E); + Expander_Mode_Restore; + Full_Analysis := Save_Full_Analysis; + In_Spec_Expression := Save_In_Spec_Expression; + end; end if; when Pre_Post_Aspects => -- 2.40.0