From d363464f4a40cd999838aa5d229a3644bfbe2cec Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Tue, 2 Jun 2015 21:54:42 +0200 Subject: Catch duplicated subprogram body. Fix bug14. --- libraries/std/textio.vhdl | 5 ++--- libraries/std/textio_body.vhdl | 5 ++--- src/vhdl/sem.adb | 20 +++++++++++++++----- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/libraries/std/textio.vhdl b/libraries/std/textio.vhdl index 3b62d763e..939caf439 100644 --- a/libraries/std/textio.vhdl +++ b/libraries/std/textio.vhdl @@ -13,9 +13,8 @@ -- for more details. -- -- You should have received a copy of the GNU General Public License --- along with GCC; see the file COPYING. If not, write to the Free --- Software Foundation, 59 Temple Place - Suite 330, Boston, MA --- 02111-1307, USA. +-- along with GCC; see the file COPYING3. If not see +-- . package Textio is diff --git a/libraries/std/textio_body.vhdl b/libraries/std/textio_body.vhdl index 4c49670b3..ddf85d7dd 100644 --- a/libraries/std/textio_body.vhdl +++ b/libraries/std/textio_body.vhdl @@ -12,9 +12,8 @@ -- for more details. -- -- You should have received a copy of the GNU General Public License --- along with GCC; see the file COPYING. If not, write to the Free --- Software Foundation, 59 Temple Place - Suite 330, Boston, MA --- 02111-1307, USA. +-- along with GCC; see the file COPYING3. If not see +-- . package body textio is --START-V08 diff --git a/src/vhdl/sem.adb b/src/vhdl/sem.adb index d89eaca65..b78b6cf6e 100644 --- a/src/vhdl/sem.adb +++ b/src/vhdl/sem.adb @@ -20,6 +20,7 @@ with Errorout; use Errorout; with Std_Package; use Std_Package; with Ieee.Std_Logic_1164; with Libraries; +with Files_Map; with Std_Names; with Sem_Scopes; use Sem_Scopes; with Sem_Expr; use Sem_Expr; @@ -1901,11 +1902,20 @@ package body Sem is if Spec /= Null_Iir then -- SUBPRG is the body of the specification SPEC. - Check_Conformance_Rules (Subprg, Spec); - Xref_Body (Subprg, Spec); - Set_Subprogram_Body (Subprg, Subprg_Body); - Set_Subprogram_Specification (Subprg_Body, Spec); - Set_Subprogram_Body (Spec, Subprg_Body); + if Get_Subprogram_Body (Spec) /= Null_Iir then + Error_Msg_Sem + (Disp_Node (Spec) & " body already defined at " + & Files_Map.Image (Get_Location (Get_Subprogram_Body (Spec))), + Subprg); + -- Kill warning. + Set_Use_Flag (Subprg, True); + else + Check_Conformance_Rules (Subprg, Spec); + Xref_Body (Subprg, Spec); + Set_Subprogram_Body (Subprg, Subprg_Body); + Set_Subprogram_Specification (Subprg_Body, Spec); + Set_Subprogram_Body (Spec, Subprg_Body); + end if; else -- Forward declaration or specification followed by body. Set_Subprogram_Overload_Number (Subprg); -- cgit v1.2.3