From af5d8cb0f6bbb33cc5f4aae125b7c34a4f59a8cb Mon Sep 17 00:00:00 2001 From: Daniel Mercier Date: Mon, 21 May 2018 14:52:31 +0000 Subject: [PATCH] [Ada] Pretty-print attribute names using mixed case 2018-05-21 Daniel Mercier gcc/ada/ * pprint.adb: Use mixed case for attribute names. From-SVN: r260470 --- gcc/ada/ChangeLog | 4 ++++ gcc/ada/pprint.adb | 27 ++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index a439064b945..1d5f07919f4 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,7 @@ +2018-04-04 Daniel Mercier + + * pprint.adb: Use mixed case for attribute names. + 2018-04-04 Hristian Kirtchev * sem_ch6.adb (Analyze_Generic_Subprogram_Body): Rename the call to diff --git a/gcc/ada/pprint.adb b/gcc/ada/pprint.adb index 52ea0185604..e66de36005f 100644 --- a/gcc/ada/pprint.adb +++ b/gcc/ada/pprint.adb @@ -24,6 +24,7 @@ ------------------------------------------------------------------------------ with Atree; use Atree; +with Csets; use Csets; with Einfo; use Einfo; with Namet; use Namet; with Nlists; use Nlists; @@ -272,11 +273,35 @@ package body Pprint is when N_Attribute_Reference => if Take_Prefix then declare + function To_Mixed_Case (S : String) return String; + -- Transform given string into the corresponding one in + -- mixed case form. + + function To_Mixed_Case (S : String) return String is + Ucase : Boolean := True; + Result : String (S'Range); + begin + for J in S'Range loop + if Ucase then + Result (J) := Fold_Upper (S (J)); + else + Result (J) := Fold_Lower (S (J)); + end if; + + Ucase := (S (J) = '_'); + end loop; + + return Result; + end To_Mixed_Case; + Id : constant Attribute_Id := Get_Attribute_Id (Attribute_Name (Expr)); + + -- Always use mixed case for attributes Str : constant String := Expr_Name (Prefix (Expr)) & "'" - & Get_Name_String (Attribute_Name (Expr)); + & To_Mixed_Case (Get_Name_String + (Attribute_Name (Expr))); N : Node_Id; Ranges : List_Id; -- 2.30.2