Fixes an illegal call to Compile_Time_Known_Value with Empty parameter,
which is now reported as a crash with switch -gnatdk. This is clearly a
corner case; in preparation for a cleanup of some dubious code for
Enum_Rep attribute.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* sem_attr.adb (Eval_Attribute): Check if constant has an
initialization expression.
diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb
--- a/gcc/ada/sem_attr.adb
+++ b/gcc/ada/sem_attr.adb
@@ -7834,6 +7834,8 @@ package body Sem_Attr is
(Ekind (Entity (Enum_Expr)) = E_Constant
and then Nkind (Parent (Entity (Enum_Expr))) =
N_Object_Declaration
+ and then Present
+ (Expression (Parent (Entity (P))))
and then Compile_Time_Known_Value
(Expression (Parent (Entity (P))))))
then