diff options
author | Piotr Trojanek <trojanek@adacore.com> | 2023-01-30 12:21:24 +0100 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2023-05-22 10:44:07 +0200 |
commit | 68d93e0111d3b1956cf3fed3b2ad430d8fc001f3 (patch) | |
tree | 5c528967d7f72e8eb95e823d145d258f5e776401 /gcc | |
parent | c9de07cd00c814c7147c24825b9bbe4fba18519a (diff) | |
download | gcc-68d93e0111d3b1956cf3fed3b2ad430d8fc001f3.zip gcc-68d93e0111d3b1956cf3fed3b2ad430d8fc001f3.tar.gz gcc-68d93e0111d3b1956cf3fed3b2ad430d8fc001f3.tar.bz2 |
ada: Restrict expression pretty-printer to subexpressions
When pretty-printing expressions with a CASE alternatives we can qualify
the call to Nkind using N_Subexpr, so that we will get compile-time
errors when new node kinds are added (e.g. Ada 2022 case expressions).
gcc/ada/
* pprint.adb (Expr_Name): Qualify CASE expression with N_Subexpr; add
missing alternative for N_Raise_Storage_Error; remove dead alternatives;
explicitly list unsupported alternatives.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/pprint.adb | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/gcc/ada/pprint.adb b/gcc/ada/pprint.adb index 526b70f..2a86bd5 100644 --- a/gcc/ada/pprint.adb +++ b/gcc/ada/pprint.adb @@ -185,10 +185,8 @@ package body Pprint is return "..."; end if; - case Nkind (Expr) is - when N_Defining_Identifier - | N_Identifier - => + case N_Subexpr'(Nkind (Expr)) is + when N_Identifier => return Ident_Image (Expr, Expression_Image.Expr, Expand_Type); when N_Character_Literal => @@ -379,14 +377,6 @@ package body Pprint is return "." & Expr_Name (Selector_Name (Expr)); end if; - when N_Component_Association => - return "(" - & List_Name - (List => First (Choices (Expr)), - Add_Space => False, - Add_Paren => False) - & " => " & Expr_Name (Expression (Expr)) & ")"; - when N_If_Expression => declare Cond_Expr : constant Node_Id := First (Expressions (Expr)); @@ -436,6 +426,15 @@ package body Pprint is return "[program_error]"; end if; + when N_Raise_Storage_Error => + if Present (Condition (Expr)) then + return + "[storage_error when " + & Expr_Name (Condition (Expr)) & "]"; + else + return "[storage_error]"; + end if; + when N_Range => return Expr_Name (Low_Bound (Expr)) & ".." & @@ -573,9 +572,6 @@ package body Pprint is when N_Op_Not => return "not (" & Expr_Name (Right_Opnd (Expr)) & ")"; - when N_Parameter_Association => - return Expr_Name (Explicit_Actual_Parameter (Expr)); - when N_Type_Conversion => -- Most conversions are not very interesting (used inside @@ -627,10 +623,18 @@ package body Pprint is when N_Null => return "null"; - when N_Others_Choice => - return "others"; - - when others => + when N_Case_Expression + | N_Delta_Aggregate + | N_Interpolated_String_Literal + | N_Op_Rotate_Left + | N_Op_Rotate_Right + | N_Operator_Symbol + | N_Procedure_Call_Statement + | N_Quantified_Expression + | N_Raise_Expression + | N_Reference + | N_Target_Name + => return "..."; end case; end Expr_Name; |