Commit a8f3a62d by Ian Lance Taylor

Don't permit assigning abstract string/bool to numeric variable.

From-SVN: r168145
parent 67eff3d9
...@@ -543,15 +543,17 @@ Type::are_assignable(const Type* lhs, const Type* rhs, std::string* reason) ...@@ -543,15 +543,17 @@ Type::are_assignable(const Type* lhs, const Type* rhs, std::string* reason)
|| lhs->interface_type() != NULL)) || lhs->interface_type() != NULL))
return true; return true;
// An untyped constant may be assigned to a numeric type if it is // An untyped numeric constant may be assigned to a numeric type if
// representable in that type. // it is representable in that type.
if (rhs->is_abstract() if ((rhs->is_abstract()
&& (rhs->integer_type() != NULL
|| rhs->float_type() != NULL
|| rhs->complex_type() != NULL))
&& (lhs->integer_type() != NULL && (lhs->integer_type() != NULL
|| lhs->float_type() != NULL || lhs->float_type() != NULL
|| lhs->complex_type() != NULL)) || lhs->complex_type() != NULL))
return true; return true;
// Give some better error messages. // Give some better error messages.
if (reason != NULL && reason->empty()) if (reason != NULL && reason->empty())
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment