[COMMITTED,07/30] ada: Operator visibility bug in static expression functions

Message ID 20240801151738.400796-7-poulhies@adacore.com
State Committed
Commit ed8612ac09baa12d025a019b43acec975978ce9e
Headers
Series [COMMITTED,01/30] ada: Remove obsolete workaround |

Commit Message

Marc Poulhiès Aug. 1, 2024, 3:17 p.m. UTC
  From: Steve Baird <baird@adacore.com>

In some cases, an expanded name refering to a predefined operator (such as
Some_Package."+") occurring in a static expression function would be
incorrectly rejected with a message saying that the operator is not directly
visible (which, while True, does not make the reference illegal).

gcc/ada/

	* sem_ch4.adb (Is_Effectively_Visible_Opertor): Return True if
	Checking_Potentially_Static_Expression is True. The accompanying
	comment says True is returned "if there is a reason it is ok for
	Is_Visible_Operator to return False"; if
	Checking_Potentially_Static_Expression is true, that is such a
	reason.

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

---
 gcc/ada/sem_ch4.adb | 1 +
 1 file changed, 1 insertion(+)
  

Patch

diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb
index 2281ef9ce71..fc3a2a43c3c 100644
--- a/gcc/ada/sem_ch4.adb
+++ b/gcc/ada/sem_ch4.adb
@@ -278,6 +278,7 @@  package body Sem_Ch4 is
            (N /= Original_Node (N)
              and then Is_Effectively_Visible_Operator
                         (N => Original_Node (N), Typ => Typ))
+         or else Checking_Potentially_Static_Expression
          or else not Comes_From_Source (N));
    --  Return True iff either Is_Visible_Operator returns True or if
    --  there is a reason it is ok for Is_Visible_Operator to return False.