diff options
author | Tristan Gingold <tgingold@free.fr> | 2019-05-07 18:45:33 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2019-05-07 18:45:33 +0200 |
commit | a2c0447aeb1e1b3fca1d84716a2a97a5f65d3c30 (patch) | |
tree | e6966abbf56ad36ed80ea5301240a25aef54ce39 /src/vhdl/vhdl-sem_types.adb | |
parent | cebafc9a8bcc4664dd00de5efad97dd0b709d3a9 (diff) | |
download | ghdl-a2c0447aeb1e1b3fca1d84716a2a97a5f65d3c30.tar.gz ghdl-a2c0447aeb1e1b3fca1d84716a2a97a5f65d3c30.tar.bz2 ghdl-a2c0447aeb1e1b3fca1d84716a2a97a5f65d3c30.zip |
vhdl: Add a warning for null range in discrete type declaration.
For issue #810
Diffstat (limited to 'src/vhdl/vhdl-sem_types.adb')
-rw-r--r-- | src/vhdl/vhdl-sem_types.adb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/vhdl/vhdl-sem_types.adb b/src/vhdl/vhdl-sem_types.adb index 3ec8586ce..0cc7bf314 100644 --- a/src/vhdl/vhdl-sem_types.adb +++ b/src/vhdl/vhdl-sem_types.adb @@ -265,6 +265,13 @@ package body Vhdl.Sem_Types is case Get_Kind (Get_Base_Type (Get_Type (Get_Left_Limit (Rng)))) is when Iir_Kind_Integer_Type_Definition => + if Get_Expr_Staticness (Rng) = Locally + and then Eval_Is_Null_Discrete_Range (Rng) + then + Warning_Msg_Sem + (Warnid_Runtime_Error, +Expr, + "integer type %i has a null range", (1 => +Decl)); + end if; Res := Create_Integer_Type (Expr, Rng, Decl); when Iir_Kind_Floating_Type_Definition => declare @@ -374,6 +381,13 @@ package body Vhdl.Sem_Types is Get_Range_Constraint (Universal_Integer_Subtype_Definition); else Range_Expr1 := Eval_Range_If_Static (Range_Expr1); + if Get_Expr_Staticness (Range_Expr1) = Locally + and then Eval_Is_Null_Discrete_Range (Range_Expr1) + then + Warning_Msg_Sem + (Warnid_Runtime_Error, +Range_Expr, + "physical type %i has a null range", (1 => +Decl)); + end if; end if; -- Create the subtype. |