diff mbox

[Ada] Missing style warning on overlong line is task subunit

Message ID 20160420102943.GA129683@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet April 20, 2016, 10:29 a.m. UTC
This patch restores a warning message on an overlong line in a subunit that
is a task body, when compiling the parent unit.

Compiling:

   gcc -c -gnatyM50 par.adb

must yield:

par-separated_task.adb:6:51: (style) this line is too long

---
opackage Par is

   task type Separated_Task is
      entry Start;
   end Separated_Task;

end Par;
---
package body Par is

   task body Separated_Task is separate;

end Par;
---
separate (Par)
task body Separated_Task is

   procedure Other is
   begin
      ----------------------------------------------------------- Too long
      null;
   end Other;
begin
   accept Start;
   Other;
end Separated_Task;

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

2016-04-20  Ed Schonberg  <schonberg@adacore.com>

	* sem.adb (Do_Analyze): Save and restore Style_Max_Line_Length
	so that the corresponding checks are preserved across compilations
	that include System.Constants in their context.
diff mbox

Patch

Index: sem.adb
===================================================================
--- sem.adb	(revision 235192)
+++ sem.adb	(working copy)
@@ -53,6 +53,7 @@ 
 with Sem_Util; use Sem_Util;
 with Sinfo;    use Sinfo;
 with Stand;    use Stand;
+with Stylesw;  use Stylesw;
 with Uintp;    use Uintp;
 with Uname;    use Uname;
 
@@ -1316,6 +1317,13 @@ 
       procedure Do_Analyze is
          Save_Ghost_Mode : constant Ghost_Mode_Type := Ghost_Mode;
 
+         --  Generally style checks are preserved across compilations, with
+         --  one exception: s-oscons.ads, which allows arbitrary long lines
+         --  unconditionally, and has no restore mechanism, because it is
+         --  intended as a lowest-level Pure package.
+
+         Save_Max_Line   : constant Int := Style_Max_Line_Length;
+
          List : Elist_Id;
 
       begin
@@ -1346,6 +1354,7 @@ 
          Pop_Scope;
          Restore_Scope_Stack (List);
          Ghost_Mode := Save_Ghost_Mode;
+         Style_Max_Line_Length := Save_Max_Line;
       end Do_Analyze;
 
       --  Local variables