Check for the expression of the aspect Static were done inside branches
corresponding to inside-a-generic and outside-a-generic. Now this check
occurs only once. Code cleanup; behaviour is unaffected.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* sem_ch13.adb (Analyze_Aspect_Static): Refactor to have a
single check for the expression being present; adapt comments.
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
@@ -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