std::unique_ptr<Expr> &get_lhs () { return main_or_left_expr; }
std::unique_ptr<Expr> &get_rhs () { return right_expr; }
+ std::string get_operator_str () const;
+
protected:
/* Use covariance to implement clone function as returning this object rather
* than base */
void visit_lhs (HIRFullVisitor &vis) { main_or_left_expr->accept_vis (vis); }
void visit_rhs (HIRFullVisitor &vis) { right_expr->accept_vis (vis); }
+ std::string get_operator_str () const;
+
protected:
/* Use covariance to implement clone function as returning this object rather
* than base */
}
std::string
-CompoundAssignmentExpr::as_string () const
+CompoundAssignmentExpr::get_operator_str () const
{
std::string operator_str;
operator_str.reserve (1);
operator_str += "=";
+ return operator_str;
+}
+
+std::string
+CompoundAssignmentExpr::as_string () const
+{
std::string str ("CompoundAssignmentExpr: ");
+ std::string operator_str = get_operator_str ();
if (main_or_left_expr == nullptr || right_expr == nullptr)
{
str += "error. this is probably a parsing failure.";
}
std::string
-ArithmeticOrLogicalExpr::as_string () const
+ArithmeticOrLogicalExpr::get_operator_str () const
{
std::string operator_str;
operator_str.reserve (1);
break;
}
+ return operator_str;
+}
+
+std::string
+ArithmeticOrLogicalExpr::as_string () const
+{
std::string str = main_or_left_expr->as_string () + " ";
- str += operator_str + " ";
+ str += get_operator_str () + " ";
str += right_expr->as_string ();
return "( " + str + " (" + get_mappings ().as_string () + "))";
if (!valid)
{
rust_error_at (expr.get_locus (),
- "cannot apply this operator to types %s and %s",
+ "cannot apply operator %qs to types %s and %s",
+ expr.get_operator_str ().c_str (),
lhs->as_string ().c_str (), rhs->as_string ().c_str ());
return;
}
if (!valid)
{
rust_error_at (expr.get_locus (),
- "cannot apply this operator to types %s and %s",
+ "cannot apply operator %qs to types %s and %s",
+ expr.get_operator_str ().c_str (),
lhs->as_string ().c_str (), rhs->as_string ().c_str ());
return;
}
let mut x = 5;
let mut x;
x = true;
- x = x + 2; // { dg-error "cannot apply this operator to types bool and <integer>" }
+ x = x + 2; // { dg-error "cannot apply operator .+. to types bool and <integer>" }
}