diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/vhdl/iirs_utils.adb | 2 | ||||
| -rw-r--r-- | src/vhdl/sem.adb | 109 | ||||
| -rw-r--r-- | src/vhdl/sem_assocs.adb | 51 | 
3 files changed, 83 insertions, 79 deletions
| diff --git a/src/vhdl/iirs_utils.adb b/src/vhdl/iirs_utils.adb index 99ce824e9..ac9b965dd 100644 --- a/src/vhdl/iirs_utils.adb +++ b/src/vhdl/iirs_utils.adb @@ -240,6 +240,8 @@ package body Iirs_Utils is                 Adecl := Get_Named_Entity (Adecl);              when Iir_Kind_Attribute_Name =>                 return Get_Named_Entity (Adecl); +            when Iir_Kind_Error => +               return Adecl;              when others =>                 Error_Kind ("get_object_prefix", Adecl);           end case; 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; diff --git a/src/vhdl/sem_assocs.adb b/src/vhdl/sem_assocs.adb index b85050ff3..f113db244 100644 --- a/src/vhdl/sem_assocs.adb +++ b/src/vhdl/sem_assocs.adb @@ -1992,21 +1992,44 @@ package body Sem_Assocs is        Actual := Get_Actual (Assoc);        In_Conv := Null_Iir;        if Get_Kind (Inter) /= Iir_Kind_Interface_Constant_Declaration then -         case Get_Kind (Actual) is -            when Iir_Kind_Function_Call => -               Expr := Get_Parameter_Association_Chain (Actual); -               if Is_Conversion_Function (Expr) then -                  In_Conv := Actual; -                  Actual := Get_Actual (Expr); -               end if; -            when Iir_Kind_Type_Conversion => -               if Flags.Vhdl_Std > Vhdl_87 then -                  In_Conv := Actual; -                  Actual := Get_Expression (Actual); +         declare +            --  Actual before the extraction of the conversion. +            Prev_Actual : constant Iir := Actual; +         begin +            --  Extract conversion and new actual (conv_expr). +            case Get_Kind (Actual) is +               when Iir_Kind_Function_Call => +                  Expr := Get_Parameter_Association_Chain (Actual); +                  if Is_Conversion_Function (Expr) then +                     In_Conv := Actual; +                     Actual := Get_Actual (Expr); +                  end if; +               when Iir_Kind_Type_Conversion => +                  if Flags.Vhdl_Std > Vhdl_87 then +                     In_Conv := Actual; +                     Actual := Get_Expression (Actual); +                  end if; +               when others => +                  null; +            end case; + +            --  There could be an ambiguity between a conversion and a normal +            --  actual expression.  Check if the new actual is an object and +            --  if the object is of the corresponding class. +            if Is_Valid (In_Conv) then +               if Get_Kind (Inter) = Iir_Kind_Interface_Signal_Declaration then +                  if not Is_Signal_Object (Actual) then +                     --  Actual is not a signal object.  This is not a +                     --  conversion but a regular association. +                     In_Conv := Null_Iir; +                     Actual := Prev_Actual; +                  end if; +               else +                  --  Variable: let as is. +                  null;                 end if; -            when others => -               null; -         end case; +            end if; +         end;        end if;        --  4 cases: F:out_conv, G:in_conv. | 
