public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/c++-modules] [Ada] Add second warning for convention C_Variadic_n
@ 2020-06-29 21:04 Nathan Sidwell
  0 siblings, 0 replies; only message in thread
From: Nathan Sidwell @ 2020-06-29 21:04 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:0c32ab8232a40d8bb982c0ac13864d2290dc9336

commit 0c32ab8232a40d8bb982c0ac13864d2290dc9336
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Thu Apr 23 14:26:48 2020 +0200

    [Ada] Add second warning for convention C_Variadic_n
    
    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.

Diff:
---
 gcc/ada/sem_prag.adb | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
index 689c7282947..e9cfb13a830 100644
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -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;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-06-29 21:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-29 21:04 [gcc/devel/c++-modules] [Ada] Add second warning for convention C_Variadic_n Nathan Sidwell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).