diff options
author | Ian Lance Taylor <iant@golang.org> | 2020-07-10 13:43:09 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2020-07-11 12:41:28 -0700 |
commit | e109f6e438b72ef3e403162971068d28d09b82f5 (patch) | |
tree | 8ead189e618f8ef1456c8b02c81de0cc1585d8a6 /gcc | |
parent | e7d6d8f9f7b687c8e7438523d7d6f7a539ec7287 (diff) | |
download | gcc-e109f6e438b72ef3e403162971068d28d09b82f5.zip gcc-e109f6e438b72ef3e403162971068d28d09b82f5.tar.gz gcc-e109f6e438b72ef3e403162971068d28d09b82f5.tar.bz2 |
compiler: avoid generating unnamed bool type descriptor
We were generating it in cases where a boolean expression was
converted directly to an empty interface type.
Fixes golang/go#40152
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/242002
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/go/gofrontend/MERGE | 2 | ||||
-rw-r--r-- | gcc/go/gofrontend/expressions.cc | 5 | ||||
-rw-r--r-- | gcc/go/gofrontend/gogo.cc | 6 | ||||
-rw-r--r-- | gcc/go/gofrontend/names.cc | 9 |
4 files changed, 15 insertions, 7 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index c65fd8e..7bec9a8 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -ce70fa16a73e3f162de01deab6b5d17783e6b76b +9703ad5fa23ca63062cb403bd12bc7da4d7845bd The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index deac874..327f940 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -6041,10 +6041,7 @@ Binary_expression::do_lower(Gogo* gogo, Named_object*, &right_nc, location, &result)) return this; - return Expression::make_cast(Type::make_boolean_type(), - Expression::make_boolean(result, - location), - location); + return Expression::make_boolean(result, location); } else { diff --git a/gcc/go/gofrontend/gogo.cc b/gcc/go/gofrontend/gogo.cc index 212ef45..c1021e5 100644 --- a/gcc/go/gofrontend/gogo.cc +++ b/gcc/go/gofrontend/gogo.cc @@ -3309,7 +3309,11 @@ Remove_deadcode::expression(Expression** pexpr) && be->boolean_constant_value(&bval) && (be->op() == OPERATOR_ANDAND || be->op() == OPERATOR_OROR)) - *pexpr = Expression::make_boolean(bval, be->location()); + { + *pexpr = Expression::make_boolean(bval, be->location()); + Type_context context(NULL, false); + (*pexpr)->determine_type(&context); + } return TRAVERSE_CONTINUE; } diff --git a/gcc/go/gofrontend/names.cc b/gcc/go/gofrontend/names.cc index a721a36..1f0a545 100644 --- a/gcc/go/gofrontend/names.cc +++ b/gcc/go/gofrontend/names.cc @@ -975,7 +975,14 @@ Gogo::type_descriptor_name(const Type* type, Named_type* nt) return "unsafe.Pointer..d"; if (nt == NULL) - return "type.." + type->mangled_name(this); + { + // Sanity check: we should never generate a type descriptor for + // an unnamed primitive type. For those we should always be + // using a named type, like "int". + go_assert(!type->is_basic_type()); + + return "type.." + type->mangled_name(this); + } std::string ret; Named_object* no = nt->named_object(); |