diff options
author | Tristan Gingold <tgingold@free.fr> | 2020-06-20 17:31:31 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2020-06-24 07:46:44 +0200 |
commit | e359f04bdaa8b5cad3846d333f9dedf4df62c1ef (patch) | |
tree | 7305568a8d5f475dd6e9831219462b505cefc825 /src/vhdl/vhdl-sem_decls.adb | |
parent | 18a71a430a7cfc460e9b013b37465ba7a9e32b1e (diff) | |
download | ghdl-e359f04bdaa8b5cad3846d333f9dedf4df62c1ef.tar.gz ghdl-e359f04bdaa8b5cad3846d333f9dedf4df62c1ef.tar.bz2 ghdl-e359f04bdaa8b5cad3846d333f9dedf4df62c1ef.zip |
vhdl: improve support of subtype attribute. For #641
Diffstat (limited to 'src/vhdl/vhdl-sem_decls.adb')
-rw-r--r-- | src/vhdl/vhdl-sem_decls.adb | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/vhdl/vhdl-sem_decls.adb b/src/vhdl/vhdl-sem_decls.adb index c7bd4ce43..ffb55d0a7 100644 --- a/src/vhdl/vhdl-sem_decls.adb +++ b/src/vhdl/vhdl-sem_decls.adb @@ -1134,15 +1134,24 @@ package body Vhdl.Sem_Decls is -- For a variable or signal declared by an object declaration, the -- subtype indication of the corresponding object declaration -- must define a constrained array subtype. - if not Is_Fully_Constrained_Type (Atype) then - Error_Msg_Sem - (+Decl, - "declaration of %n with unconstrained %n is not allowed", - (+Decl, +Atype)); - if Default_Value /= Null_Iir then - Error_Msg_Sem (+Decl, "(even with a default value)"); + declare + Ind : constant Iir := Get_Subtype_Indication (Decl); + begin + if not (Is_Valid (Ind) + and then Get_Kind (Ind) = Iir_Kind_Subtype_Attribute) + and then not Is_Fully_Constrained_Type (Atype) + then + Report_Start_Group; + Error_Msg_Sem + (+Decl, + "declaration of %n with unconstrained %n is not allowed", + (+Decl, +Atype)); + if Default_Value /= Null_Iir then + Error_Msg_Sem (+Decl, "(even with a default value)"); + end if; + Report_End_Group; end if; - end if; + end; when others => Error_Kind ("sem_object_declaration(2)", Decl); |