From: Ian Lance Taylor Date: Tue, 21 Dec 2010 23:33:51 +0000 (+0000) Subject: Don't permit assigning abstract string/bool to numeric variable. X-Git-Tag: releases/gcc-4.6.0~1687 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a8f3a62df168583299b417adf67abc55edd79f0f;p=thirdparty%2Fgcc.git Don't permit assigning abstract string/bool to numeric variable. From-SVN: r168145 --- 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()) {