diff options
author | Tristan Gingold <tgingold@free.fr> | 2017-06-12 05:37:49 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2017-06-12 05:37:49 +0200 |
commit | d986b9af22f4e927e887f1bd6f9ff5174dde4aca (patch) | |
tree | 87d270fb31ef48030983f0e89b66ea4705c8a5a4 | |
parent | 5ba7861a7d065b1feb90de890ce34e837cb12fdf (diff) | |
download | ghdl-d986b9af22f4e927e887f1bd6f9ff5174dde4aca.tar.gz ghdl-d986b9af22f4e927e887f1bd6f9ff5174dde4aca.tar.bz2 ghdl-d986b9af22f4e927e887f1bd6f9ff5174dde4aca.zip |
Fix crash of implicit conversion in instantiation.
Fix #301
-rw-r--r-- | src/vhdl/translate/trans-chap5.adb | 16 | ||||
-rw-r--r-- | src/vhdl/translate/trans.adb | 5 | ||||
-rw-r--r-- | src/vhdl/translate/trans.ads | 3 | ||||
-rwxr-xr-x | testsuite/gna/issue283/testsuite.sh | 2 |
4 files changed, 24 insertions, 2 deletions
diff --git a/src/vhdl/translate/trans-chap5.adb b/src/vhdl/translate/trans-chap5.adb index f4efc4103..dbccd5ac4 100644 --- a/src/vhdl/translate/trans-chap5.adb +++ b/src/vhdl/translate/trans-chap5.adb @@ -36,12 +36,23 @@ package body Trans.Chap5 is Scope => Scope_Ptr.all); end Save_Map_Env; - procedure Set_Map_Env (Env : Map_Env) + procedure Restore_Map_Env (Env : Map_Env) is -- Avoid potential compiler bug with discriminant check. pragma Suppress (Discriminant_Check); begin Env.Scope_Ptr.all := Env.Scope; + end Restore_Map_Env; + + procedure Set_Map_Env (Env : Map_Env) is + begin + -- In some cases, the previous environment is still needed (for example + -- an implicit array conversion accesses to both the formal and the + -- actual type). Set ENV only if it is not null, in order not to erase + -- the previous env. + if not Is_Null (Env.Scope) then + Restore_Map_Env (Env); + end if; end Set_Map_Env; procedure Translate_Attribute_Specification @@ -742,7 +753,7 @@ package body Trans.Chap5 is end; Next_Association_Interface (Assoc, Inter); end loop; - Set_Map_Env (Actual_Env); + Restore_Map_Env (Actual_Env); end Elab_Port_Map_Aspect; procedure Elab_Generic_Map_Aspect @@ -855,6 +866,7 @@ package body Trans.Chap5 is Close_Temp; Next_Association_Interface (Assoc, Inter); end loop; + Restore_Map_Env (Actual_Env); end Elab_Generic_Map_Aspect; procedure Elab_Map_Aspect diff --git a/src/vhdl/translate/trans.adb b/src/vhdl/translate/trans.adb index 1f9d177a4..6c8bc048e 100644 --- a/src/vhdl/translate/trans.adb +++ b/src/vhdl/translate/trans.adb @@ -432,6 +432,11 @@ package body Trans is Scope := (Scope_Type => Scope.Scope_Type, Kind => Var_Scope_None); end Clear_Scope; + function Is_Null (Scope : Var_Scope_Type) return Boolean is + begin + return Scope.Kind = Var_Scope_None; + end Is_Null; + function Create_Global_Var (Name : O_Ident; Vtype : O_Tnode; Storage : O_Storage) return Var_Type diff --git a/src/vhdl/translate/trans.ads b/src/vhdl/translate/trans.ads index adc4a4712..cc74d46b5 100644 --- a/src/vhdl/translate/trans.ads +++ b/src/vhdl/translate/trans.ads @@ -324,6 +324,9 @@ package Trans is -- before being set. procedure Clear_Scope (Scope : in out Var_Scope_Type); + -- True if SCOPE is a null-scope (eg. was cleared). + function Is_Null (Scope : Var_Scope_Type) return Boolean; + -- Reset the identifier. type Id_Mark_Type is limited private; type Local_Identifier_Type is private; diff --git a/testsuite/gna/issue283/testsuite.sh b/testsuite/gna/issue283/testsuite.sh index 13cf1d89c..4000acc12 100755 --- a/testsuite/gna/issue283/testsuite.sh +++ b/testsuite/gna/issue283/testsuite.sh @@ -1,5 +1,7 @@ #! /bin/sh # Need cocotb +# Was run with: +# make COCOTB=/path/to/cocotb/ SIM=ghdl ARCH=x86_64 PYTHON_BIN=python TOPLEVEL_LANG=vhdl CMD=$GHDL echo "Test skipped" |