summaryrefslogtreecommitdiff
path: root/gcc/ada/sprint.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2013-01-02 10:38:18 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2013-01-02 10:38:18 +0000
commit6b452e895bc41965b541ee2753c1cc14c33e14c0 (patch)
treefad1732609d459202281d32411b622d865c8e835 /gcc/ada/sprint.adb
parentc1cb7c7537af33dbd1146664a9c35d1b694839a7 (diff)
downloadgcc-6b452e895bc41965b541ee2753c1cc14c33e14c0.tar.gz
2013-01-02 Hristian Kirtchev <kirtchev@adacore.com>
* sem_attr.adb (Analyze_Attribute): Skip the special _Parent scope generated for subprogram inlining purposes while trying to locate the enclosing function. * sem_prag.adb (Analyze_Pragma): Preanalyze the boolean expression of pragma Postcondition when the pragma comes from source and appears inside a subprogram body. 2013-01-02 Thomas Quinot <quinot@adacore.com> * switch-c.adb, fe.h, back_end.adb: Enable generation of instantiation information in debug info unconditionally when using -fdump-scos, instead of relying on a separate command line switch -fdebug-instances. 2013-01-02 Ed Schonberg <schonberg@adacore.com> * sem_ch12.adb: Additional refinement of predicate. 2013-01-02 Vincent Celier <celier@adacore.com> * vms_data.ads: Remove incorrect spaces at end of descriptions of qualifiers for single switch. 2013-01-02 Ben Brosgol <brosgol@adacore.com> * gnat_rm.texi: Minor edits / wordsmithing in section on pragma Check_Float_Overflow. 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. 2013-01-02 Thomas Quinot <quinot@adacore.com> * gnat1drv.adb (Adjust_Global_Switches): Adjust back-end flag_debug_instances here, after front-end switches have been processed. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@194792 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/sprint.adb')
-rw-r--r--gcc/ada/sprint.adb38
1 files changed, 27 insertions, 11 deletions
diff --git a/gcc/ada/sprint.adb b/gcc/ada/sprint.adb
index e80708e67b0..bfa245fd9dc 100644
--- a/gcc/ada/sprint.adb
+++ b/gcc/ada/sprint.adb
@@ -1159,14 +1159,19 @@ package body Sprint is
when N_Case_Expression =>
declare
- Alt : Node_Id;
+ Has_Parens : constant Boolean := Paren_Count (Node) > 0;
+ Alt : Node_Id;
begin
-- The syntax for case_expression does not include parentheses,
-- but sometimes parentheses are required, so unconditionally
- -- generate them here.
+ -- generate them here unless already present.
- Write_Str_With_Col_Check_Sloc ("(case ");
+ if not Has_Parens then
+ Write_Char ('(');
+ end if;
+
+ Write_Str_With_Col_Check_Sloc ("case ");
Sprint_Node (Expression (Node));
Write_Str_With_Col_Check (" is");
@@ -1178,7 +1183,9 @@ package body Sprint is
Write_Char (',');
end loop;
- Write_Char (')');
+ if not Has_Parens then
+ Write_Char (')');
+ end if;
end;
when N_Case_Expression_Alternative =>
@@ -1963,15 +1970,19 @@ package body Sprint is
when N_If_Expression =>
declare
- Condition : constant Node_Id := First (Expressions (Node));
- Then_Expr : constant Node_Id := Next (Condition);
+ Has_Parens : constant Boolean := Paren_Count (Node) > 0;
+ Condition : constant Node_Id := First (Expressions (Node));
+ Then_Expr : constant Node_Id := Next (Condition);
begin
-- The syntax for if_expression does not include parentheses,
-- but sometimes parentheses are required, so unconditionally
- -- generate them here.
+ -- generate them here unless already present.
- Write_Str_With_Col_Check_Sloc ("(if ");
+ if not Has_Parens then
+ Write_Char ('(');
+ end if;
+ Write_Str_With_Col_Check_Sloc ("if ");
Sprint_Node (Condition);
Write_Str_With_Col_Check (" then ");
@@ -1979,11 +1990,16 @@ package body Sprint is
if Present (Then_Expr) then
Sprint_Node (Then_Expr);
- Write_Str_With_Col_Check (" else ");
- Sprint_Node (Next (Then_Expr));
+
+ if Present (Next (Then_Expr)) then
+ Write_Str_With_Col_Check (" else ");
+ Sprint_Node (Next (Then_Expr));
+ end if;
end if;
- Write_Char (')');
+ if not Has_Parens then
+ Write_Char (')');
+ end if;
end;
when N_If_Statement =>