summaryrefslogtreecommitdiff
path: root/gcc/go/gofrontend/expressions.cc
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2012-12-04 05:17:54 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2012-12-04 05:17:54 +0000
commit4f2138d7c4a565dd82d92953535d07742feeb993 (patch)
treefc45f7b721523284e00758f9174c0e8d2878b20d /gcc/go/gofrontend/expressions.cc
parent55dcfde90c2dc80a5832596aef876844b876f3dd (diff)
downloadgcc-4f2138d7c4a565dd82d92953535d07742feeb993.tar.gz
compiler: Fix crash in go/defer of some builtin functions.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@194114 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/go/gofrontend/expressions.cc')
-rw-r--r--gcc/go/gofrontend/expressions.cc30
1 files changed, 17 insertions, 13 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc
index a2a76d9ce30..bfc1b625d71 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -80,10 +80,11 @@ Expression::do_traverse(Traverse*)
// expression is being discarded. By default, we give an error.
// Expressions with side effects override.
-void
+bool
Expression::do_discarding_value()
{
this->unused_value_error();
+ return false;
}
// This virtual function is called to export expressions. This will
@@ -100,7 +101,7 @@ Expression::do_export(Export*) const
void
Expression::unused_value_error()
{
- error_at(this->location(), "value computed is not used");
+ this->report_error(_("value computed is not used"));
}
// Note that this expression is an error. This is called by children
@@ -786,9 +787,9 @@ class Error_expression : public Expression
return true;
}
- void
+ bool
do_discarding_value()
- { }
+ { return true; }
Type*
do_type()
@@ -1149,9 +1150,9 @@ class Sink_expression : public Expression
{ }
protected:
- void
+ bool
do_discarding_value()
- { }
+ { return true; }
Type*
do_type();
@@ -5326,13 +5327,16 @@ Binary_expression::do_numeric_constant_value(Numeric_constant* nc) const
// Note that the value is being discarded.
-void
+bool
Binary_expression::do_discarding_value()
{
if (this->op_ == OPERATOR_OROR || this->op_ == OPERATOR_ANDAND)
- this->right_->discarding_value();
+ return this->right_->discarding_value();
else
- this->unused_value_error();
+ {
+ this->unused_value_error();
+ return false;
+ }
}
// Get type.
@@ -6536,7 +6540,7 @@ class Builtin_call_expression : public Call_expression
bool
do_numeric_constant_value(Numeric_constant*) const;
- void
+ bool
do_discarding_value();
Type*
@@ -7338,7 +7342,7 @@ Builtin_call_expression::do_numeric_constant_value(Numeric_constant* nc) const
// discarding the value of an ordinary function call, but we do for
// builtin functions, purely for consistency with the gc compiler.
-void
+bool
Builtin_call_expression::do_discarding_value()
{
switch (this->code_)
@@ -7359,7 +7363,7 @@ Builtin_call_expression::do_discarding_value()
case BUILTIN_OFFSETOF:
case BUILTIN_SIZEOF:
this->unused_value_error();
- break;
+ return false;
case BUILTIN_CLOSE:
case BUILTIN_COPY:
@@ -7368,7 +7372,7 @@ Builtin_call_expression::do_discarding_value()
case BUILTIN_PRINT:
case BUILTIN_PRINTLN:
case BUILTIN_RECOVER:
- break;
+ return true;
}
}