summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--elaborate.cxx2
-rw-r--r--tapsets.cxx30
-rwxr-xr-xtestsuite/semok/cast.stp6
3 files changed, 20 insertions, 18 deletions
diff --git a/elaborate.cxx b/elaborate.cxx
index 6fb3f197..7c4a5fca 100644
--- a/elaborate.cxx
+++ b/elaborate.cxx
@@ -3448,7 +3448,7 @@ typeresolution_info::visit_cast_op (cast_op* e)
if (e->saved_conversion_error)
throw (* (e->saved_conversion_error));
else
- throw semantic_error("unresolved cast expression", e->tok);
+ throw semantic_error("type definition '" + e->type + "' not found", e->tok);
}
diff --git a/tapsets.cxx b/tapsets.cxx
index 1e0d9e6b..ac43a222 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -4775,13 +4775,13 @@ dwarf_var_expanding_visitor::visit_cast_op (cast_op *e)
struct dwarf_cast_query : public base_query
{
- const cast_op& e;
+ cast_op& e;
const bool lvalue;
exp_type& pe_type;
string& code;
- dwarf_cast_query(dwflpp& dw, const string& module, const cast_op& e,
+ dwarf_cast_query(dwflpp& dw, const string& module, cast_op& e,
bool lvalue, exp_type& pe_type, string& code):
base_query(dw, module), e(e), lvalue(lvalue),
pe_type(pe_type), code(code) {}
@@ -4819,11 +4819,15 @@ dwarf_cast_query::handle_query_cu(Dwarf_Die * cudie)
code = dw.literal_stmt_for_pointer (type_die, &e,
lvalue, pe_type);
}
- catch (const semantic_error& e)
+ catch (const semantic_error& er)
{
- // XXX might be better to save the error
- // and try again in another CU
- sess.print_error (e);
+ // XXX might be better to try again in another CU
+ // NB: we can have multiple errors, since a @cast
+ // may be expanded in several different contexts:
+ // function ("*") { @cast(...) }
+ semantic_error* new_er = new semantic_error(er);
+ new_er->chain = e.saved_conversion_error;
+ e.saved_conversion_error = new_er;
}
return DWARF_CB_ABORT;
}
@@ -4972,17 +4976,9 @@ void dwarf_cast_expanding_visitor::visit_cast_op (cast_op* e)
if (code.empty())
{
- // We generate an error message, and pass the unresolved
- // cast_op to the next pass. We hope that this value ends
- // up not being referenced after all, so it can be optimized out
- // quietly.
- string msg = "type definition '" + e->type + "' not found";
- semantic_error* er = new semantic_error (msg, e->tok);
- // NB: we can have multiple errors, since a @cast
- // may be expanded in several different contexts:
- // function ("*") { @cast(...) }
- er->chain = e->saved_conversion_error;
- e->saved_conversion_error = er;
+ // We pass the unresolved cast_op to the next pass, and hope
+ // that this value ends up not being referenced after all, so
+ // it can be optimized out quietly.
provide (e);
return;
}
diff --git a/testsuite/semok/cast.stp b/testsuite/semok/cast.stp
index 769335f2..14401886 100755
--- a/testsuite/semok/cast.stp
+++ b/testsuite/semok/cast.stp
@@ -14,4 +14,10 @@ probe begin {
// check modules generated from headers
println(@cast(0, "task_struct", "kernel<linux/sched.h>")->tgid)
println(@cast(0, "timeval", "<sys/time.h>")->tv_sec)
+
+ // make sure that bogus @casts can get optimized away
+ @cast(0, "task_struct")->no_such_field
+ @cast(0, "task_struct")->parent->no_such_field
+ @cast(0, "no_such_type")->tgid
+ @cast(0, "task_struct", "no_such_module")->tgid
}