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] implement new style switch -gnatyu


Tested on i686-linux, committed on mainline.

This patch implements a new style switch -gnatyu (warn on unnecessary
blank lines). Blank lines are considered unnecessary if they occur at
the end of the file, or if there is more than one blank line in a row.
A simple test case is


procedure K is
begin


   null;
end;




(note that there should be blank lines after the end in this example)
when compiled with -gnatyu should generate two diagnostics:

k.adb:5:01: (style) multiple blank lines
k.adb:9:01: (style) multiple blank lines
--
Implement also part of Ada 2005 AI-395. Full details of this AI can be found
at http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00395.TXT. In this
AI a change is made to allow Unicode characters of category Cf (other
format) in string and character literals by defining them as graphic
characters.
This change also makes ACATS test c352001 obsolete, so it has been removed.

THe following test program:

procedure K is
   -- 00AD;SOFT HYPHEN;Cf;0;ON;;;;;N;;;;;
   -- 0600;ARABIC NUMBER SIGN;Cf;0;AL;;;;;N;;;;;
   S : Wide_String := "abc["AD"]["0600"]xyz";
   Y : Wide_Character := '["AD"]';
   Z : Wide_Character := '["0600"]';
begin
   Put_Line (Integer'Image (Wide_Character'Pos (S (4))));
   Put_Line (Integer'Image (Wide_Character'Pos (S (4))));
   Put_Line (Integer'Image (Wide_Character'Pos (Y)));
   Put_Line (Integer'Image (Wide_Character'Pos (Z)));
end;

should execute without errors when compiled with switch -gnat05
and generate the output:

 173
 173
 173
 1536

Previously this would have given compile time errors on the other format
characters.
--
Finally, the checksum was not computed right for the rare case of a wide wide
character whose code is >= 2 ** 24. This could lead to a blow up with
the assertions enabled compiler, or, in some very marginal case, a
failure to recompile when necessary. The following test program should
compile in -gnat05 mode without blowing up:

package K is
   C : Wide_Wide_Character    := '["1234FFFF"]';
end K;

and generate the diagnostic:

k.ads:2:35: (Ada 2005) non-graphic character not
            permitted in character literal

2005-06-14  Robert Dewar  <dewar@adacore.com>

	* scng.adb: Add call to new Check_EOF routine
	(Accumulate_Checksum): Properly handle wide wide char >= 2 ** 24
	Add some comments regarding wide character handling

	* style.ads, styleg.ads, styleg.adb: Implement new style switch -gnatyu

	* stylesw.ads, stylesw.adb: Implement new style switch -gnatyu

	* g-utf_32.ads, g-utf_32.adb (Is_UTF_32_Non_Graphic): Other_Format
	characters are now considered graphic characters and hence yield false
	in this call.

Attachment: difs.45
Description: Text document


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