public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-5097] [Ada] Avoid warnings regarding rep clauses in generics Date: Wed, 10 Nov 2021 08:59:22 +0000 (GMT) [thread overview] Message-ID: <20211110085922.BF1A23858436@sourceware.org> (raw) https://gcc.gnu.org/g:db778c7022cc0e5b2b4100ccc7c2e52a0eaba3c0 commit r12-5097-gdb778c7022cc0e5b2b4100ccc7c2e52a0eaba3c0 Author: Bob Duff <duff@adacore.com> Date: Wed Nov 3 12:06:28 2021 -0400 [Ada] Avoid warnings regarding rep clauses in generics 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: --- gcc/ada/repinfo.adb | 29 ++++++++++++++++++++++------- gcc/ada/sem_ch13.adb | 6 ++++-- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/gcc/ada/repinfo.adb b/gcc/ada/repinfo.adb index b86885cec6c..a11057a1a49 100644 --- 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 index f6679456f2b..d63d60fb385 100644 --- 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
reply other threads:[~2021-11-10 8:59 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20211110085922.BF1A23858436@sourceware.org \ --to=pmderodat@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).