From a946a5c38d46ae99653649aafadf8f020defaa5d Mon Sep 17 00:00:00 2001 From: Javier Miranda Date: Thu, 13 Oct 2016 12:12:18 +0000 Subject: sem_prag.ads (Process_Compile_Time_Warning_Or_Error): New overloaded subprogram that factorizes code executed as part of the regular... 2016-10-13 Javier Miranda * sem_prag.ads (Process_Compile_Time_Warning_Or_Error): New overloaded subprogram that factorizes code executed as part of the regular processing of these pragmas and as part of its validation after invoking the backend. * sem_prag.adb (Process_Compile_Time_Warning_Or_Error): New subprogram. (Process_Compile_Time_Warning_Or_Error): If the condition is known at compile time then invoke the new overloaded subprogram; otherwise register the pragma in a table to validate it after invoking the backend. * sem.ads, sem.adb (Unlock): New subprogram. * sem_attr.adb (Analyze_Attribute [Size]): If we are processing pragmas Compile_Time_Warning and Compile_Time_Errors after the backend has been called then evaluate this attribute if 'Size is known at compile time. * gnat1drv.adb (Post_Compilation_Validation_Checks): Validate compile time warnings and errors. * sem_ch13.ads, sem_ch13.adb (Validate_Compile_Time_Warning_Error): New subprogram. (Validate_Compile_Time_Warning_Errors): New subprogram. From-SVN: r241107 --- gcc/ada/sem_attr.adb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'gcc/ada/sem_attr.adb') diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb index b457aa4..0190bd7 100644 --- a/gcc/ada/sem_attr.adb +++ b/gcc/ada/sem_attr.adb @@ -5746,6 +5746,22 @@ package body Sem_Attr is Check_Not_Incomplete_Type; Check_Not_CPP_Type; Set_Etype (N, Universal_Integer); + + -- If we are processing pragmas Compile_Time_Warning and Compile_ + -- Time_Errors after the backend has been called and this occurrence + -- of 'Size is known at compile time then it is safe to perform this + -- evaluation. Needed to perform the static evaluation of the full + -- boolean expression of these pragmas. + + if In_Compile_Time_Warning_Or_Error + and then Is_Entity_Name (P) + and then (Is_Type (Entity (P)) + or else Ekind (Entity (P)) = E_Enumeration_Literal) + and then Size_Known_At_Compile_Time (Entity (P)) + then + Rewrite (N, Make_Integer_Literal (Sloc (N), Esize (Entity (P)))); + Analyze (N); + end if; end Size; ----------- -- cgit v1.1