From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by sourceware.org (Postfix) with ESMTPS id 480743857369 for ; Thu, 2 Jun 2022 09:08:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 480743857369 Received: by mail-ej1-x62b.google.com with SMTP id m20so8675258ejj.10 for ; Thu, 02 Jun 2022 02:08:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=GQCk2RPahhbK2NZ2qrN0NGTvKqvBVDEtbuj/VYbXMlc=; b=IbgTTBaa+cgx3LJ6CbZui36UhEMGipbVyO/kQ17ehZTYA9bPRv5noaQhzvztuI1YRf EUmWRCbuPSpkLdMaxQeXsf9WwBF2O4yefnQdbyznYvYn/ShrpVL10ROBVxUW3OkqxkF8 Rca2o7wUmotgTsUg+nw3qY5juEAxNlWOwBdiX3yFkLm1CpZrmRUOfXd6F00Wt1Vi0Aua fw0tkMs1U8348SJUBa2+dxPKBoXG1suLxnebOyfK+wF1W9DCfLQaOFjHw6cKt3Nek6c6 6QZldW3bThGKE29oGfKNGLcTik1TkJIS6x194ZoX7UDqBdBq+JnmJa+Pt0mf92yakjZy eBhQ== X-Gm-Message-State: AOAM530bLX7L1aC48ZNEKYWWQ1CuL3y/KDwIelFNY85K/MRhia0f/+gJ zt7WHCbMrEt2DgijSc9U8QbVAZsevq3sjg== X-Google-Smtp-Source: ABdhPJy00aFuD4R7yjB+G5FMtHWR6a3bO0vwoFg2fW+nn8rV5k1KPMOS2kpGDs9gGk24LVSO8IuYww== X-Received: by 2002:a17:907:c0f:b0:6ff:a147:32a2 with SMTP id ga15-20020a1709070c0f00b006ffa14732a2mr3167495ejc.339.1654160936066; Thu, 02 Jun 2022 02:08:56 -0700 (PDT) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id t11-20020a17090605cb00b00706c1327f4bsm1556774ejt.23.2022.06.02.02.08.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jun 2022 02:08:55 -0700 (PDT) Date: Thu, 2 Jun 2022 09:08:55 +0000 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [Ada] Fix detection of deferred constants for freezing error Message-ID: <20220602090855.GA1010649@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="7AUc2qLy4jB3hD7Z" Content-Disposition: inline X-Spam-Status: No, score=-13.2 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Jun 2022 09:08:58 -0000 --7AUc2qLy4jB3hD7Z Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Testing Is_Frozen is not robust enough, so instead test that the full view has been seen and that the Has_Completion flag is set on it. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * freeze.adb (Check_Expression_Function.Find_Constant): Make test for deferred constants more robust. --7AUc2qLy4jB3hD7Z Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="patch.diff" diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -1458,7 +1458,8 @@ package body Freeze is N_Object_Declaration and then not Is_Imported (Entity (Nod)) and then not Has_Completion (Entity (Nod)) - and then not Is_Frozen (Entity (Nod)) + and then not (Present (Full_View (Entity (Nod))) + and then Has_Completion (Full_View (Entity (Nod)))) then Error_Msg_NE ("premature use of& in call or instance", N, Entity (Nod)); --7AUc2qLy4jB3hD7Z--