]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Extend optimization to True/False prefixed with Standard
authorPiotr Trojanek <trojanek@adacore.com>
Fri, 15 May 2020 18:27:18 +0000 (20:27 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 8 Jul 2020 14:55:49 +0000 (10:55 -0400)
gcc/ada/

* exp_ch5.adb (Expand_N_If_Statement): Detect True/False
prefixed with Standard.

gcc/ada/exp_ch5.adb

index caacda6e6f0eeba033b677d5190c9d5fcf999f79..699252844da3c7dc3233b716f8ba23fbfea5d09d 100644 (file)
@@ -3743,9 +3743,9 @@ package body Exp_Ch5 is
       --  Another optimization, special cases that can be simplified
 
       --     if expression then
-      --        return true;
+      --        return [standard.]true;
       --     else
-      --        return false;
+      --        return [standard.]false;
       --     end if;
 
       --  can be changed to:
@@ -3755,9 +3755,9 @@ package body Exp_Ch5 is
       --  and
 
       --     if expression then
-      --        return false;
+      --        return [standard.]false;
       --     else
-      --        return true;
+      --        return [standard.]true;
       --     end if;
 
       --  can be changed to:
@@ -3790,9 +3790,9 @@ package body Exp_Ch5 is
                      Else_Expr : constant Node_Id := Expression (Else_Stm);
 
                   begin
-                     if Nkind (Then_Expr) = N_Identifier
+                     if Nkind_In (Then_Expr, N_Expanded_Name, N_Identifier)
                           and then
-                        Nkind (Else_Expr) = N_Identifier
+                        Nkind_In (Else_Expr, N_Expanded_Name, N_Identifier)
                      then
                         if Entity (Then_Expr) = Standard_True
                           and then Entity (Else_Expr) = Standard_False