aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2014-08-29 03:06:15 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2014-08-29 03:06:15 +0000
commit6c23308e70c4323d4c99e27e0896f4eb33f69714 (patch)
tree11f470026475e1fc32934ad05b20faf40f2d6a3e /gcc
parentbbbf5d5ab47a1632a3de692a451409ca201a4985 (diff)
downloadgcc-6c23308e70c4323d4c99e27e0896f4eb33f69714.zip
gcc-6c23308e70c4323d4c99e27e0896f4eb33f69714.tar.gz
gcc-6c23308e70c4323d4c99e27e0896f4eb33f69714.tar.bz2
compiler: Fix comparison of struct/array with interface.
The compiler used to crash when the struct/array was not addressable. The test case is https://codereview.appspot.com/135170043 . This fixes http://golang.org/issue/8612 . From-SVN: r214713
Diffstat (limited to 'gcc')
-rw-r--r--gcc/go/gofrontend/expressions.cc7
1 files changed, 5 insertions, 2 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc
index f7a3c57..6414136 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -5187,10 +5187,13 @@ Binary_expression::do_lower(Gogo* gogo, Named_object*,
// Lower struct, array, and some interface comparisons.
if (op == OPERATOR_EQEQ || op == OPERATOR_NOTEQ)
{
- if (left->type()->struct_type() != NULL)
+ if (left->type()->struct_type() != NULL
+ && right->type()->struct_type() != NULL)
return this->lower_struct_comparison(gogo, inserter);
else if (left->type()->array_type() != NULL
- && !left->type()->is_slice_type())
+ && !left->type()->is_slice_type()
+ && right->type()->array_type() != NULL
+ && !right->type()->is_slice_type())
return this->lower_array_comparison(gogo, inserter);
else if ((left->type()->interface_type() != NULL
&& right->type()->interface_type() == NULL)