]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Minor cleanups in generic formal matching
authorBob Duff <duff@adacore.com>
Mon, 29 Apr 2024 12:35:43 +0000 (08:35 -0400)
committerMarc Poulhiès <poulhies@adacore.com>
Thu, 13 Jun 2024 13:30:33 +0000 (15:30 +0200)
Minor rewording of a warning.
Disallow positional notation for <> (but disable this check),
and fix resulting errors.
Copy use clauses.

gcc/ada/

* sem_ch12.adb (Check_Fixed_Point_Actual): Minor rewording; it seems
more proper to say "operator" rather than "operation".
(Matching_Actual): Give an error for <> in positional notation.
This is a syntax error. Disable this for now.
(Analyze_Associations): Copy the use clause in all cases.
The "mustn't recopy" comment seems wrong, because New_Copy_Tree
preserves Slocs.
* libgnat/a-ticoau.ads: Fix violation of new postion-box error.
* libgnat/a-wtcoau.ads: Likewise.
* libgnat/a-ztcoau.ads: Likewise.

gcc/ada/libgnat/a-ticoau.ads
gcc/ada/libgnat/a-wtcoau.ads
gcc/ada/libgnat/a-ztcoau.ads
gcc/ada/sem_ch12.adb

index 223e823760457db4dc6706ad962ad3b2d8c265c8..58feea3af71c9581e70c248b3971c5501e653866 100644 (file)
@@ -42,7 +42,7 @@ private generic
 
    type Num is digits <>;
 
-   with package Aux is new Ada.Text_IO.Float_Aux (Num, <>, <>);
+   with package Aux is new Ada.Text_IO.Float_Aux (Num, others => <>);
 
 package Ada.Text_IO.Complex_Aux is
 
index 854b7b9fb60b8a4c83c7e65d019b3cd07d9bb436..781582dff9b4d0798b2cb69658b43a0d0bcc3f92 100644 (file)
@@ -42,7 +42,7 @@ private generic
 
    type Num is digits <>;
 
-   with package Aux is new Ada.Wide_Text_IO.Float_Aux (Num, <>, <>);
+   with package Aux is new Ada.Wide_Text_IO.Float_Aux (Num, others => <>);
 
 package Ada.Wide_Text_IO.Complex_Aux is
 
index 953ed5d9a184302d7d4d6066b6ac83c65b00c748..89f19e8e1d3f2a39330c11eb3d21810472d58207 100644 (file)
@@ -26,7 +26,7 @@ private generic
 
    type Num is digits <>;
 
-   with package Aux is new Ada.Wide_Wide_Text_IO.Float_Aux (Num, <>, <>);
+   with package Aux is new Ada.Wide_Wide_Text_IO.Float_Aux (Num, others => <>);
 
 package Ada.Wide_Wide_Text_IO.Complex_Aux is
 
index 7daa35f7fe18f5cec77ba258a18cde588b7a64c0..93e81fd95392badc36367f5b64105181936ddbc2 100644 (file)
@@ -1402,8 +1402,8 @@ package body Sem_Ch12 is
                if No (Formal) then
                   Error_Msg_Sloc := Sloc (Node (Elem));
                   Error_Msg_NE
-                    ("?instance uses predefined operation, not primitive "
-                     & "operation&#", Actual, Node (Elem));
+                    ("?instance uses predefined, not primitive, operator&#",
+                     Actual, Node (Elem));
                end if;
             end if;
 
@@ -1490,6 +1490,16 @@ package body Sem_Ch12 is
          --  Case of positional parameter corresponding to current formal
 
          elsif No (Selector_Name (Actual)) then
+            --  A "<>" without "name =>" is illegal syntax
+
+            if Box_Present (Actual) then
+               if False then -- ???
+                  --  Disable this for now, because we have various code that
+                  --  needs to be updated.
+                  Error_Msg_N ("box requires named notation", Actual);
+               end if;
+            end if;
+
             Found_Assoc := Actual;
             Act         := Explicit_Generic_Actual_Parameter (Actual);
             Num_Matched := Num_Matched + 1;
@@ -2208,22 +2218,12 @@ package body Sem_Ch12 is
                      end Explicit_Freeze_Check;
                   end if;
 
-               --  For use type and use package appearing in the generic part,
-               --  we have already copied them, so we can just move them where
-               --  they belong (we mustn't recopy them since this would mess up
-               --  the Sloc values).
+               --  Copy use clauses to where they belong
 
                when N_Use_Package_Clause
                   | N_Use_Type_Clause
                =>
-                  if Nkind (Original_Node (I_Node)) =
-                                     N_Formal_Package_Declaration
-                  then
-                     Append (New_Copy_Tree (Formal), Assoc_List);
-                  else
-                     Remove (Formal);
-                     Append (Formal, Assoc_List);
-                  end if;
+                  Append (New_Copy_Tree (Formal), Assoc_List);
 
                when others =>
                   raise Program_Error;