[Ada] Preliminary work to coordinate Pragma Warnings and middle-end warnings

Message ID 20130206100102.GA13096@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet Feb. 6, 2013, 10:01 a.m.
This couple of adjustments paves the way for the full coordination of Pragma
Warnings with the warnings issued by the diagnostic engine of the middle-end.

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

2013-02-06  Eric Botcazou  <ebotcazou@adacore.com>

	* erroutc.adb (Validate_Specific_Warning): Do not issue the
	warning about an ineffective Pragma Warnings for -Wxxx warnings.
	* sem_prag.adb (Analyze_Pragma) <Warnings>: Accept -Wxxx warnings.
	* gnat_rm.texi (Pragma Warnings): Document coordination with
	warnings of the GCC back-end.


Index: erroutc.adb
--- erroutc.adb	(revision 195784)
+++ erroutc.adb	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2013, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -1282,7 +1282,14 @@ 
                     ("?pragma Warnings Off with no matching Warnings On",
-               elsif not SWE.Used then
+               --  Do not issue this warning for -Wxxx messages since the
+               --  back-end doesn't report the information.
+               elsif not SWE.Used
+                 and then not (SWE.Msg'Length > 2
+                                 and then SWE.Msg (1 .. 2) = "-W")
+               then
                     ("?no warning suppressed by this pragma", SWE.Start);
                end if;
Index: gnat_rm.texi
--- gnat_rm.texi	(revision 195784)
+++ gnat_rm.texi	(working copy)
@@ -6154,6 +6154,14 @@ 
 User's Guide}.
+The warnings controlled by the `-gnatw' switch are generated by the front end
+of the compiler. The `GCC' back end can provide additional warnings and they
+are controlled by the `-W' switch.
+The form with a single static_string_EXPRESSION argument also works for the
+latters, but the string must be a single full `-W' switch in this case.
+The above reference lists a few examples of these additional warnings.
 The specified warnings will be in effect until the end of the program
 or another pragma Warnings is encountered. The effect of the pragma is
 cumulative. Initially the set of warnings is the standard default set
@@ -6173,6 +6181,12 @@ 
 expression notations are permitted. All characters other than asterisk in
 these three specific cases are treated as literal characters in the match.
+The fourth form also works for the additional warnings of the `GCC' back end,
+but the string must again be a single full `-W' switch in this case. Note that
+the message issued for these warnings explicitly lists the full `-W' switch
+they are associated with.
 There are two ways to use the pragma in this form. The OFF form can be used as a
 configuration pragma. The effect is to suppress all warnings (if any)
 that match the pattern string throughout the compilation.
Index: sem_prag.adb
--- sem_prag.adb	(revision 195784)
+++ sem_prag.adb	(working copy)
@@ -16017,9 +16017,23 @@ 
                            if OK then
                               Chr := Get_Character (C);
+                              --  Dash case: only -Wxxx is accepted
+                              if J = 1
+                                and then J < Len
+                                and then Chr = '-'
+                              then
+                                 J := J + 1;
+                                 C := Get_String_Char (Str, J);
+                                 Chr := Get_Character (C);
+                                 if Chr = 'W' then
+                                    exit;
+                                 end if;
+                                 OK := False;
                               --  Dot case
-                              if J < Len and then Chr = '.' then
+                              elsif J < Len and then Chr = '.' then
                                  J := J + 1;
                                  C := Get_String_Char (Str, J);
                                  Chr := Get_Character (C);