diff options
author | Robert Dewar <dewar@adacore.com> | 2005-11-15 15:01:09 +0100 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2005-11-15 15:01:09 +0100 |
commit | 3c43f85317a0b6ff48231b34ec443254ca132a02 (patch) | |
tree | fb3a2c3f9b886d8b8f2c2fcfe8d46e6e2d925883 /gcc/ada | |
parent | 62157e75fb1e1ec2612374a53f2b00da49734373 (diff) | |
download | gcc-3c43f85317a0b6ff48231b34ec443254ca132a02.zip gcc-3c43f85317a0b6ff48231b34ec443254ca132a02.tar.gz gcc-3c43f85317a0b6ff48231b34ec443254ca132a02.tar.bz2 |
par-ch10.adb (P_Compilation_Unit): Add defenses against junk unit syntax, which could cause compiler hangs.
2005-11-14 Robert Dewar <dewar@adacore.com>
* par-ch10.adb (P_Compilation_Unit): Add defenses against junk unit
syntax, which could cause compiler hangs.
From-SVN: r106993
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/par-ch10.adb | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/gcc/ada/par-ch10.adb b/gcc/ada/par-ch10.adb index 13d0fbd..bedb679 100644 --- a/gcc/ada/par-ch10.adb +++ b/gcc/ada/par-ch10.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2005 Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2005, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -405,9 +405,7 @@ package body Ch10 is elsif Private_Sloc /= No_Location and then - Nkind (Unit (Comp_Unit_Node)) /= N_Function_Instantiation - and then - Nkind (Unit (Comp_Unit_Node)) /= N_Procedure_Instantiation + Nkind (Unit (Comp_Unit_Node)) not in N_Subprogram_Instantiation and then Nkind (Unit (Comp_Unit_Node)) /= N_Subprogram_Renaming_Declaration then @@ -529,8 +527,25 @@ package body Ch10 is or else Nkind (Unit_Node) = N_Single_Protected_Declaration then Name_Node := Defining_Identifier (Unit_Node); - else + + elsif Nkind (Unit_Node) = N_Function_Instantiation + or else Nkind (Unit_Node) = N_Function_Specification + or else Nkind (Unit_Node) = N_Generic_Function_Renaming_Declaration + or else Nkind (Unit_Node) = N_Generic_Package_Renaming_Declaration + or else Nkind (Unit_Node) = N_Generic_Procedure_Renaming_Declaration + or else Nkind (Unit_Node) = N_Package_Body + or else Nkind (Unit_Node) = N_Package_Instantiation + or else Nkind (Unit_Node) = N_Package_Renaming_Declaration + or else Nkind (Unit_Node) = N_Package_Specification + or else Nkind (Unit_Node) = N_Procedure_Instantiation + or else Nkind (Unit_Node) = N_Procedure_Specification + then Name_Node := Defining_Unit_Name (Unit_Node); + + -- Anything else is a serious error, abandon scan + + else + raise Error_Resync; end if; Set_Sloc (Comp_Unit_Node, Sloc (Name_Node)); |