aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_ch3.adb
diff options
context:
space:
mode:
authorJustin Squirek <squirek@adacore.com>2021-12-15 14:27:23 +0000
committerPierre-Marie de Rodat <derodat@adacore.com>2022-05-13 08:04:27 +0000
commitfa45988cc0129f95d1c8b1d386342b6351233ef5 (patch)
tree20fd5f9324b5f2372e9bd5baba9a57daa41d0214 /gcc/ada/sem_ch3.adb
parent74ce1d5a6cbcf81e21b4c0eeee372df46c275df0 (diff)
downloadgcc-fa45988cc0129f95d1c8b1d386342b6351233ef5.zip
gcc-fa45988cc0129f95d1c8b1d386342b6351233ef5.tar.gz
gcc-fa45988cc0129f95d1c8b1d386342b6351233ef5.tar.bz2
[Ada] Spurious access error in function returning type with access discriminant
This patch fixes an issue in the compiler whereby incorrect accessibility checks were generated in functions returning types with unconstrained access discriminants when the value supplied for the discriminant is a formal parameter. More specifically, accessibility checks for return statements featuring a result type having access discriminants were incorrectly being performed against the level of the function declaration instead of the level of the master of the call. gcc/ada/ * sem_ch6.adb (Check_Return_Construct_Accessibility): Modify generation of run-time accessibility checks to account for cases where Extra_Accessibility_Of_Result should be used versus the level of the enclosing subprogram. Use original node to avoid checking against expanded code. Disable check generation for tagged type case. (Is_Formal_Of_Current_Function): Added to encompass a predicate used within Check_Return_Construct_Accessibility to test if an associated expression is related to a relevant formal. * sem_util.adb, sem_util.ads (Enclosing_Subprogram): Modified to accept Node_Or_Entity_Id. (Innermost_Master_Scope_Depth): Calculate level based on the subprogram of a return statement instead of the one returned by Current_Subprogram. (Needs_Result_Accessibility_Level): Remove Disable_Coextension_Cases constant, and disable the tagged type case for performance reasons.
Diffstat (limited to 'gcc/ada/sem_ch3.adb')
0 files changed, 0 insertions, 0 deletions