From: Pierre-Marie de Rodat <derodat@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Piotr Trojanek <trojanek@adacore.com>
Subject: [Ada] Simplify conversions from Uint to Char_Code
Date: Mon, 9 May 2022 09:30:37 +0000 [thread overview]
Message-ID: <20220509093037.GA3184605@adacore.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 343 bytes --]
Replace "Char_Code (UI_To_Int (...))" with "UI_To_CC (...).
Cleanup related to handling characters in GNATprove counterexamples;
semantics is unaffected.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* par-prag.adb (Prag): Simplify conversion of character codes.
* sem_case.adb (Choice_Image): Likewise.
(Lit_Of): Likewise.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 1374 bytes --]
diff --git a/gcc/ada/par-prag.adb b/gcc/ada/par-prag.adb
--- a/gcc/ada/par-prag.adb
+++ b/gcc/ada/par-prag.adb
@@ -1266,8 +1266,7 @@ begin
elsif Nkind (A) = N_Character_Literal then
declare
- R : constant Char_Code :=
- Char_Code (UI_To_Int (Char_Literal_Value (A)));
+ R : constant Char_Code := UI_To_CC (Char_Literal_Value (A));
begin
if In_Character_Range (R) then
Wide_Character_Encoding_Method :=
diff --git a/gcc/ada/sem_case.adb b/gcc/ada/sem_case.adb
--- a/gcc/ada/sem_case.adb
+++ b/gcc/ada/sem_case.adb
@@ -1104,7 +1104,7 @@ package body Sem_Case is
C := UI_To_Int (Value);
if C in 16#20# .. 16#7E# then
- Set_Character_Literal_Name (Char_Code (UI_To_Int (Value)));
+ Set_Character_Literal_Name (UI_To_CC (Value));
return Name_Find;
end if;
@@ -2925,7 +2925,7 @@ package body Sem_Case is
-- is created with the appropriate Char_Code and Chars fields.
if Is_Standard_Character_Type (Choice_Type) then
- Set_Character_Literal_Name (Char_Code (UI_To_Int (Value)));
+ Set_Character_Literal_Name (UI_To_CC (Value));
Lit :=
Make_Character_Literal (Loc,
Chars => Name_Find,
reply other threads:[~2022-05-09 9:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220509093037.GA3184605@adacore.com \
--to=derodat@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=trojanek@adacore.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).