aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sprint.adb
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2013-01-02 11:38:18 +0100
committerArnaud Charlet <charlet@gcc.gnu.org>2013-01-02 11:38:18 +0100
commit8ed7930e45b8232ed637f207fc48222112742a51 (patch)
treefad1732609d459202281d32411b622d865c8e835 /gcc/ada/sprint.adb
parentfab62a15d14a3a8cf4a534f48411108a776b1a81 (diff)
downloadgcc-8ed7930e45b8232ed637f207fc48222112742a51.zip
gcc-8ed7930e45b8232ed637f207fc48222112742a51.tar.gz
gcc-8ed7930e45b8232ed637f207fc48222112742a51.tar.bz2
[multiple changes]
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. From-SVN: r194792
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 e80708e..bfa245f 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 =>