From 53429589b199ccef41241e8dbc0c3a2d461211d3 Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Thu, 3 Mar 2011 00:28:53 +0000 Subject: [PATCH] Fix for pr3197861. This patch adds a check on the expression type before adjusting an unsized expression width up to integer_width. This adjustment should only be performed for vectorable expressions. The patch also fixes a few compiler warnings that only show up on 32-bit builds. --- elab_expr.cc | 9 +++++---- netmisc.cc | 2 ++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/elab_expr.cc b/elab_expr.cc index b9cf8eec8..c8404859a 100644 --- a/elab_expr.cc +++ b/elab_expr.cc @@ -110,7 +110,8 @@ NetExpr* elaborate_rval_expr(Design*des, NetScope*scope, unsigned PExpr::fix_width_(width_mode_t mode) { unsigned width = expr_width_; - if ((mode == UNSIZED) && (width < integer_width)) + if ((mode == UNSIZED) && type_is_vectorable(expr_type_) + && (width < integer_width)) expr_width_ = integer_width; return width; @@ -459,7 +460,7 @@ NetExpr* PEBinary::elaborate_expr_base_lshift_(Design*des, } } else if (NetEConst*rpc = dynamic_cast (rp)) { - long shift = rpc->value().as_long(); + unsigned long shift = rpc->value().as_ulong(); // Special case: The shift is at least the size of the entire // left operand. Elaborate as a constant-0. @@ -520,7 +521,7 @@ NetExpr* PEBinary::elaborate_expr_base_rshift_(Design*des, } if (NetEConst*rpc = dynamic_cast (rp)) { - long shift = rpc->value().as_ulong(); + unsigned long shift = rpc->value().as_ulong(); // Special case: The shift is the size of the entire // left operand, and the shift is unsigned. Elaborate as @@ -3435,7 +3436,7 @@ NetExpr*PETernary::elaborate_expr(Design*des, NetScope*scope, NetExpr* PETernary::elab_and_eval_alternative_(Design*des, NetScope*scope, PExpr*expr, unsigned expr_wid) const { - unsigned context_wid = expr_wid; + int context_wid = expr_wid; if (type_is_vectorable(expr->expr_type()) && !type_is_vectorable(expr_type_)) { expr_wid = expr->expr_width(); context_wid = -1; diff --git a/netmisc.cc b/netmisc.cc index d3fc7a18d..0479092ff 100644 --- a/netmisc.cc +++ b/netmisc.cc @@ -459,6 +459,8 @@ static const char*width_mode_name(PExpr::width_mode_t mode) switch (mode) { case PExpr::SIZED: return "sized"; + case PExpr::EXPAND: + return "expand"; case PExpr::LOSSLESS: return "lossless"; case PExpr::UNSIZED: