diff mbox series

[COMMITTED,10/26] ada: Compiler accepts illegal assignment to reference type target.

Message ID 20240802071210.413366-10-poulhies@adacore.com
State New
Headers show
Series [COMMITTED,01/26] ada: Fix detection of suspicious loop patterns | expand

Commit Message

Marc Poulhiès Aug. 2, 2024, 7:11 a.m. UTC
From: Steve Baird <baird@adacore.com>

An assignment statement whose LHS is of a reference type is never legal. If
no other legality rule is violated, then it is ambiguous. In some cases this
ambiguity was not correctly detected.

gcc/ada/

	* sem_ch5.adb (Analyze_Assignment): Delete code that was
	incorrectly implementing a preference rule.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/sem_ch5.adb | 8 --------
 1 file changed, 8 deletions(-)
diff mbox series

Patch

diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb
index 4db3a1a26ee..d44a12d1dd1 100644
--- a/gcc/ada/sem_ch5.adb
+++ b/gcc/ada/sem_ch5.adb
@@ -437,14 +437,6 @@  package body Sem_Ch5 is
                then
                   null;
 
-               --  This may be a call to a parameterless function through an
-               --  implicit dereference, so discard interpretation as well.
-
-               elsif Is_Entity_Name (Lhs)
-                 and then Has_Implicit_Dereference (It.Typ)
-               then
-                  null;
-
                elsif Has_Compatible_Type (Rhs, It.Typ) then
                   if T1 = Any_Type then
                      T1 := It.Typ;