From 142f6617378cd28c5202dada4b06003f255b6d31 Mon Sep 17 00:00:00 2001 From: Cary R Date: Mon, 2 Jan 2012 10:11:56 -0800 Subject: [PATCH] Fix the compiler to keep the original file/line information. For a parameter we want to keep the base definition file/line information not the file/line information for the override. --- PExpr.h | 8 ++++---- elab_expr.cc | 28 +++++++++++++++++++++++----- libmisc/LineInfo.h | 4 ++-- net_design.cc | 4 ++-- 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/PExpr.h b/PExpr.h index 8aa74beee..e087cb592 100644 --- a/PExpr.h +++ b/PExpr.h @@ -354,7 +354,7 @@ class PEIdent : public PExpr { NetExpr*elaborate_expr_param_(Design*des, NetScope*scope, const NetExpr*par, - NetScope*found, + NetScope*found_in, const NetExpr*par_msb, const NetExpr*par_lsb, unsigned expr_wid, @@ -362,21 +362,21 @@ class PEIdent : public PExpr { NetExpr*elaborate_expr_param_part_(Design*des, NetScope*scope, const NetExpr*par, - NetScope*found, + NetScope*found_in, const NetExpr*par_msb, const NetExpr*par_lsb, unsigned expr_wid) const; NetExpr*elaborate_expr_param_idx_up_(Design*des, NetScope*scope, const NetExpr*par, - NetScope*found, + NetScope*found_in, const NetExpr*par_msb, const NetExpr*par_lsb, bool need_const) const; NetExpr*elaborate_expr_param_idx_do_(Design*des, NetScope*scope, const NetExpr*par, - NetScope*found, + NetScope*found_in, const NetExpr*par_msb, const NetExpr*par_lsb, bool need_const) const; diff --git a/elab_expr.cc b/elab_expr.cc index ad24ecff3..42ef38108 100644 --- a/elab_expr.cc +++ b/elab_expr.cc @@ -2540,7 +2540,7 @@ static void warn_param_ob(long par_msv, long par_lsv, bool defined, NetExpr* PEIdent::elaborate_expr_param_idx_up_(Design*des, NetScope*scope, const NetExpr*par, - NetScope*, + NetScope*found_in, const NetExpr*par_msb, const NetExpr*par_lsb, bool need_const) const @@ -2613,6 +2613,12 @@ NetExpr* PEIdent::elaborate_expr_param_idx_up_(Design*des, NetScope*scope, base = normalize_variable_base(base, par_msv, par_lsv, wid, true); NetExpr*tmp = par->dup_expr(); + if (!tmp) return 0; + + /* The numeric parameter value needs to have the file and line + * information for the actual parameter not the expression. */ + NetScope::param_ref_t pref = found_in->find_parameter(peek_tail_name(path_)); + tmp->set_line((*pref).second); tmp = new NetESelect(tmp, base, wid, IVL_SEL_IDX_UP); tmp->set_line(*this); return tmp; @@ -2620,7 +2626,7 @@ NetExpr* PEIdent::elaborate_expr_param_idx_up_(Design*des, NetScope*scope, NetExpr* PEIdent::elaborate_expr_param_idx_do_(Design*des, NetScope*scope, const NetExpr*par, - NetScope*, + NetScope*found_in, const NetExpr*par_msb, const NetExpr*par_lsb, bool need_const) const @@ -2694,6 +2700,12 @@ NetExpr* PEIdent::elaborate_expr_param_idx_do_(Design*des, NetScope*scope, base = normalize_variable_base(base, par_msv, par_lsv, wid, false); NetExpr*tmp = par->dup_expr(); + if (!tmp) return 0; + + /* The numeric parameter value needs to have the file and line + * information for the actual parameter not the expression. */ + NetScope::param_ref_t pref = found_in->find_parameter(peek_tail_name(path_)); + tmp->set_line((*pref).second); tmp = new NetESelect(tmp, base, wid, IVL_SEL_IDX_DOWN); tmp->set_line(*this); return tmp; @@ -2748,8 +2760,14 @@ NetExpr* PEIdent::elaborate_expr_param_(Design*des, // rewritten in the above format, as I get to it. NetExpr*tmp = par->dup_expr(); - if (!tmp) - return 0; + if (!tmp) return 0; + + /* The numeric parameter value needs to have the file and line + * information for the actual parameter not the expression. */ + if (! dynamic_cast(tmp)) { + NetScope::param_ref_t pref = found_in->find_parameter(peek_tail_name(path_)); + tmp->set_line((*pref).second); + } if (use_sel == index_component_t::SEL_BIT) { ivl_assert(*this, !name_tail.index.empty()); @@ -2846,6 +2864,7 @@ NetExpr* PEIdent::elaborate_expr_param_(Design*des, NetEConst*re2 = new NetEConst(verinum(rb, 1)); + re2->set_line(*this); delete tmp; delete mtmp; tmp = re2; @@ -2911,7 +2930,6 @@ NetExpr* PEIdent::elaborate_expr_param_(Design*des, } } - tmp->set_line(*this); return tmp; } diff --git a/libmisc/LineInfo.h b/libmisc/LineInfo.h index f2262b568..357360fad 100644 --- a/libmisc/LineInfo.h +++ b/libmisc/LineInfo.h @@ -1,7 +1,7 @@ #ifndef __LineInfo_H #define __LineInfo_H /* - * Copyright (c) 1999-2009 Stephen Williams (steve@icarus.com) + * Copyright (c) 1999-2011 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -40,7 +40,7 @@ class LineInfo { // Get a fully formatted file/lineno string get_fileline() const; - // Set the file/line fro another LineInfo object. + // Set the file/line from another LineInfo object. void set_line(const LineInfo&that); // Access parts of LineInfo data diff --git a/net_design.cc b/net_design.cc index 84f4a7a34..3ed2fef8c 100644 --- a/net_design.cc +++ b/net_design.cc @@ -641,8 +641,8 @@ void NetScope::evaluate_parameters(Design*des) cur->second->evaluate_parameters(des); if (debug_scopes) - cerr << ":0" << ": debug: " - << "Evaluate parameters in " << scope_path(this) << endl; + cerr << "debug: " + << "Evaluating parameters in " << scope_path(this) << endl; for (param_ref_t cur = parameters.begin() ; cur != parameters.end() ; ++ cur) {