diff options
author | Piotr Trojanek <trojanek@adacore.com> | 2023-02-11 00:43:41 +0100 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2023-05-23 09:50:58 +0200 |
commit | 0b369aed43e622b0cf67879e84e4b4adf401b350 (patch) | |
tree | de241d6885a7d245e95f060f1075755050ba4817 /gcc/ada/sem_ch6.adb | |
parent | 53ed0028adacb4e9c033b236805ae409823178ab (diff) | |
download | gcc-0b369aed43e622b0cf67879e84e4b4adf401b350.zip gcc-0b369aed43e622b0cf67879e84e4b4adf401b350.tar.gz gcc-0b369aed43e622b0cf67879e84e4b4adf401b350.tar.bz2 |
ada: Fix expression pretty-printer for SPARK counterexamples
The expression pretty-printer that is used for SPARK counterexamples was
essentially duplicating the logic of First_Node/Last_Node and
First_Sloc/Last_Sloc routines. Now it simply reuses those routines.
gcc/ada/
* errout.adb
(Paren_Required): New subsidiary routine for better handling of
parentheses in First_Node/Last_Node.
(First_Sloc, Last_Sloc): Use Get_Source_File_Index to correctly
handle generic instances and inlined subprograms; tune handling of
parentheses; improve handling of literals.
* pprint.adb (Expression_Image): Simplify using
First_Sloc/Last_Sloc.
* sem_ch6.adb (Analyze_Expression_Function): Remove parenthesis
when relocating expression from expression function to simple
return statement.
Diffstat (limited to 'gcc/ada/sem_ch6.adb')
-rw-r--r-- | gcc/ada/sem_ch6.adb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index 0b374c2..992688c 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -361,6 +361,13 @@ package body Sem_Ch6 is Ret := Make_Simple_Return_Statement (LocX, Expr); + -- Remove parens around the expression, so that if the expression will + -- appear without them when pretty-printed in error messages. + + if Paren_Count (Expr) > 0 then + Set_Paren_Count (Expr, Paren_Count (Expr) - 1); + end if; + New_Body := Make_Subprogram_Body (Loc, Specification => New_Spec, |