From patchwork Wed Nov 10 08:58:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 47374 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 43C1A3857C56 for ; Wed, 10 Nov 2021 09:10:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 43C1A3857C56 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1636535406; bh=0kmdbMiREkRGMjMBOtbiJpAWAS39sOrrMs7S2fx9XN0=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=tBW8EkisXKG8OhrSpCSsLvEcjIg5oK2SBqqKXe0vik9TrxUb6XvMzVni4mB/zMK0u B5pJ7qFeX5pTbZU2YVonFV4Z3bRZ39TvAp7Y2SMnoBKVtWs3eWSI2Nbowpyogfe55O pHJPRM+O9hVSH4UmZWGkJOeSm/PiZ2n5XS4Y+aWA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by sourceware.org (Postfix) with ESMTPS id 1D87A3857C51 for ; Wed, 10 Nov 2021 08:58:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1D87A3857C51 Received: by mail-lf1-x133.google.com with SMTP id u11so4389004lfs.1 for ; Wed, 10 Nov 2021 00:58:48 -0800 (PST) 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=0kmdbMiREkRGMjMBOtbiJpAWAS39sOrrMs7S2fx9XN0=; b=KmsYuO55Res+nvJqCuRAfMrPwExFRjbnJinLyPLJKnoRBzz2hixPXYBWTci6Av8mjW hntyLyTkCMlS0ceF6uo5RlyEEmfdEnbC1D57HnkfkhYeO4K6eEMu+VkTEYAweiaT9kvq ei0LSDpxQJ3nIwG7l/47O2XCMF5lBZl/X7OESNY8Vh/W/SZH6I0PIzWjhUamuDOS0X5R /CUUg7qLB98wWGrdbx+nKoA4uzMH+chW1WkN3LL8Vr9C13PGjH8v40Pn+oeJEb5XynSQ cs5yyqa5lgW91cMroky3SlSM3JegCg/zodfTdC1cCU4CLWrYNOa+NjXIoXGYxNKan/h3 6F+g== X-Gm-Message-State: AOAM531HDZQT0Zdjkf7cFO1hr+8llqJBeJH4Ze9DCVfA/DV1+5KAB8oO 10Wzcvm3YIRmu6+sEGXcdGRcX7qzz78Qcg== X-Google-Smtp-Source: ABdhPJxrgFuKIpjiLy5xngmoY3UdG3OHRf8XafImFLB4nFLJ6NKaCjR61e5+d2nvxJoqwjfD89lAHQ== X-Received: by 2002:a05:6512:30d:: with SMTP id t13mr12420676lfp.322.1636534727037; Wed, 10 Nov 2021 00:58:47 -0800 (PST) Received: from adacore.com ([2a02:2ab8:224:2ce:72b5:e8ff:feef:ee60]) by smtp.gmail.com with ESMTPSA id m14sm2402641lfg.235.2021.11.10.00.58.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Nov 2021 00:58:46 -0800 (PST) Date: Wed, 10 Nov 2021 08:58:45 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] Avoid warnings regarding rep clauses in generics Message-ID: <20211110085845.GA2811200@adacore.com> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-13.0 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 autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-Patchwork-Original-From: Pierre-Marie de Rodat via Gcc-patches From: Pierre-Marie de Rodat Reply-To: Pierre-Marie de Rodat Cc: Bob Duff Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Representation-related node fields are not set for types in generic units, so we should not warn based on the values of such fields. Also avoid printing the values of such fields for -gnatR. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * repinfo.adb (List_Common_Type_Info, List_Object_Info): Add check for In_Generic_Scope. (List_Component_Layout): Check for known static values. * sem_ch13.adb (Check_Record_Representation_Clause): Add check for In_Generic_Scope. diff --git a/gcc/ada/repinfo.adb b/gcc/ada/repinfo.adb --- a/gcc/ada/repinfo.adb +++ b/gcc/ada/repinfo.adb @@ -38,6 +38,7 @@ with Output; use Output; with Osint.C; use Osint.C; with Sem_Aux; use Sem_Aux; with Sem_Eval; use Sem_Eval; +with Sem_Util; with Sinfo; use Sinfo; with Sinfo.Nodes; use Sinfo.Nodes; with Sinfo.Utils; use Sinfo.Utils; @@ -426,11 +427,14 @@ package body Repinfo is end if; -- Alignment is not always set for task, protected, and class-wide - -- types. + -- types. Representation aspects are not computed for types in a + -- generic unit. else pragma Assert - (Is_Concurrent_Type (Ent) or else Is_Class_Wide_Type (Ent)); + (Is_Concurrent_Type (Ent) or else + Is_Class_Wide_Type (Ent) or else + Sem_Util.In_Generic_Scope (Ent)); end if; end List_Common_Type_Info; @@ -902,6 +906,13 @@ package body Repinfo is procedure List_Object_Info (Ent : Entity_Id) is begin + -- The information has not been computed in a generic unit, so don't try + -- to print it. + + if Sem_Util.In_Generic_Scope (Ent) then + return; + end if; + Write_Separator; if List_Representation_Info_To_JSON then @@ -1176,13 +1187,17 @@ package body Repinfo is Write_Str (" range "); end if; - Sbit := Starting_First_Bit + Fbit; + if Known_Static_Normalized_First_Bit (Ent) then + Sbit := Starting_First_Bit + Fbit; - if Sbit >= SSU then - Sbit := Sbit - SSU; - end if; + if Sbit >= SSU then + Sbit := Sbit - SSU; + end if; - UI_Write (Sbit, Decimal); + UI_Write (Sbit, Decimal); + else + Write_Unknown_Val; + end if; if List_Representation_Info_To_JSON then Write_Line (", "); diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -12618,9 +12618,11 @@ package body Sem_Ch13 is end if; -- Skip the following warnings if overlap was detected; programmer - -- should fix the errors first. + -- should fix the errors first. Also skip the warnings for types in + -- generics, because their representation information is not fully + -- computed. - if not Overlap_Detected then + if not Overlap_Detected and then not In_Generic_Scope (Rectype) then -- Check for record holes (gaps) if Warn_On_Record_Holes then