[COMMITTED] ada: Fix internal error on expression function with Refined_Post aspect

Message ID 20230915142052.2100773-1-poulhies@adacore.com
State Accepted
Headers
Series [COMMITTED] ada: Fix internal error on expression function with Refined_Post aspect |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Marc Poulhiès Sept. 15, 2023, 2:20 p.m. UTC
  From: Eric Botcazou <ebotcazou@adacore.com>

This occurs when the expression function calls a protected function and the
-gnata switch is specified, because the compiler wrongly freezes the called
function when analyzing the expression function, a fallout of the wrapping
scheme used for the Post and Refined_Post aspects.

gcc/ada/

	* sem_res.adb (Resolve_Call): When the target is an entity, do not
	freeze it if the current scope is the inner wrapper function built
	for an expression function with a Post or Refined_Post aspect.

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

---
 gcc/ada/sem_res.adb | 3 +++
 1 file changed, 3 insertions(+)
  

Patch

diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index c708d04fc32..b8d8e701ae3 100644
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -6582,6 +6582,9 @@  package body Sem_Res is
       if Is_Entity_Name (Subp)
         and then not In_Spec_Expression
         and then not Is_Expression_Function_Or_Completion (Current_Scope)
+        and then not (Chars (Current_Scope) = Name_uWrapped_Statements
+                       and then Is_Expression_Function_Or_Completion
+                                  (Scope (Current_Scope)))
         and then
           (not Is_Expression_Function_Or_Completion (Entity (Subp))
             or else Expander_Active)