#1264 Fixes for implicit casts in assignments

closed
nobody
None
5
2013-03-24
2013-03-01
No

The attached bundle of regression tests attempt to test all the cases where an implicit cast occurs as part of an assignment. Many of the tests either give incorrect results or cause a compiler or run-time crash.

All tests require the -g2009 option and are self-checking.

Following are a sequence of 5 patches that fix these issues.

1 Attachments

Discussion

  • Martin Whitaker

    Martin Whitaker - 2013-03-01

    This patch adds support for implicit casts to the elaborate_rval_expr() function. This will handle the majority of cases where an implicit cast can occur.

    Note that the cast is inserted by elab_and_eval() just before the expression is evaluated. This allows the cast to be optimised away in constant expressions.

     
  • Martin Whitaker

    Martin Whitaker - 2013-03-01

    This patch extends support for implicit casts in module port connections and adds support for implicit casts in user task output assignments.

     
  • Martin Whitaker

    Martin Whitaker - 2013-03-01

    This patch adds support for bool/bit vector types on the LHS of a parameter declaration and ensures implicit casts to or from these types in parameter declarations are performed where necessary.

    UPDATE: Revised patch to eliminate collision on copyright date changes.

     
    Last edit: Martin Whitaker 2013-03-24
  • Martin Whitaker

    Martin Whitaker - 2013-03-01

    This patch fixes a few issues/bugs that showed up when testing the fixes for implicit casts:

    1. Make the compile-time implementation of $abs, $min, and $max match
      the run-time behaviour (system functions can't be polymorphic).

    2. Correctly set the type (signed/unsigned) of the result of an
      assignment inside a constant user function (the LHS should not
      inherit the type of the RHS).

    3. Fix a bug in the verinum(double) constructor (insufficient bits
      were allocated in the case where the double value rounded up to
      the next power of two).

     
  • Martin Whitaker

    Martin Whitaker - 2013-03-01

    And finally, this patch removes some code that has been made redundant by the
    more general handling of implicit casts.

    I've also disabled some code which I believe should have been made redundant by the expression elaboration rework (expression elaboration should now guarantee that the RHS of an assignment is as least as wide as the LHS) but am not quite brave enough to delete straight away.

     
  • Martin Whitaker

    Martin Whitaker - 2013-03-01

    A final note - you will find that pr1741212 in the test suite now fails. This is because the gold file is wrong. These two lines are obviously incorrect

    log2(MATH_PI): 4.536886
    log_base(pow(2,32),2): 40.215917

    and I have checked all the other differences and satisfied myself that the new behaviour is correct.

     
  • Martin Whitaker

    Martin Whitaker - 2013-03-05

    A couple of small fixes to the above. IVL_VT_NO_TYPE is now used to signal an untyped LHS in a parameter declaration. The parser function that handles specparam declarations needs to do this too. Also, although it should never happen, make sure we don't set the expression width in a NetECast object to a
    negative number.

    UPDATE: Added changes to make constant evaluation of NetECast objects observe the expression width.

     
    Last edit: Martin Whitaker 2013-03-06
  • Martin Whitaker

    Martin Whitaker - 2013-03-05

    This update to the specparam1 test checks that specparam declarations with no type on the LHS correctly inherit the type of the RHS.

     
    Attachments
  • Stephen Williams

    I've applied the first two patches to git master, but patch #3 seems to conflict with some changes that Cary made. I think I should let you two sort that out.

    I have added all the tests to the ivtest suite in git master.

     
  • Cary R.

    Cary R. - 2013-03-24

    That's most unfortunate. I think since my stuff is already pushed into git Martin will need to regenerate a patch that applies cleanly, Sorry about this Martin.

     
  • Stephen Williams

    OK, thanks for the updates. I've applied and pushed all the patches to git master, and I've applied all the updates to ivtest git master.

     
  • Stephen Williams

    • status: open --> closed
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks