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] Improvements to sprint for conditional expressions


This change improves the circuitry that produces a source-like rendition
for an Ada tree by omitting the generation of extraneous parentheses around
conditional expressions, and removing an extraneous ELSE keyword.

The following compilation must produce the indicated output:
$ gcc -c -gnat12 -gnatG condexpr_sprint.adb
Source recreated from tree for Condexpr_Sprint (body)


procedure condexpr_sprint (b : boolean; i : integer) is
   type r is record
      bb : boolean := (if b then b);
      ii : integer := (case i is when 1 => 1, when others => 2);
   end record;
begin
   null;
end condexpr_sprint;

condexpr_sprint.adb:2:04: declaration expected

procedure Condexpr_Sprint (B : Boolean; I : Integer) is
   zz --  Purposely introduce a serious error here to prevent further analysis

   type R is record
      BB : Boolean := (if B then B);
      II : Integer := (case I is when 1 => 1, when others => 2);
   end record;
begin
   null;
end Condexpr_Sprint;

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

2013-01-02  Thomas Quinot  <quinot@adacore.com>

	* sprint.adb (Sprint_Node_Actual): Do not add extra parens for
	a conditional expression (CASE or IF expression) that already
	has parens. Also omit ELSE keyword for an IF expression without
	an ELSE part.

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]