aboutsummaryrefslogtreecommitdiff
path: root/gcc/cppdefault.h
diff options
context:
space:
mode:
authorGary Dismukes <dismukes@adacore.com>2025-02-28 00:08:19 +0000
committerEric Botcazou <ebotcazou@adacore.com>2025-06-09 10:20:58 +0200
commit8a63f6bd618decc974a46c50894f3b450e025f95 (patch)
treea86f20f2877daa5405eb1d29baa31bb0daa66feb /gcc/cppdefault.h
parent823e9733520536cf1fc427d6a128f5a7a48cc3b5 (diff)
downloadgcc-8a63f6bd618decc974a46c50894f3b450e025f95.zip
gcc-8a63f6bd618decc974a46c50894f3b450e025f95.tar.gz
gcc-8a63f6bd618decc974a46c50894f3b450e025f95.tar.bz2
ada: Incorrect creation of corresponding expression of class-wide contracts
GNAT was incorrectly implementing the Ada rules for resolving calls to primitive functions within inherited class-wide pre- and postconditions, as specified in RM22 6.1.1 (relating to AI12-0113). Only function calls that involve formals of the associated primitive subprogram should be treated using the "(notional) formal derived type" rules. In particular, calls that are tag-indeterminate (for example, "F(G)") should not be mapped to call the corresponding primitives of the derived type (they should still call the primitives of the ancestor type). The fix for this involves a new predicate function that recursively traverses calls to determine the calls that satisfy the criteria for mapping. These changes also completely remove the mapping of formals that was done in Contracts.Merge_Class_Conditions (in Inherit_Condition), since the mapping will be done later anyway by Build_Class_Wide_Expression, and the earlier mapping interferes with that. Note: The utility function Sem_Util.Check_Parents is no longer called after removal of the single call to it from contracts.adb, but it's being retained (along with the generic subprograms in Atree that it depends on) for possible use in VAST. gcc/ada/ChangeLog: * contracts.adb (Inherit_Condition): Remove Assoc_List and its uses along with function Check_Condition, since mapping of formals will effectively be done in Build_Class_Wide_Expression (by Replace_Entity). * exp_util.adb (Replace_Entity): Only rewrite entity references in function calls that qualify according to the result of calling the new function Call_To_Parent_Dispatching_Op_Must_Be_Mapped. (Call_To_Parent_Dispatching_Op_Must_Be_Mapped): New function that determines whether a function call to a primitive of Par_Subp associated tagged type needs to be mapped (according to whether it has any actuals that reference controlling formals of the primitive).
Diffstat (limited to 'gcc/cppdefault.h')
0 files changed, 0 insertions, 0 deletions