aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEd Schonberg <schonberg@adacore.com>2020-03-09 16:36:55 -0400
committerPierre-Marie de Rodat <derodat@adacore.com>2020-06-10 09:35:01 -0400
commitf95fb9d019147b2af0c8107d6c6a6e2b6034d9fe (patch)
tree913a557c8d58290cee8e233d9625d1ab1e299a0c /gcc
parent67a44a4c109e6b2e684e96c346ec0f0fc1f56591 (diff)
downloadgcc-f95fb9d019147b2af0c8107d6c6a6e2b6034d9fe.zip
gcc-f95fb9d019147b2af0c8107d6c6a6e2b6034d9fe.tar.gz
gcc-f95fb9d019147b2af0c8107d6c6a6e2b6034d9fe.tar.bz2
[Ada] Additional warnings on overlapping actuals of composite types
2020-06-10 Ed Schonberg <schonberg@adacore.com> gcc/ada/ * sem_warn.adb (Warn_On_Overlapping_Actuals): Add a warning when two actuals in a call overlap, both are composite types that may be passed by reference, and only one of them is writable.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/sem_warn.adb18
1 files changed, 17 insertions, 1 deletions
diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb
index b84e82e..a3195a1 100644
--- a/gcc/ada/sem_warn.adb
+++ b/gcc/ada/sem_warn.adb
@@ -3742,10 +3742,26 @@ package body Sem_Warn is
-- If appropriate warning switch is set, we also report warnings on
-- overlapping parameters that are record types or array types.
+ -- It is also worthwhile to warn on overlaps of composite objects when
+ -- only one of the formals is (in)-out. Note that the RM rule above is
+ -- a legality rule. We choose to implement this check as a warning to
+ -- avoid major incompatibilities with legacy code. We exclude internal
+ -- sources from the warning, because subprograms in Container libraries
+ -- would be affected by the warning.
+
+ -- Note also that the rule in 6.4.1 (6.17/3), introduced by AI12-0324,
+ -- is potentially more expensive to verify, and is not yet implemented.
+
+ if Is_Internal_Unit (Current_Sem_Unit) then
+ return;
+ end if;
+
Form1 := First_Formal (Subp);
Act1 := First_Actual (N);
while Present (Form1) and then Present (Act1) loop
- if Is_Covered_Formal (Form1) then
+ if Is_Covered_Formal (Form1)
+ or else not Is_Elementary_Type (Etype (Act1))
+ then
Form2 := First_Formal (Subp);
Act2 := First_Actual (N);
while Present (Form2) and then Present (Act2) loop