diff options
Diffstat (limited to 'gcc/ada/restrict.adb')
-rw-r--r-- | gcc/ada/restrict.adb | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/gcc/ada/restrict.adb b/gcc/ada/restrict.adb index 93fd6f0b045..c13537da39f 100644 --- a/gcc/ada/restrict.adb +++ b/gcc/ada/restrict.adb @@ -129,22 +129,32 @@ package body Restrict is Get_File_Name (U, Subunit => False); begin - if not Is_Predefined_File_Name (Fnam) then - return; + -- Get file name - -- Predefined spec, needs checking against list + Get_Name_String (Fnam); - else - -- Pad name to 8 characters with blanks + -- Nothing to do if name not at least 5 characters long ending + -- in .ads or .adb extension, which we strip. + + if Name_Len < 5 + or else (Name_Buffer (Name_Len - 3 .. Name_Len) /= ".ads" + and then + Name_Buffer (Name_Len - 4 .. Name_Len) /= ".adb") + then + return; + end if; - Get_Name_String (Fnam); - Name_Len := Name_Len - 4; + -- Strip extension and pad to eight characters - while Name_Len < 8 loop - Name_Len := Name_Len + 1; - Name_Buffer (Name_Len) := ' '; - end loop; + Name_Len := Name_Len - 4; + while Name_Len < 8 loop + Name_Len := Name_Len + 1; + Name_Buffer (Name_Len) := ' '; + end loop; + + -- If predefined unit, check the list of restricted units + if Is_Predefined_File_Name (Fnam) then for J in Unit_Array'Range loop if Name_Len = 8 and then Name_Buffer (1 .. 8) = Unit_Array (J).Filenm @@ -152,6 +162,15 @@ package body Restrict is Check_Restriction (Unit_Array (J).Res_Id, N); end if; end loop; + + -- If not predefied unit, then one special check still remains. + -- GNAT.Current_Exception is not allowed if we have restriction + -- No_Exception_Propagation active. + + else + if Name_Buffer (1 .. 8) = "g-curexc" then + Check_Restriction (No_Exception_Propagation, N); + end if; end if; end; end if; |