public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <derodat@adacore.com>
To: gcc-patches@gcc.gnu.org
Subject: [Ada] Code cleanups
Date: Tue, 11 Jan 2022 13:32:01 +0000	[thread overview]
Message-ID: <20220111133201.GA748544@adacore.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 191 bytes --]

Use membership tests when possible

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* exp_ch9.adb, gen_il-types.ads, make.adb, par-ch12.adb,
	sem_ch13.adb: Use membership tests.

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 2677 bytes --]

diff --git a/gcc/ada/exp_ch9.adb b/gcc/ada/exp_ch9.adb
--- a/gcc/ada/exp_ch9.adb
+++ b/gcc/ada/exp_ch9.adb
@@ -4394,7 +4394,7 @@ package body Exp_Ch9 is
       --  It would be better to encapsulate this as a routine in Exp_Dbug ???
 
       if Append_Char /= ' ' then
-         if Append_Char = 'P' or Append_Char = 'N' then
+         if Append_Char in 'P' | 'N' then
             Add_Char_To_Name_Buffer (Append_Char);
             return Name_Find;
          else


diff --git a/gcc/ada/gen_il-types.ads b/gcc/ada/gen_il-types.ads
--- a/gcc/ada/gen_il-types.ads
+++ b/gcc/ada/gen_il-types.ads
@@ -577,8 +577,7 @@ package Gen_IL.Types is
       | N_Defining_Operator_Symbol;
 
    subtype Opt_Abstract_Type is Opt_Type_Enum with
-     Predicate => Opt_Abstract_Type = No_Type or
-       Opt_Abstract_Type in Abstract_Type;
+     Predicate => Opt_Abstract_Type in No_Type | Abstract_Type;
 
    subtype Type_Boundaries is Type_Enum with
      Predicate => Type_Boundaries in


diff --git a/gcc/ada/make.adb b/gcc/ada/make.adb
--- a/gcc/ada/make.adb
+++ b/gcc/ada/make.adb
@@ -3765,7 +3765,7 @@ package body Make is
                declare
                   Arg : constant String := Argument (J);
                begin
-                  if Arg = "-cargs" or Arg = "-bargs" or Arg = "-largs" then
+                  if Arg in "-cargs" | "-bargs" | "-largs" then
                      In_Gnatmake_Switches := False;
 
                   elsif Arg = "-margs" then


diff --git a/gcc/ada/par-ch12.adb b/gcc/ada/par-ch12.adb
--- a/gcc/ada/par-ch12.adb
+++ b/gcc/ada/par-ch12.adb
@@ -184,7 +184,7 @@ package body Ch12 is
                if Token = Tok_Package then
                   Append (P_Formal_Package_Declaration, Decls);
 
-               elsif Token = Tok_Procedure or Token = Tok_Function then
+               elsif Token in Tok_Procedure | Tok_Function then
                   Append (P_Formal_Subprogram_Declaration, Decls);
 
                else


diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb
--- a/gcc/ada/sem_ch13.adb
+++ b/gcc/ada/sem_ch13.adb
@@ -17125,9 +17125,8 @@ package body Sem_Ch13 is
 
    procedure Validate_Literal_Aspect (Typ : Entity_Id; ASN : Node_Id) is
       A_Id        : constant Aspect_Id := Get_Aspect_Id (ASN);
-      pragma Assert ((A_Id = Aspect_Integer_Literal) or
-                     (A_Id = Aspect_Real_Literal) or
-                     (A_Id = Aspect_String_Literal));
+      pragma Assert (A_Id in Aspect_Integer_Literal |
+                             Aspect_Real_Literal | Aspect_String_Literal);
       Func_Name   : constant Node_Id := Expression (ASN);
       Overloaded  : Boolean := Is_Overloaded (Func_Name);
 



                 reply	other threads:[~2022-01-11 13:32 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=20220111133201.GA748544@adacore.com \
    --to=derodat@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    /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).