compiler: fix check for notinheap conversion
A normal pointer may not be converted to a notinheap pointer. We were
erroneously permitting a conversion from a normal pointer to a
notinheap unsafe.Pointer, which is useless since unsafe.Pointer is not
marked notinheap. Correct the test to permit a conversion from
unsafe.Pointer to a notinheap pointer, which is the same test that the
gc compiler uses.
The test case for this is in the 1.9 runtime package.
Change-Id: Ie86db54020ed977068969d53fa67568c3cca8d23
Reviewed-on: https://go-review.googlesource.com/62731
Reviewed-by: Than McIntosh <thanm@google.com>
diff --git a/go/types.cc b/go/types.cc
index cde1408..cdf1f40 100644
--- a/go/types.cc
+++ b/go/types.cc
@@ -747,16 +747,16 @@
return true;
// A pointer to a regular type may not be converted to a pointer to
- // a type that may not live in the heap, except when converting to
+ // a type that may not live in the heap, except when converting from
// unsafe.Pointer.
if (lhs->points_to() != NULL
&& rhs->points_to() != NULL
- && !rhs->points_to()->in_heap()
- && lhs->points_to()->in_heap()
- && !lhs->is_unsafe_pointer_type())
+ && !lhs->points_to()->in_heap()
+ && rhs->points_to()->in_heap()
+ && !rhs->is_unsafe_pointer_type())
{
if (reason != NULL)
- reason->assign(_("conversion from notinheap type to normal type"));
+ reason->assign(_("conversion from normal type to notinheap type"));
return false;
}