diff options
author | Tristan Gingold <tgingold@free.fr> | 2014-01-13 02:40:01 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2014-01-13 02:40:01 +0100 |
commit | 86bfd8ac497f4e4a753ddbd9d382b377d876dcbc (patch) | |
tree | 3035168b395c5f301b8c344c3cd1f881d4c6031c /sem_expr.adb | |
parent | eae904baf0e76f48c755e5ae91b1c0eff5729796 (diff) | |
download | ghdl-86bfd8ac497f4e4a753ddbd9d382b377d876dcbc.tar.gz ghdl-86bfd8ac497f4e4a753ddbd9d382b377d876dcbc.tar.bz2 ghdl-86bfd8ac497f4e4a753ddbd9d382b377d876dcbc.zip |
Fix bug20312: rewrite of complex types.
Fix crashes in sem_expr when string literals are used in range exprs.
Diffstat (limited to 'sem_expr.adb')
-rw-r--r-- | sem_expr.adb | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/sem_expr.adb b/sem_expr.adb index ebe7679b1..aec8a83bc 100644 --- a/sem_expr.adb +++ b/sem_expr.adb @@ -505,6 +505,7 @@ package body Sem_Expr is is Base_Type: Iir; Left, Right: Iir; + Left_Type, Right_Type : Iir; Expr_Type : Iir; begin Expr_Type := Get_Type (Expr); @@ -540,7 +541,22 @@ package body Sem_Expr is return Null_Iir; end if; - if Is_Overloaded (Left) or else Is_Overloaded (Right) then + Left_Type := Get_Type (Left); + Right_Type := Get_Type (Right); + -- Check for string or aggregate literals + -- FIXME: improve error message + if Left_Type = Null_Iir then + Error_Msg_Sem ("bad expression for a scalar", Left); + return Null_Iir; + end if; + if Right_Type = Null_Iir then + Error_Msg_Sem ("bad expression for a scalar", Right); + return Null_Iir; + end if; + + if Is_Overload_List (Left_Type) + or else Is_Overload_List (Right_Type) + then if Base_Type /= Null_Iir then -- Cannot happen, since sem_expression_ov should resolved -- ambiguties if a type is given. @@ -548,21 +564,20 @@ package body Sem_Expr is end if; -- Try to find a common type. - Base_Type := Search_Compatible_Type - (Get_Type (Left), Get_Type (Right)); + Base_Type := Search_Compatible_Type (Left_Type, Right_Type); if Base_Type = Null_Iir then - if Compatibility_Types1 - (Universal_Integer_Type_Definition, Get_Type (Left)) + if Compatibility_Types1 (Universal_Integer_Type_Definition, + Left_Type) and then - Compatibility_Types1 - (Universal_Integer_Type_Definition, Get_Type (Right)) + Compatibility_Types1 (Universal_Integer_Type_Definition, + Right_Type) then Base_Type := Universal_Integer_Type_Definition; - elsif Compatibility_Types1 - (Universal_Real_Type_Definition, Get_Type (Left)) + elsif Compatibility_Types1 (Universal_Real_Type_Definition, + Left_Type) and then - Compatibility_Types1 - (Universal_Real_Type_Definition, Get_Type (Right)) + Compatibility_Types1 (Universal_Real_Type_Definition, + Right_Type) then Base_Type := Universal_Real_Type_Definition; else @@ -3997,6 +4012,11 @@ package body Sem_Expr is return Null_Iir; end if; Expr_Type := Get_Type (Expr1); + if Expr_Type = Null_Iir then + -- FIXME: improve message + Error_Msg_Sem ("bad expression for a scalar", Expr); + return Null_Iir; + end if; if not Is_Overload_List (Expr_Type) then return Expr1; end if; |