aboutsummaryrefslogtreecommitdiff
path: root/gcc/go
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2013-10-11 18:10:03 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2013-10-11 18:10:03 +0000
commitd621811443516a0133fb6999c3b3e610773c1743 (patch)
tree37de7994f2baba0aee367724e2f65b9c3daf0892 /gcc/go
parent0213a547b0ec72dbd0ea3e98181c9ebc20275a92 (diff)
downloadgcc-d621811443516a0133fb6999c3b3e610773c1743.zip
gcc-d621811443516a0133fb6999c3b3e610773c1743.tar.gz
gcc-d621811443516a0133fb6999c3b3e610773c1743.tar.bz2
compiler: Better error message of unsafe.Offsetof(method value).
From-SVN: r203454
Diffstat (limited to 'gcc/go')
-rw-r--r--gcc/go/gofrontend/expressions.cc14
1 files changed, 13 insertions, 1 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc
index 06c3429..258953f 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -7253,6 +7253,15 @@ Builtin_call_expression::do_lower(Gogo* gogo, Named_object* function,
if (this->code_ == BUILTIN_OFFSETOF)
{
Expression* arg = this->one_arg();
+
+ if (arg->bound_method_expression() != NULL
+ || arg->interface_field_reference_expression() != NULL)
+ {
+ this->report_error(_("invalid use of method value as argument "
+ "of Offsetof"));
+ return this;
+ }
+
Field_reference_expression* farg = arg->field_reference_expression();
while (farg != NULL)
{
@@ -7262,7 +7271,8 @@ Builtin_call_expression::do_lower(Gogo* gogo, Named_object* function,
// it must not be reached through pointer indirections.
if (farg->expr()->deref() != farg->expr())
{
- this->report_error(_("argument of Offsetof implies indirection of an embedded field"));
+ this->report_error(_("argument of Offsetof implies "
+ "indirection of an embedded field"));
return this;
}
// Go up until we reach the original base.
@@ -7672,6 +7682,8 @@ Find_call_expression::expression(Expression** pexpr)
bool
Builtin_call_expression::do_is_constant() const
{
+ if (this->is_error_expression())
+ return true;
switch (this->code_)
{
case BUILTIN_LEN: