aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl/sem.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2016-12-15 09:04:43 +0100
committerTristan Gingold <tgingold@free.fr>2016-12-15 09:04:43 +0100
commit60f245f0bc7046e8050162b9ab26571a490c2ac4 (patch)
tree6696e5a8f5e010e0e259dcf946ff9248f80927c8 /src/vhdl/sem.adb
parent93bf03fbc429f7a588b59deaea73e9f4c3d2fc5b (diff)
downloadghdl-60f245f0bc7046e8050162b9ab26571a490c2ac4.tar.gz
ghdl-60f245f0bc7046e8050162b9ab26571a490c2ac4.tar.bz2
ghdl-60f245f0bc7046e8050162b9ab26571a490c2ac4.zip
assocs: rework conversion.
An actual is analyzed as a conversion if the inner expression is an object of the right class. Fix #225
Diffstat (limited to 'src/vhdl/sem.adb')
-rw-r--r--src/vhdl/sem.adb109
1 files changed, 44 insertions, 65 deletions
diff --git a/src/vhdl/sem.adb b/src/vhdl/sem.adb
index 81fb79ccc..ba6eaf481 100644
--- a/src/vhdl/sem.adb
+++ b/src/vhdl/sem.adb
@@ -528,78 +528,57 @@ package body Sem is
-- There has been an error, exit from the loop.
exit when Actual = Null_Iir;
Object := Name_To_Object (Actual);
- if Object = Null_Iir then
- Prefix := Actual;
- else
+ if Is_Valid (Object) and then Is_Signal_Object (Object) then
+ -- Port or signal.
+ Set_Collapse_Signal_Flag
+ (Assoc, Can_Collapse_Signals (Assoc, Formal));
+ if Get_Name_Staticness (Object) < Globally then
+ Error_Msg_Sem (+Actual, "actual must be a static name");
+ end if;
+ Check_Port_Association_Bounds_Restrictions
+ (Formal, Actual, Assoc);
Prefix := Get_Object_Prefix (Object);
- end if;
- case Get_Kind (Prefix) is
- when Iir_Kind_Signal_Declaration
- | Iir_Kind_Interface_Signal_Declaration
- | Iir_Kind_Guard_Signal_Declaration
- | Iir_Kinds_Signal_Attribute =>
- -- Port or signal.
- Set_Collapse_Signal_Flag
- (Assoc, Can_Collapse_Signals (Assoc, Formal));
- if Get_Name_Staticness (Object) < Globally then
- Error_Msg_Sem (+Actual, "actual must be a static name");
- end if;
- Check_Port_Association_Bounds_Restrictions
- (Formal, Actual, Assoc);
- if Get_Kind (Prefix) = Iir_Kind_Interface_Signal_Declaration
- then
- declare
- P : Boolean;
- pragma Unreferenced (P);
- begin
- P := Check_Port_Association_Mode_Restrictions
- (Formal_Base, Prefix, Assoc);
- end;
- end if;
- when others =>
- -- Expression.
- Set_Collapse_Signal_Flag (Assoc, False);
-
- -- If there is an IN conversion, re-integrate it into
- -- the actual.
+ if Get_Kind (Prefix) = Iir_Kind_Interface_Signal_Declaration
+ then
declare
- In_Conv : Iir;
+ P : Boolean;
+ pragma Unreferenced (P);
begin
- In_Conv := Get_In_Conversion (Assoc);
- if In_Conv /= Null_Iir then
- Set_In_Conversion (Assoc, Null_Iir);
- Set_Expr_Staticness
- (In_Conv, Get_Expr_Staticness (Actual));
- Actual := In_Conv;
- Set_Actual (Assoc, Actual);
- end if;
+ P := Check_Port_Association_Mode_Restrictions
+ (Formal_Base, Prefix, Assoc);
end;
- if Flags.Vhdl_Std >= Vhdl_93c then
- -- LRM93 1.1.1.2 Ports
- -- Moreover, the ports of a block may be associated
- -- with an expression, in order to provide these ports
- -- with constant driving values; such ports must be
- -- of mode in.
- if Get_Mode (Formal_Base) /= Iir_In_Mode then
- Error_Msg_Sem
- (+Assoc, "only 'in' ports may be associated with "
- & "expression");
- end if;
+ end if;
+ else
+ -- Expression.
+ Set_Collapse_Signal_Flag (Assoc, False);
+
+ pragma Assert (Is_Null (Get_In_Conversion (Assoc)));
+ if Flags.Vhdl_Std >= Vhdl_93c then
+ -- LRM93 1.1.1.2 Ports
+ -- Moreover, the ports of a block may be associated
+ -- with an expression, in order to provide these ports
+ -- with constant driving values; such ports must be
+ -- of mode in.
+ if Get_Mode (Formal_Base) /= Iir_In_Mode then
+ Error_Msg_Sem
+ (+Assoc, "only 'in' ports may be associated with "
+ & "expression");
+ end if;
- -- LRM93 1.1.1.2 Ports
- -- The actual, if an expression, must be a globally
- -- static expression.
- if Get_Expr_Staticness (Actual) < Globally then
- Error_Msg_Sem
- (+Actual,
- "actual expression must be globally static");
- end if;
- else
+ -- LRM93 1.1.1.2 Ports
+ -- The actual, if an expression, must be a globally
+ -- static expression.
+ if Get_Expr_Staticness (Actual) < Globally then
Error_Msg_Sem
- (+Assoc,
- "cannot associate ports with expression in vhdl87");
+ (+Actual,
+ "actual expression must be globally static");
end if;
- end case;
+ else
+ Error_Msg_Sem
+ (+Assoc,
+ "cannot associate ports with expression in vhdl87");
+ end if;
+ end if;
end if;
Next_Association_Interface (Assoc, Inter);
end loop;