Commit c40b69ae by Ian Lance Taylor

compiler: implement Go 1 unsafe.Pointer conversion rules

Any type whose underlying type is uintptr can be converted
to unsafe.Pointer, and vice versa.

Fixes golang/go#10284.

From-SVN: r221774
parent 233b9db6
...@@ -772,16 +772,16 @@ Type::are_convertible(const Type* lhs, const Type* rhs, std::string* reason) ...@@ -772,16 +772,16 @@ Type::are_convertible(const Type* lhs, const Type* rhs, std::string* reason)
} }
// An unsafe.Pointer type may be converted to any pointer type or to // An unsafe.Pointer type may be converted to any pointer type or to
// uintptr, and vice-versa. // a type whose underlying type is uintptr, and vice-versa.
if (lhs->is_unsafe_pointer_type() if (lhs->is_unsafe_pointer_type()
&& (rhs->points_to() != NULL && (rhs->points_to() != NULL
|| (rhs->integer_type() != NULL || (rhs->integer_type() != NULL
&& rhs->forwarded() == Type::lookup_integer_type("uintptr")))) && rhs->integer_type() == Type::lookup_integer_type("uintptr")->real_type())))
return true; return true;
if (rhs->is_unsafe_pointer_type() if (rhs->is_unsafe_pointer_type()
&& (lhs->points_to() != NULL && (lhs->points_to() != NULL
|| (lhs->integer_type() != NULL || (lhs->integer_type() != NULL
&& lhs->forwarded() == Type::lookup_integer_type("uintptr")))) && lhs->integer_type() == Type::lookup_integer_type("uintptr")->real_type())))
return true; return true;
// Give a better error message. // Give a better error message.
......
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