From 8b96a998627521e45e92b44a52d09853c73ca625 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Wed, 20 May 2015 21:42:09 +0200 Subject: Fix crash in assert translation for overflow literal. Fix ticket 75. --- src/vhdl/evaluation.adb | 3 ++- src/vhdl/iirs_utils.adb | 5 +++++ src/vhdl/iirs_utils.ads | 4 ++++ src/vhdl/translate/trans-chap8.adb | 4 +++- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/vhdl/evaluation.adb b/src/vhdl/evaluation.adb index b1adbbcf6..76464a777 100644 --- a/src/vhdl/evaluation.adb +++ b/src/vhdl/evaluation.adb @@ -1651,7 +1651,8 @@ package body Evaluation is return Build_Enumeration (Iir_Index32 (I), Expr); end if; end loop; - Warning_Msg_Sem ("value """ & Value & """ not in enumeration", Expr); + Warning_Msg_Sem ("value """ & Value & """ not in enumeration " + & Disp_Node (Enum), Expr); return Build_Overflow (Expr); end Build_Enumeration_Value; diff --git a/src/vhdl/iirs_utils.adb b/src/vhdl/iirs_utils.adb index 5fa9987e5..4df49b424 100644 --- a/src/vhdl/iirs_utils.adb +++ b/src/vhdl/iirs_utils.adb @@ -51,6 +51,11 @@ package body Iirs_Utils is return Get_Kind (N) = Iir_Kind_Error; end Is_Error; + function Is_Overflow_Literal (N : Iir) return Boolean is + begin + return Get_Kind (N) = Iir_Kind_Overflow_Literal; + end Is_Overflow_Literal; + function Get_Operator_Name (Op : Iir) return Name_Id is begin case Get_Kind (Op) is diff --git a/src/vhdl/iirs_utils.ads b/src/vhdl/iirs_utils.ads index 3d74aa30d..96ac91dd4 100644 --- a/src/vhdl/iirs_utils.ads +++ b/src/vhdl/iirs_utils.ads @@ -31,6 +31,10 @@ package Iirs_Utils is function Is_Error (N : Iir) return Boolean; pragma Inline (Is_Error); + -- Return True iff N is an overflow_literal node. + function Is_Overflow_Literal (N : Iir) return Boolean; + pragma Inline (Is_Overflow_Literal); + -- Find LIT in the list of identifiers or characters LIST. -- Return the literal (whose name is LIT) or null_iir if not found. function Find_Name_In_Chain (Chain: Iir; Lit: Name_Id) return Iir; diff --git a/src/vhdl/translate/trans-chap8.adb b/src/vhdl/translate/trans-chap8.adb index 16dc32bb1..283ffbcdb 100644 --- a/src/vhdl/translate/trans-chap8.adb +++ b/src/vhdl/translate/trans-chap8.adb @@ -701,7 +701,9 @@ package body Trans.Chap8 is end if; Expr := Get_Assertion_Condition (Stmt); - if Get_Expr_Staticness (Expr) = Locally then + if Get_Expr_Staticness (Expr) = Locally + and then not Is_Overflow_Literal (Expr) + then if Eval_Pos (Expr) = 1 then -- Assert TRUE is a noop. -- FIXME: generate a noop ? -- cgit v1.2.3