[Ada] Refactor repeated checks for the expression of aspect Static
authorPiotr Trojanek <trojanek@adacore.com>
Wed, 9 Dec 2020 14:22:29 +0000 (15:22 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 28 Apr 2021 09:38:12 +0000 (05:38 -0400)
gcc/ada/

* sem_ch13.adb (Analyze_Aspect_Static): Refactor to have a
single check for the expression being present; adapt comments.

gcc/ada/sem_ch13.adb

index 2273887..25e3bd7 100644 (file)
@@ -2610,25 +2610,23 @@ package body Sem_Ch13 is
                   --  component type C, a similar rule applies to C."
                end if;
 
-               --  Preanalyze the expression (if any) when the aspect resides
-               --  in a generic unit. (Is this generic-related code necessary
-               --  for this aspect? It's modeled on what's done for aspect
-               --  Disable_Controlled. ???)
+               --  When the expression is present, it must be static. If it
+               --  evaluates to True, the expression function is treated as
+               --  a static function. Otherwise the aspect appears without
+               --  an expression and defaults to True.
 
-               if Inside_A_Generic then
-                  if Present (Expr) then
-                     Preanalyze_And_Resolve (Expr, Any_Boolean);
-                  end if;
+               if Present (Expr) then
+                  --  Preanalyze the expression when the aspect resides in a
+                  --  generic unit. (Is this generic-related code necessary
+                  --  for this aspect? It's modeled on what's done for aspect
+                  --  Disable_Controlled. ???)
 
-               --  Otherwise the aspect resides in a nongeneric context
+                  if Inside_A_Generic then
+                     Preanalyze_And_Resolve (Expr, Any_Boolean);
 
-               else
-                  --  When the expression statically evaluates to True, the
-                  --  expression function is treated as a static function.
-                  --  Otherwise the aspect appears without an expression and
-                  --  defaults to True.
+                  --  Otherwise the aspect resides in a nongeneric context
 
-                  if Present (Expr) then
+                  else
                      Analyze_And_Resolve (Expr, Any_Boolean);
 
                      --  Error if the boolean expression is not static