]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Improve error message for ambiguous subprogram call
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 5 Jul 2023 20:04:07 +0000 (22:04 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 18 Jul 2023 13:11:47 +0000 (15:11 +0200)
This restores the full listing of the types for the interpretations.

gcc/ada/

* sem_util.ads (Wrong_Type): Add Multiple parameter defaulting to
False and document it.
* sem_util.adb (Wrong_Type): Do not return early if an error has
already been posted on Expr and Multiple is True.
* sem_ch4.adb (Analyze_One_Call): Pass All_Errors_Mode as the
actual parameter for Multiple to Wrong_Type.

gcc/ada/sem_ch4.adb
gcc/ada/sem_util.adb
gcc/ada/sem_util.ads

index fafb7e63110007930d75cebf903a0ed6f059beb6..8543f0d578bc9df6d0855dd8d353b908962ddfd6 100644 (file)
@@ -4099,7 +4099,11 @@ package body Sem_Ch4 is
                            Actual, Etype (Etype (Formal)));
                      end if;
 
-                     Wrong_Type (Actual, Etype (Formal));
+                     --  If we are going to output a secondary error message
+                     --  below, we need to have Wrong_Type output the main one.
+
+                     Wrong_Type
+                       (Actual, Etype (Formal), Multiple => All_Errors_Mode);
 
                      if Nkind (Actual) = N_Op_Eq
                        and then Nkind (Left_Opnd (Actual)) = N_Identifier
index 222fd72a0614586a081b9ba71a2f92674370e08c..35ec296ab932c0780db0aba0f70887c8424737d2 100644 (file)
@@ -29398,7 +29398,11 @@ package body Sem_Util is
    -- Wrong_Type --
    ----------------
 
-   procedure Wrong_Type (Expr : Node_Id; Expected_Type : Entity_Id) is
+   procedure Wrong_Type
+     (Expr          : Node_Id;
+      Expected_Type : Entity_Id;
+      Multiple      : Boolean := False)
+   is
       Found_Type : constant Entity_Id := First_Subtype (Etype (Expr));
       Expec_Type : constant Entity_Id := First_Subtype (Expected_Type);
 
@@ -29485,13 +29489,14 @@ package body Sem_Util is
 
    begin
       --  Don't output message if either type is Any_Type, or if a message
-      --  has already been posted for this node. We need to do the latter
-      --  check explicitly (it is ordinarily done in Errout), because we
-      --  are using ! to force the output of the error messages.
+      --  has already been posted for this node and we do not want multiple
+      --  error messages. We need to do the latter check explicitly (it is
+      --  ordinarily done in Errout) because we are using '!' to force the
+      --  output of the error messages.
 
       if Expec_Type = Any_Type
         or else Found_Type = Any_Type
-        or else Error_Posted (Expr)
+        or else (Error_Posted (Expr) and then not Multiple)
       then
          return;
 
index 7fc77de2b8a385dbccb672bf7d0a69d6432a1c22..b56a235c02221bc2630062e6c75630bce8b83709 100644 (file)
@@ -3362,12 +3362,16 @@ package Sem_Util is
    --  is potentially issued: it is the visible entity in the former case, and
    --  the use_clause in the latter case.
 
-   procedure Wrong_Type (Expr : Node_Id; Expected_Type : Entity_Id);
+   procedure Wrong_Type
+     (Expr          : Node_Id;
+      Expected_Type : Entity_Id;
+      Multiple      : Boolean := False);
    --  Output error message for incorrectly typed expression. Expr is the node
    --  for the incorrectly typed construct (Etype (Expr) is the type found),
    --  and Expected_Type is the entity for the expected type. Note that Expr
    --  does not have to be a subexpression, anything with an Etype field may
-   --  be used.
+   --  be used. If Multiple is False, do not output the message if an error
+   --  has already been posted for Expr.
 
    function Yields_Synchronized_Object (Typ : Entity_Id) return Boolean;
    --  Determine whether type Typ "yields synchronized object" as specified by