[Ada] Fix PR ada/118712

Message ID 3602717.dWV9SEqChM@fomalhaut
State New
Headers
Series [Ada] Fix PR ada/118712 |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gcc_build--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 fail Patch failed to apply

Commit Message

Eric Botcazou Feb. 1, 2025, 10:44 a.m. UTC
  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  <ebotcazou@adacore.com>

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


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

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

Patch

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