diff options
Diffstat (limited to 'gcc/ada/sem_prag.adb')
-rw-r--r-- | gcc/ada/sem_prag.adb | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index a5eaf1304bd..a1d381c8b90 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -2827,6 +2827,10 @@ package body Sem_Prag is -- Analyze_Pragma -- -------------------- + -------------------- + -- Analyze_Pragma -- + -------------------- + procedure Analyze_Pragma (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Prag_Id : Pragma_Id; @@ -12240,11 +12244,39 @@ package body Sem_Prag is GNAT_Pragma; Process_Compile_Time_Warning_Or_Error; - ------------------- - -- Compiler_Unit -- - ------------------- + --------------------------- + -- Compiler_Unit_Warning -- + --------------------------- + + -- pragma Compiler_Unit_Warning; + + -- Historical note + + -- Originally, we had only pragma Compiler_Unit, and it resulted in + -- errors not warnings. This means that we had introduced a big extra + -- inertia to compiler changes, since even if we implemented a new + -- feature, and even if all versions to be used for bootstrapping + -- implemented this new feature, we could not use it, since old + -- compilers would give errors for using this feature in units + -- having Compiler_Unit pragmas. + + -- By changing Compiler_Unit to Compiler_Unit_Warning, we solve the + -- problem. We no longer have any units mentioning Compiler_Unit, + -- so old compilers see Compiler_Unit_Warning which is unrecognized, + -- and thus generates a warning which can be ignored. So that deals + -- with the problem of old compilers not implementing the newer form + -- of the pragma. + + -- Newer compilers recognize the new pragma, but generate warning + -- messages instead of errors, which again can be ignored in the + -- case of an old compiler which implements a wanted new feature + -- but at the time felt like warning about it for older compilers. + + -- We retain Compiler_Unit so that new compilers can be used to build + -- older run-times that use this pragma. That's an unusual case, but + -- it's easy enough to handle, so why not? - when Pragma_Compiler_Unit => + when Pragma_Compiler_Unit | Pragma_Compiler_Unit_Warning => GNAT_Pragma; Check_Arg_Count (0); Set_Is_Compiler_Unit (Get_Source_Unit (N)); @@ -25521,6 +25553,7 @@ package body Sem_Prag is Pragma_Compile_Time_Error => -1, Pragma_Compile_Time_Warning => -1, Pragma_Compiler_Unit => 0, + Pragma_Compiler_Unit_Warning => 0, Pragma_Complete_Representation => 0, Pragma_Complex_Representation => 0, Pragma_Component_Alignment => -1, |