]> gcc.gnu.org Git - gcc.git/commitdiff
[Ada] Add second warning for convention C_Variadic_n
authorEric Botcazou <ebotcazou@adacore.com>
Thu, 23 Apr 2020 12:26:48 +0000 (14:26 +0200)
committerGiuliano Belinassi <giuliano.belinassi@usp.br>
Mon, 17 Aug 2020 16:13:52 +0000 (13:13 -0300)
2020-06-18  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

* sem_prag.adb (Process_Convention): Give a warning on C_Variadic_n
being applied to a subprogram with exactly n parameters.

gcc/ada/sem_prag.adb

index 689c728294745b6deb88ca52c9c666c6ce1e6a85..e9cfb13a830d0645fe561e64d96d060db384016f 100644 (file)
@@ -8323,11 +8323,21 @@ package body Sem_Prag is
                      Next_Formal (Formal);
                   end loop;
 
+                  --  Error out if the number of parameters is lower than n
+
                   if Count < Minimum then
                      Error_Msg_Uint_1 := UI_From_Int (Minimum);
                      Error_Pragma_Arg
                        ("argument of pragma% must have at least"
                         & "^ parameters", Arg2);
+
+                  --  But warn if it is exactly n because this is useless
+
+                  elsif Count = Minimum then
+                     Error_Msg_Uint_1 := UI_From_Int (Minimum + 1);
+                     Error_Msg_N
+                       ("??subprogram should have at least ^ parameters",
+                        Get_Pragma_Arg (Arg2));
                   end if;
                end;
             end if;
This page took 0.096636 seconds and 5 git commands to generate.