This is a regression present on the mainline, 14 and 13 branches: the compiler 
segfaults when warning about an uninitialized variable as operand of primitive 
operator of derived real type, because of a small internal adjustment.

Tested on x86-64/Linux, applied on the mainline, 14 and 13 branches.


2025-02-01  Eric Botcazou  <ebotca...@adacore.com>

        PR ada/118712
        * sem_warn.adb (Check_References): Deal with small adjustments of
        references.


2025-02-01  Eric Botcazou  <ebotca...@adacore.com>

        * gnat.dg/warn33.adb: New test.
        * gnat.dg/warn33_pkg.ads: New helper.

-- 
Eric Botcazou
diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb
index e460799da1f..35ef6166472 100644
--- a/gcc/ada/sem_warn.adb
+++ b/gcc/ada/sem_warn.adb
@@ -1257,6 +1257,10 @@ package body Sem_Warn is
                   UR := Unset_Reference (E1);
                end if;
 
+               --  Protect again small adjustments of reference
+
+               UR := Unqual_Conv (UR);
+
                --  Special processing for access types
 
                if Present (UR) and then Is_Access_Type (E1T) then
--  { dg-do compile }

with Warn33_Pkg; use Warn33_Pkg;

procedure Warn33 is
  Var : DerT;
begin
  Var := 1.0 - Var; -- { dg-warning "may be referenced before" }
end;
package Warn33_Pkg is

  type GenT is delta 1.0 range 1.0 .. 10.0;
  function "-" (X : GenT; Y : GenT) return GenT;
  type DerT is new GenT;

end Warn33_Pkg;

Reply via email to