diff mbox series

[Ada] Fix handling of generic types in check for overlapping actuals

Message ID 20210617143310.GA9742@adacore.com
State New
Headers show
Series [Ada] Fix handling of generic types in check for overlapping actuals | expand

Commit Message

Pierre-Marie de Rodat June 17, 2021, 2:33 p.m. UTC
In detection of overlapping actuals we were giving up on the first
formal parameter of a generic type, which caused errors to depend on the
order of parameters. Now we examine all parameters and simply ignore
generic ones.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* sem_warn.adb (Warn_On_Overlapping_Actuals): Ignore formal of
	generic types, but keep examining other parameters.
diff mbox series

Patch

diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb
--- a/gcc/ada/sem_warn.adb
+++ b/gcc/ada/sem_warn.adb
@@ -3741,17 +3741,20 @@  package body Sem_Warn is
       Form1 := First_Formal (Subp);
       Act1  := First_Actual (N);
       while Present (Form1) and then Present (Act1) loop
-         if Is_Generic_Type (Etype (Act1)) then
-            return;
-         end if;
 
          Form2 := Next_Formal (Form1);
          Act2  := Next_Actual (Act1);
          while Present (Form2) and then Present (Act2) loop
-            if Refer_Same_Object (Act1, Act2) then
-               if Is_Generic_Type (Etype (Act2)) then
-                  return;
-               end if;
+
+            --  Ignore formals of generic types; they will be examined when
+            --  instantiated.
+
+            if Is_Generic_Type (Etype (Form1))
+              or else Is_Generic_Type (Etype (Form2))
+            then
+               null;
+
+            elsif Refer_Same_Object (Act1, Act2) then
 
                --  Case 1: two writable elementary parameters that overlap