{
// XXX: prefer not to print_error at every nest/unroll level
semantic_error* er = new SEMANTIC_ERROR (_("while resolving probe point"),
- loc->components[0]->tok);
- er->chain = & e;
+ loc->components[0]->tok, NULL, &e);
s.print_error (* er);
delete er;
}
chain_msg << _F(" of index %d", index);
chain_msg << _F(" was first inferred here (%s)",
lex_cast(decl->type).c_str());
- err.chain = new SEMANTIC_ERROR(chain_msg.str(), original->tok);
+ semantic_error chain(ERR_SRC, chain_msg.str(), original->tok);
+ err.set_chain(chain);
session.print_error (err);
- if (err.chain) delete err.chain;
}
else if (!assert_resolvability)
mismatch_complexity = max(3, mismatch_complexity);
}
catch (const semantic_error& e)
{
- semantic_error* er = new SEMANTIC_ERROR (_("while registering probe alias"),
- alias->tok);
- er->chain = & e;
- print_error (* er);
- delete er;
+ semantic_error er(ERR_SRC, _("while registering probe alias"),
+ alias->tok, NULL, &e);
+ print_error (er);
}
}
}
if (verbose > 0 || seen_errors[se.errsrc_chain()] < 1)
{
seen_errors[se.errsrc_chain()]++;
- for (const semantic_error *e = &se; e != NULL; e = e->chain)
+ for (const semantic_error *e = &se; e != NULL; e = e->get_chain())
cerr << build_error_msg(*e);
}
else suppressed_errors++;
if (arity != a && arity >= 0)
{
semantic_error err (ERR_SRC, _F("inconsistent arity (%s vs %d)",
- lex_cast(arity).c_str(), a), t?:tok);
+ lex_cast(arity).c_str(), a), t?:tok);
if (arity_tok)
- err.chain = new SEMANTIC_ERROR (_F("arity %s first inferred here",
+ {
+ semantic_error chain(ERR_SRC, _F("arity %s first inferred here",
lex_cast(arity).c_str()), arity_tok);
+ err.set_chain(chain);
+ }
throw err;
}
semantic_error* e = new semantic_error(er);
if (!e->tok1)
e->tok1 = this->tok;
- assert (e->chain == 0);
- e->chain = this->saved_conversion_error;
+ assert (e->get_chain() == 0);
+ if (this->saved_conversion_error)
+ {
+ e->set_chain(*this->saved_conversion_error);
+ delete this->saved_conversion_error;
+ }
this->saved_conversion_error = e;
}
{
const token* tok1;
const token* tok2;
- const semantic_error *chain;
- const std::string errsrc;
+ std::string errsrc;
- ~semantic_error () throw () {}
+ ~semantic_error () throw ()
+ {
+ if (chain)
+ delete chain;
+ }
semantic_error (const std::string& src, const std::string& msg, const token* t1=0):
- runtime_error (msg), tok1 (t1), tok2 (0), chain (0), errsrc(src) {}
+ runtime_error (msg), tok1 (t1), tok2 (0), errsrc (src), chain (0) {}
semantic_error (const std::string& src, const std::string& msg, const token* t1,
- const token* t2):
- runtime_error (msg), tok1 (t1), tok2 (t2), chain (0), errsrc(src) {}
+ const token* t2, const semantic_error* chn=0):
+ runtime_error (msg), tok1 (t1), tok2 (t2), errsrc (src), chain (0)
+ {
+ if (chn)
+ set_chain(*chn);
+ }
+
+ /* override copy-ctor to deep-copy chain */
+ semantic_error (const semantic_error& other):
+ runtime_error(other), tok1(other.tok1), tok2(other.tok2),
+ errsrc(other.errsrc), chain (0)
+ {
+ if (other.chain)
+ set_chain(*other.chain);
+ }
std::string errsrc_chain(void) const
{
return errsrc + (chain ? "|" + chain->errsrc_chain() : "");
}
+
+ void set_chain(const semantic_error& new_chain)
+ {
+ if (chain)
+ delete chain;
+ chain = new semantic_error(new_chain);
+ }
+
+ const semantic_error* get_chain(void) const
+ {
+ return chain;
+ }
+
+private:
+ const semantic_error* chain;
};
// ------------------------------------------------------------------------
{
for (const semantic_error *c = tsym->saved_conversion_error;
c != 0;
- c = c->chain) {
+ c = c->get_chain()) {
clog << _("variable location problem [man error::dwarf]: ") << c->what() << endl;
}
}
{
if (dw.sess.verbose>2)
for (const semantic_error *c = tsym->saved_conversion_error;
- c != 0; c = c->chain)
+ c != 0; c = c->get_chain())
clog << _("variable location problem [man error::dwarf]: ") << c->what() << endl;
pf->raw_components += "=?";
continue;