diff options
author | Tristan Gingold <tgingold@free.fr> | 2019-07-15 18:41:07 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2019-07-15 18:41:07 +0200 |
commit | c9822a57bbce7c5a9a48829a0720d38abe20610b (patch) | |
tree | e387e8a07245d8e838b4a17a46d49dbcbd125325 | |
parent | 86286af396045c10b2452276dc46013bc00f2cc3 (diff) | |
download | ghdl-c9822a57bbce7c5a9a48829a0720d38abe20610b.tar.gz ghdl-c9822a57bbce7c5a9a48829a0720d38abe20610b.tar.bz2 ghdl-c9822a57bbce7c5a9a48829a0720d38abe20610b.zip |
find_top_entity: avoid crash on missing entity, handle
-rw-r--r-- | src/vhdl/vhdl-configuration.adb | 5 | ||||
-rw-r--r-- | src/vhdl/vhdl-nodes_walk.adb | 35 |
2 files changed, 27 insertions, 13 deletions
diff --git a/src/vhdl/vhdl-configuration.adb b/src/vhdl/vhdl-configuration.adb index 25e29b305..8911c93dd 100644 --- a/src/vhdl/vhdl-configuration.adb +++ b/src/vhdl/vhdl-configuration.adb @@ -814,7 +814,10 @@ package body Vhdl.Configuration is case Iir_Kinds_Entity_Aspect (Get_Kind (Aspect)) is when Iir_Kind_Entity_Aspect_Entity => Unit := Get_Entity (Aspect); - Set_Elab_Flag (Get_Parent (Unit), True); + if Unit /= Null_Node then + -- There may be an error (unit not found). + Set_Elab_Flag (Get_Parent (Unit), True); + end if; when Iir_Kind_Entity_Aspect_Configuration | Iir_Kind_Entity_Aspect_Open => null; diff --git a/src/vhdl/vhdl-nodes_walk.adb b/src/vhdl/vhdl-nodes_walk.adb index e9ae956a7..0bbddef3b 100644 --- a/src/vhdl/vhdl-nodes_walk.adb +++ b/src/vhdl/vhdl-nodes_walk.adb @@ -159,27 +159,38 @@ package body Vhdl.Nodes_Walk is when Iir_Kinds_Simple_Concurrent_Statement | Iir_Kind_Component_Instantiation_Statement => Status := Cb.all (El); - if Status /= Walk_Continue then - return Status; - end if; when Iir_Kind_Block_Statement => Status := Cb.all (El); - if Status /= Walk_Continue then - return Status; + if Status = Walk_Continue then + Status := Walk_Concurrent_Statements_Chain + (Get_Concurrent_Statement_Chain (El), Cb); end if; - return Walk_Concurrent_Statements_Chain - (Get_Concurrent_Statement_Chain (El), Cb); when Iir_Kind_For_Generate_Statement => Status := Cb.all (El); - if Status /= Walk_Continue then - return Status; + if Status = Walk_Continue then + Status := Walk_Concurrent_Statements_Chain + (Get_Concurrent_Statement_Chain + (Get_Generate_Statement_Body (El)), Cb); end if; - return Walk_Concurrent_Statements_Chain - (Get_Concurrent_Statement_Chain - (Get_Generate_Statement_Body (El)), Cb); + when Iir_Kind_If_Generate_Statement => + declare + Cl : Node; + begin + Status := Cb.all (El); + Cl := El; + while Status = Walk_Continue and then Cl /= Null_Node loop + Status := Walk_Concurrent_Statements_Chain + (Get_Concurrent_Statement_Chain + (Get_Generate_Statement_Body (Cl)), Cb); + Cl := Get_Generate_Else_Clause (Cl); + end loop; + end; when others => Error_Kind ("walk_concurrent_statements_chain", El); end case; + if Status /= Walk_Continue then + return Status; + end if; El := Get_Chain (El); end loop; |