Cleanup from yesterday's "Add more error checking" patch

Removes const char related compiler warnings,
tidies up mainline code by abstracting the human_readable_op() routine
This commit is contained in:
Larry Doolittle 2008-02-01 12:07:04 -08:00 committed by Stephen Williams
parent 9c0d2c13c9
commit f4cf7b1799
1 changed files with 28 additions and 20 deletions

View File

@ -29,6 +29,26 @@
# include <iostream> # include <iostream>
# include "ivl_assert.h" # include "ivl_assert.h"
/*
* Human readable version of op_ used in NetEBinary and NetEUnary.
* XXX This isn't a complete list, but it's enough to cover the
* restricted cases it is used for.
*/
static const char *human_readable_op(const char op_)
{
const char *type;
switch (op_) {
case '^': type = "^"; break; // XOR
case 'X': type = "~^"; break; // XNOR
case '&': type = "&"; break; // AND
case 'A': type = "~&"; break; // NAND (~&)
case '|': type = "|"; break; // Bitwise OR
case 'O': type = "~|"; break; // Bitwise NOR
default: assert(0);
}
return type;
}
/* /*
* This is a state flag that determines whether an elaborate_net must * This is a state flag that determines whether an elaborate_net must
* report an error when it encounters an unsized number. Normally, it * report an error when it encounters an unsized number. Normally, it
@ -287,17 +307,7 @@ NetNet* PEBinary::elaborate_net_bit_(Design*des, NetScope*scope,
/* The types match here and real is not supported. */ /* The types match here and real is not supported. */
if (lsig->data_type() == IVL_VT_REAL) { if (lsig->data_type() == IVL_VT_REAL) {
char *type; cerr << get_fileline() << ": error: " << human_readable_op(op_)
switch (op_) {
case '^': type = "^"; break; // XOR
case 'X': type = "~^"; break; // XNOR
case '&': type = "&"; break; // AND
case 'A': type = "~&"; break; // NAND (~&)
case '|': type = "|"; break; // Bitwise OR
case 'O': type = "~|"; break; // Bitwise NOR
default: assert(0);
}
cerr << get_fileline() << ": error: " << type
<< " operator may not have REAL operands." << endl; << " operator may not have REAL operands." << endl;
des->errors += 1; des->errors += 1;
return 0; return 0;
@ -3542,8 +3552,6 @@ NetNet* PEUnary::elab_net_unary_real_(Design*des, NetScope*scope,
sig->local_flag(true); sig->local_flag(true);
sig->set_line(*this); sig->set_line(*this);
char *type=0;
switch (op_) { switch (op_) {
default: default:
@ -3551,13 +3559,13 @@ NetNet* PEUnary::elab_net_unary_real_(Design*des, NetScope*scope,
<< op_ << " expression with real values." << endl; << op_ << " expression with real values." << endl;
des->errors += 1; des->errors += 1;
break; break;
case '&': type = "&"; if(0){ case '&':
case 'A': type = "~&"; }if(0){ case 'A':
case '|': type = "|"; }if(0){ case '|':
case 'N': type = "~|"; }if(0){ case 'N':
case '^': type = "^"; }if(0){ case '^':
case 'X': type = "~^"; } case 'X':
cerr << get_fileline() << ": error: " << type cerr << get_fileline() << ": error: " << human_readable_op(op_)
<< " reduction operator may not have a REAL operand." << endl; << " reduction operator may not have a REAL operand." << endl;
des->errors += 1; des->errors += 1;
break; break;