diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2010-12-21 23:33:51 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2010-12-21 23:33:51 +0000 |
commit | a8f3a62df168583299b417adf67abc55edd79f0f (patch) | |
tree | 8d2a7a0645782e55683e6000e9a664f47ae9d31e | |
parent | 67eff3d9f72b4ae733dd519331f90757d48f0590 (diff) | |
download | gcc-a8f3a62df168583299b417adf67abc55edd79f0f.zip gcc-a8f3a62df168583299b417adf67abc55edd79f0f.tar.gz gcc-a8f3a62df168583299b417adf67abc55edd79f0f.tar.bz2 |
Don't permit assigning abstract string/bool to numeric variable.
From-SVN: r168145
-rw-r--r-- | gcc/go/gofrontend/types.cc | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc index 11a561d..8d4730e 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()) { |