diff options
author | Tristan Gingold <tgingold@free.fr> | 2017-10-26 19:22:54 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2017-10-26 19:22:54 +0200 |
commit | 254b3b89d28d1fa7a46aa83567e8bb5bb5481b0a (patch) | |
tree | 9fc39e77ecc402dd501ff696addd2e7555280a4c /src | |
parent | f802fc154bba038ea654b17c4c3b3577b1def9ff (diff) | |
download | ghdl-254b3b89d28d1fa7a46aa83567e8bb5bb5481b0a.tar.gz ghdl-254b3b89d28d1fa7a46aa83567e8bb5bb5481b0a.tar.bz2 ghdl-254b3b89d28d1fa7a46aa83567e8bb5bb5481b0a.zip |
Follow object aliases while checking purity.
Fix #447
Diffstat (limited to 'src')
-rw-r--r-- | src/vhdl/sem_names.adb | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/vhdl/sem_names.adb b/src/vhdl/sem_names.adb index 7e1161e06..211314c08 100644 --- a/src/vhdl/sem_names.adb +++ b/src/vhdl/sem_names.adb @@ -1399,6 +1399,7 @@ package body Sem_Names is Subprg : constant Iir := Sem_Stmts.Get_Current_Subprogram; Subprg_Body : Iir; Parent : Iir; + Decl : Iir; begin -- Apply only in subprograms. if Subprg = Null_Iir then @@ -1421,10 +1422,18 @@ package body Sem_Names is Error_Kind ("sem_check_pure", Subprg); end case; + -- Follow aliases. + if Get_Kind (Obj) = Iir_Kind_Object_Alias_Declaration then + Decl := Get_Object_Prefix (Get_Name (Obj)); + else + Decl := Obj; + end if; + -- Not all objects are impure. - case Get_Kind (Obj) is - when Iir_Kind_Object_Alias_Declaration - | Iir_Kind_Guard_Signal_Declaration + case Get_Kind (Decl) is + when Iir_Kind_Object_Alias_Declaration => + raise Program_Error; + when Iir_Kind_Guard_Signal_Declaration | Iir_Kind_Signal_Declaration | Iir_Kind_Variable_Declaration | Iir_Kind_Interface_File_Declaration => @@ -1433,7 +1442,7 @@ package body Sem_Names is | Iir_Kind_Interface_Signal_Declaration => -- When referenced as a formal name (FIXME: this is an -- approximation), the rules don't apply. - if not Get_Is_Within_Flag (Get_Parent (Obj)) then + if not Get_Is_Within_Flag (Get_Parent (Decl)) then return; end if; when Iir_Kind_File_Declaration => @@ -1456,8 +1465,8 @@ package body Sem_Names is return; end case; - -- OBJ is declared in the immediate declarative part of the subprogram. - Parent := Get_Parent (Obj); + -- DECL is declared in the immediate declarative part of the subprogram. + Parent := Get_Parent (Decl); Subprg_Body := Get_Subprogram_Body (Subprg); if Parent = Subprg or else Parent = Subprg_Body then return; |