From a8f3a62df168583299b417adf67abc55edd79f0f Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 21 Dec 2010 23:33:51 +0000 Subject: [PATCH] Don't permit assigning abstract string/bool to numeric variable. From-SVN: r168145 --- gcc/go/gofrontend/types.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc index 11a561dac2d5..8d4730ee423a 100644 --- a/gcc/go/gofrontend/types.cc +++ b/gcc/go/gofrontend/types.cc @@ -543,15 +543,17 @@ Type::are_assignable(const Type* lhs, const Type* rhs, std::string* reason) || lhs->interface_type() != NULL)) return true; - // An untyped constant may be assigned to a numeric type if it is - // representable in that type. - if (rhs->is_abstract() + // An untyped numeric constant may be assigned to a numeric type if + // it is representable in that type. + if ((rhs->is_abstract() + && (rhs->integer_type() != NULL + || rhs->float_type() != NULL + || rhs->complex_type() != NULL)) && (lhs->integer_type() != NULL || lhs->float_type() != NULL || lhs->complex_type() != NULL)) return true; - // Give some better error messages. if (reason != NULL && reason->empty()) { -- 2.47.2