OSDN Git Service

compiler: Remove old handling of unsafe.Pointer in type assertions.
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 23 Aug 2012 00:21:50 +0000 (00:21 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 23 Aug 2012 00:21:50 +0000 (00:21 +0000)
Fixes issue 17.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@190609 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/go/gofrontend/expressions.cc
libgo/go/os/dir.go

index a2ac987..728a2ac 100644 (file)
@@ -12923,26 +12923,8 @@ Type_guard_expression::do_traverse(Traverse* traverse)
 void
 Type_guard_expression::do_check_types(Gogo*)
 {
-  // 6g permits using a type guard with unsafe.pointer; we are
-  // compatible.
   Type* expr_type = this->expr_->type();
-  if (expr_type->is_unsafe_pointer_type())
-    {
-      if (this->type_->points_to() == NULL
-         && (this->type_->integer_type() == NULL
-             || (this->type_->forwarded()
-                 != Type::lookup_integer_type("uintptr"))))
-       this->report_error(_("invalid unsafe.Pointer conversion"));
-    }
-  else if (this->type_->is_unsafe_pointer_type())
-    {
-      if (expr_type->points_to() == NULL
-         && (expr_type->integer_type() == NULL
-             || (expr_type->forwarded()
-                 != Type::lookup_integer_type("uintptr"))))
-       this->report_error(_("invalid unsafe.Pointer conversion"));
-    }
-  else if (expr_type->interface_type() == NULL)
+  if (expr_type->interface_type() == NULL)
     {
       if (!expr_type->is_error() && !this->type_->is_error())
        this->report_error(_("type assertion only valid for interface types"));
@@ -12975,23 +12957,10 @@ Type_guard_expression::do_check_types(Gogo*)
 tree
 Type_guard_expression::do_get_tree(Translate_context* context)
 {
-  Gogo* gogo = context->gogo();
   tree expr_tree = this->expr_->get_tree(context);
   if (expr_tree == error_mark_node)
     return error_mark_node;
-  Type* expr_type = this->expr_->type();
-  if ((this->type_->is_unsafe_pointer_type()
-       && (expr_type->points_to() != NULL
-          || expr_type->integer_type() != NULL))
-      || (expr_type->is_unsafe_pointer_type()
-         && this->type_->points_to() != NULL))
-    return convert_to_pointer(type_to_tree(this->type_->get_backend(gogo)),
-                             expr_tree);
-  else if (expr_type->is_unsafe_pointer_type()
-          && this->type_->integer_type() != NULL)
-    return convert_to_integer(type_to_tree(this->type_->get_backend(gogo)),
-                             expr_tree);
-  else if (this->type_->interface_type() != NULL)
+  if (this->type_->interface_type() != NULL)
     return Expression::convert_interface_to_interface(context, this->type_,
                                                      this->expr_->type(),
                                                      expr_tree, true,
index 02b21e6..c77560f 100644 (file)
@@ -49,7 +49,7 @@ func (file *File) readdirnames(n int) (names []string, err error) {
                file.dirinfo.dir = r
        }
 
-       entry_dirent := unsafe.Pointer(&file.dirinfo.buf[0]).(*syscall.Dirent)
+       entry_dirent := (*syscall.Dirent)(unsafe.Pointer(&file.dirinfo.buf[0]))
 
        size := n
        if size < 0 {