This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] More complete style checks for specs


This patch corrects some cases of missing style checks on specs when
compiling the body. If the spec of the main unit is explicitly with'ed
from an indirect chain of with's, then style checks for this spec
were missed. This patch corrects this, so will have the effect of
catching previously missed style errors.

Consider the following program:

     1. with SCaseP;
     2. package SCaseQ is
     3.    procedure Proc;
     4. end SCaseQ;

     1. package SCaseP is
     2.    Var : Integer;
     3.    type Value_Number is access all Integer;
     4.    procedure External_Value_Rec (Addr : Value_number);
     5.    Val : Integer := var;
     6. end SCaseP;

     1. with SCaseQ;
     2. package body SCaseP is
     3.    V : Integer := Var;
     4.    procedure External_Value_Rec (Addr : Value_number) is
     5.    begin
     6.       null;
     7.    end External_Value_Rec;
     8. end SCaseP;

With the patch in place, if we compile the body of SCaseP with
-gnatyr, we get:

Compiling: scasep.adb

     1. with SCaseQ;
     2. package body SCaseP is
     3.    V : Integer := Var;
     4.    procedure External_Value_Rec (Addr : Value_number) is
                                                      |
        >>> (style) bad casing of "Value_Number" declared at scasep.ads:3

     5.    begin
     6.       null;
     7.    end External_Value_Rec;
     8. end SCaseP;

Compiling: scasep.ads

     1. package SCaseP is
     2.    Var : Integer;
     3.    type Value_Number is access all Integer;
     4.    procedure External_Value_Rec (Addr : Value_number);
                                                      |
        >>> (style) bad casing of "Value_Number" declared at line 3

     5.    Val : Integer := var;
                            |
        >>> (style) bad casing of "Var" declared at line 2

     6. end SCaseP;

Previous to this patch, this compilation lost the two warnings on
lines 4 and 5 of the spec in file scalsep.ads, and these style
warnings are clearly correct!

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

2013-04-12  Robert Dewar  <dewar@adacore.com>

	* opt.ads (Style_Check_Main): New switch.
	* sem.adb (Semantics): Set Style_Check flag properly for new
	unit to be analyzed.
	* sem_ch10.adb (Analyze_With_Clause): Don't reset Style_Check,
	the proper setting of this flag is now part of the Semantics
	procedure.
	* switch-c.adb (Scan_Front_End_Switches): Set Style_Check_Main
	for -gnatg and -gnaty

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]