aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2010-12-14 23:45:50 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2010-12-14 23:45:50 +0000
commit10a0275d927e16d006d9e93e03a63ec949a7afc8 (patch)
tree6797210640946af34709454dbe25ca7c13072b67
parent002d4675481348987b4f7191e61e12e4e7ac9b4e (diff)
downloadgcc-10a0275d927e16d006d9e93e03a63ec949a7afc8.zip
gcc-10a0275d927e16d006d9e93e03a63ec949a7afc8.tar.gz
gcc-10a0275d927e16d006d9e93e03a63ec949a7afc8.tar.bz2
Fix comparison of string and interface types.
From-SVN: r167826
-rw-r--r--gcc/go/gofrontend/expressions.cc16
1 files changed, 7 insertions, 9 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc
index 7041cb5..2a8d802 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -5938,9 +5938,8 @@ Expression::comparison_tree(Translate_context* context, Operator op,
gcc_unreachable();
}
- if (left_type->is_string_type())
+ if (left_type->is_string_type() && right_type->is_string_type())
{
- gcc_assert(right_type->is_string_type());
tree string_type = Type::make_string_type()->get_tree(context->gogo());
static tree string_compare_decl;
left_tree = Gogo::call_builtin(&string_compare_decl,
@@ -5954,13 +5953,12 @@ Expression::comparison_tree(Translate_context* context, Operator op,
right_tree);
right_tree = build_int_cst_type(integer_type_node, 0);
}
-
- if ((left_type->interface_type() != NULL
- && right_type->interface_type() == NULL
- && !right_type->is_nil_type())
- || (left_type->interface_type() == NULL
- && !left_type->is_nil_type()
- && right_type->interface_type() != NULL))
+ else if ((left_type->interface_type() != NULL
+ && right_type->interface_type() == NULL
+ && !right_type->is_nil_type())
+ || (left_type->interface_type() == NULL
+ && !left_type->is_nil_type()
+ && right_type->interface_type() != NULL))
{
// Comparing an interface value to a non-interface value.
if (left_type->interface_type() == NULL)