aboutsummaryrefslogtreecommitdiffstats
path: root/src/synth
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-04-30 07:36:15 +0200
committerTristan Gingold <tgingold@free.fr>2020-04-30 07:36:15 +0200
commit86dd779a285adca640b497568080b1fdcf264506 (patch)
treedbba861fb979b5ad63dcfba932f7f79665a11271 /src/synth
parentba342a67ebf6afc00ea25c3b463d7beb93cd16d2 (diff)
downloadghdl-86dd779a285adca640b497568080b1fdcf264506.tar.gz
ghdl-86dd779a285adca640b497568080b1fdcf264506.tar.bz2
ghdl-86dd779a285adca640b497568080b1fdcf264506.zip
synth: do not allow signals in default values. Fix #1271
Only for default values of 'global' objects.
Diffstat (limited to 'src/synth')
-rw-r--r--src/synth/synth-decls.adb26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/synth/synth-decls.adb b/src/synth/synth-decls.adb
index c53b4159c..9f10a6e61 100644
--- a/src/synth/synth-decls.adb
+++ b/src/synth/synth-decls.adb
@@ -462,8 +462,10 @@ package body Synth.Decls is
Synth_Subtype_Indication (Syn_Inst, Atype);
end Synth_Declaration_Type;
- procedure Synth_Constant_Declaration
- (Syn_Inst : Synth_Instance_Acc; Decl : Node; Last_Type : in out Node)
+ procedure Synth_Constant_Declaration (Syn_Inst : Synth_Instance_Acc;
+ Decl : Node;
+ Is_Subprg : Boolean;
+ Last_Type : in out Node)
is
Deferred_Decl : constant Node := Get_Deferred_Declaration (Decl);
First_Decl : Node;
@@ -521,7 +523,16 @@ package body Synth.Decls is
| Value_Alias =>
Cst := Val;
when others =>
- Cst := Create_Value_Const (Val, Decl);
+ if Is_Static (Val.Val) then
+ Cst := Create_Value_Const (Val, Decl);
+ else
+ if not Is_Subprg then
+ Error_Msg_Synth
+ (+Decl, "signals cannot be used in default value "
+ & "of this constant");
+ end if;
+ Cst := Val;
+ end if;
end case;
Create_Object_Force (Syn_Inst, First_Decl, Cst);
end if;
@@ -749,6 +760,13 @@ package body Synth.Decls is
if Is_Valid (Def) then
Init := Synth_Expression_With_Type (Syn_Inst, Def, Obj_Typ);
Init := Synth_Subtype_Conversion (Init, Obj_Typ, False, Decl);
+ if not Is_Subprg
+ and then not Is_Static (Init.Val)
+ then
+ Error_Msg_Synth
+ (+Decl, "signals cannot be used in default value of "
+ & "this variable");
+ end if;
else
Init := Create_Value_Default (Obj_Typ);
end if;
@@ -822,7 +840,7 @@ package body Synth.Decls is
Create_Wire_Object (Syn_Inst, Wire_Variable, Decl);
Create_Var_Wire (Syn_Inst, Decl, No_Valtyp);
when Iir_Kind_Constant_Declaration =>
- Synth_Constant_Declaration (Syn_Inst, Decl, Last_Type);
+ Synth_Constant_Declaration (Syn_Inst, Decl, Is_Subprg, Last_Type);
when Iir_Kind_Signal_Declaration =>
Synth_Declaration_Type (Syn_Inst, Decl);
declare