aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-06-13 18:18:36 +0200
committerTristan Gingold <tgingold@free.fr>2019-06-13 18:18:36 +0200
commita42fb47d1987c8c4fb903da2ecdb9cee14c3d539 (patch)
tree8c9e7a3ff0c92b9298d27ee8f172f8b9cd2b7aaa
parent885019604e8771e4248977dff8557186f471ddae (diff)
downloadghdl-a42fb47d1987c8c4fb903da2ecdb9cee14c3d539.tar.gz
ghdl-a42fb47d1987c8c4fb903da2ecdb9cee14c3d539.tar.bz2
ghdl-a42fb47d1987c8c4fb903da2ecdb9cee14c3d539.zip
vhdl-sem_expr: set string type in case of error.
-rw-r--r--src/vhdl/vhdl-sem_expr.adb21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/vhdl/vhdl-sem_expr.adb b/src/vhdl/vhdl-sem_expr.adb
index c664ee0c2..2bfe77b49 100644
--- a/src/vhdl/vhdl-sem_expr.adb
+++ b/src/vhdl/vhdl-sem_expr.adb
@@ -2082,23 +2082,26 @@ package body Vhdl.Sem_Expr is
-- The type of the context is constrained.
Index_Type := Get_Index_Type (Lit_Type, 0);
if Get_Type_Staticness (Index_Type) = Locally then
- if Eval_Discrete_Type_Length (Index_Type) /= Int64 (Len) then
+ if Eval_Discrete_Type_Length (Index_Type) = Int64 (Len) then
+ return;
+ else
Error_Msg_Sem (+Lit, "string length does not match that of %n",
+Index_Type);
+ -- Change the type.
end if;
else
-- FIXME: emit a warning because of dubious construct (the type
-- of the string is not locally constrained) ?
- null;
+ return;
end if;
- else
- -- Context type is not constained. Set type of the string literal,
- -- according to LRM93 7.3.2.2.
- N_Type := Create_Unidim_Array_By_Length
- (Lit_Base_Type, Int64 (Len), Lit);
- Set_Type (Lit, N_Type);
- Set_Literal_Subtype (Lit, N_Type);
end if;
+
+ -- Context type is not constained. Set type of the string literal,
+ -- according to LRM93 7.3.2.2.
+ N_Type := Create_Unidim_Array_By_Length
+ (Lit_Base_Type, Int64 (Len), Lit);
+ Set_Type (Lit, N_Type);
+ Set_Literal_Subtype (Lit, N_Type);
end Sem_String_Literal;
procedure Count_Choices (Info : out Choice_Info_Type;