summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTristan Gingold2015-06-02 21:54:42 +0200
committerTristan Gingold2015-06-02 21:54:42 +0200
commitd363464f4a40cd999838aa5d229a3644bfbe2cec (patch)
tree4206b7faa739f3d789ea7ca2d95839ef3dd28ff8 /src
parentc4cb0f1b51fcc1b2a1490e5f7bd9344ce8c05bb6 (diff)
downloadghdl-d363464f4a40cd999838aa5d229a3644bfbe2cec.tar.gz
ghdl-d363464f4a40cd999838aa5d229a3644bfbe2cec.tar.bz2
ghdl-d363464f4a40cd999838aa5d229a3644bfbe2cec.zip
Catch duplicated subprogram body.
Fix bug14.
Diffstat (limited to 'src')
-rw-r--r--src/vhdl/sem.adb20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/vhdl/sem.adb b/src/vhdl/sem.adb
index d89eaca..b78b6cf 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);