diff mbox

[Ada] pragma Style_Checks (All_Checks) for -gnatg mode

Message ID 20100618094250.GA20659@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet June 18, 2010, 9:42 a.m. UTC
This patch modifies the behavior of pragma Style_Checks so that if
the argument All_Checks is used in -gnatg (GNAT) mode, then the
result is to set the standard GNAT style check options (-gnatyg)
rather than the normal default style checks (-gnatyy).

The following program is compiled in -gnatg mode:

     1. --  pragma Style_Checks (All_Checks);
     2. package AllChecks is
     3.
        |
        >>> (style) multiple blank lines

     4.
     5. end AllChecks;
     6.
        |
        >>> (style) blank line not allowed at end of file

Previously neither of these two errors was caught

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

2010-06-18  Robert Dewar  <dewar@adacore.com>

	* par-prag.adb (Prag, case Style_Checks): All_Checks sets gnat style
	for -gnatg.
	* sem_prag.adb (Analyze_Pragma, case Style_Checks): All_Checks sets
	gnat style for -gnatg.
	* gnat_rm.texi: Add documentation for ALL_CHECKS in GNAT mode.
diff mbox

Patch

Index: gnat_rm.texi
===================================================================
--- gnat_rm.texi	(revision 160961)
+++ gnat_rm.texi	(working copy)
@@ -4536,7 +4536,11 @@  gcc -c -gnatyl @dots{}
 The form ALL_CHECKS activates all standard checks (its use is equivalent
 to the use of the @code{gnaty} switch with no options.  @xref{Top,
 @value{EDITION} User's Guide, About This Guide, gnat_ugn,
-@value{EDITION} User's Guide}, for details.
+@value{EDITION} User's Guide}, for details.)
+
+Note: the behavior is slightly different in GNAT mode (@option{-gnatg} used).
+In this case, ALL_CHECKS implies the standard set of GNAT mode style check
+options (i.e. equivalent to -gnatyg).
 
 The forms with @code{Off} and @code{On}
 can be used to temporarily disable style checks
Index: par-prag.adb
===================================================================
--- par-prag.adb	(revision 160959)
+++ par-prag.adb	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2010, 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- --
@@ -943,7 +943,11 @@  begin
                OK := False;
 
             elsif Chars (A) = Name_All_Checks then
-               Stylesw.Set_Default_Style_Check_Options;
+               if GNAT_Mode then
+                  Stylesw.Set_GNAT_Style_Check_Options;
+               else
+                  Stylesw.Set_Default_Style_Check_Options;
+               end if;
 
             elsif Chars (A) = Name_On then
                Style_Check := True;
Index: sem_prag.adb
===================================================================
--- sem_prag.adb	(revision 160961)
+++ sem_prag.adb	(working copy)
@@ -11327,7 +11332,11 @@  package body Sem_Prag is
 
                elsif Nkind (A) = N_Identifier then
                   if Chars (A) = Name_All_Checks then
-                     Set_Default_Style_Check_Options;
+                     if GNAT_Mode then
+                        Set_GNAT_Style_Check_Options;
+                     else
+                        Set_Default_Style_Check_Options;
+                     end if;
 
                   elsif Chars (A) = Name_On then
                      Style_Check := True;