]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Don't permit assigning abstract string/bool to numeric variable.
authorIan Lance Taylor <ian@gcc.gnu.org>
Tue, 21 Dec 2010 23:33:51 +0000 (23:33 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Tue, 21 Dec 2010 23:33:51 +0000 (23:33 +0000)
From-SVN: r168145

gcc/go/gofrontend/types.cc

index 11a561dac2d51e0892a4e9f3cd99d31b6ba0aa1d..8d4730ee423a54d68c60c9740c14ef865027fd83 100644 (file)
@@ -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())
     {