aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl/vhdl-sem_assocs.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-02-01 17:17:29 +0100
committerTristan Gingold <tgingold@free.fr>2020-02-01 17:17:29 +0100
commitf0d2cb1cb5c01f460a72051735a129063690574b (patch)
treea6f160c2797b476ef39c3a13f7f5d91905b0a1ef /src/vhdl/vhdl-sem_assocs.adb
parent841790b42b7be2fada2bd12faeb68dc020ccb908 (diff)
downloadghdl-f0d2cb1cb5c01f460a72051735a129063690574b.tar.gz
ghdl-f0d2cb1cb5c01f460a72051735a129063690574b.tar.bz2
ghdl-f0d2cb1cb5c01f460a72051735a129063690574b.zip
vhdl-sem_assocs: minor rework.
Diffstat (limited to 'src/vhdl/vhdl-sem_assocs.adb')
-rw-r--r--src/vhdl/vhdl-sem_assocs.adb64
1 files changed, 32 insertions, 32 deletions
diff --git a/src/vhdl/vhdl-sem_assocs.adb b/src/vhdl/vhdl-sem_assocs.adb
index 45a8b56f7..47f45c380 100644
--- a/src/vhdl/vhdl-sem_assocs.adb
+++ b/src/vhdl/vhdl-sem_assocs.adb
@@ -1249,44 +1249,44 @@ package body Vhdl.Sem_Assocs is
return True;
end Is_Conversion_Function;
- function Is_Valid_Conversion
- (Func : Iir; Res_Base_Type : Iir; Param_Base_Type : Iir) return Boolean
+ function Is_Valid_Type_Conversion
+ (Conv : Iir; Res_Base_Type : Iir; Param_Base_Type : Iir) return Boolean
+ is
+ Atype : constant Iir := Get_Type (Conv);
+ begin
+ return Get_Base_Type (Atype) = Res_Base_Type
+ and then Are_Types_Closely_Related (Atype, Param_Base_Type);
+ end Is_Valid_Type_Conversion;
+
+ function Is_Valid_Function_Conversion
+ (Call : Iir; Res_Base_Type : Iir; Param_Base_Type : Iir) return Boolean
is
- R_Type : Iir;
- P_Type : Iir;
+ Imp : constant Iir := Get_Implementation (Call);
+ Res_Type : constant Iir := Get_Type (Imp);
+ Inters : constant Iir := Get_Interface_Declaration_Chain (Imp);
+ Param_Type : Iir;
+ begin
+ if Inters = Null_Iir then
+ return False;
+ end if;
+ Param_Type := Get_Type (Inters);
+
+ return Get_Base_Type (Res_Type) = Res_Base_Type
+ and then Get_Base_Type (Param_Type) = Param_Base_Type;
+ end Is_Valid_Function_Conversion;
+
+ function Is_Valid_Conversion
+ (Func : Iir; Res_Base_Type : Iir; Param_Base_Type : Iir) return Boolean is
begin
case Get_Kind (Func) is
- when Iir_Kind_Function_Declaration =>
- R_Type := Get_Type (Func);
- P_Type := Get_Type (Get_Interface_Declaration_Chain (Func));
- if Get_Base_Type (R_Type) = Res_Base_Type
- and then Get_Base_Type (P_Type) = Param_Base_Type
- then
- return True;
- else
- return False;
- end if;
- when Iir_Kind_Type_Declaration
- | Iir_Kind_Subtype_Declaration =>
- R_Type := Get_Type (Func);
- if Get_Base_Type (R_Type) = Res_Base_Type
- and then Are_Types_Closely_Related (R_Type, Param_Base_Type)
- then
- return True;
- else
- return False;
- end if;
when Iir_Kind_Function_Call =>
- return Is_Valid_Conversion (Get_Implementation (Func),
- Res_Base_Type, Param_Base_Type);
+ return Is_Valid_Function_Conversion
+ (Func, Res_Base_Type, Param_Base_Type);
when Iir_Kind_Type_Conversion =>
- return Is_Valid_Conversion (Get_Type_Mark (Func),
- Res_Base_Type, Param_Base_Type);
- when Iir_Kinds_Denoting_Name =>
- return Is_Valid_Conversion (Get_Named_Entity (Func),
- Res_Base_Type, Param_Base_Type);
+ return Is_Valid_Type_Conversion
+ (Func, Res_Base_Type, Param_Base_Type);
when others =>
- return False;
+ Error_Kind ("is_valid_conversion", Func);
end case;
end Is_Valid_Conversion;