OSDN Git Service

Improve error about indirecting an unsafe.Pointer type.
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 27 Mar 2011 16:40:24 +0000 (16:40 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 27 Mar 2011 16:40:24 +0000 (16:40 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@171574 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/go/gofrontend/expressions.cc

index f1a2ec7..3a60051 100644 (file)
@@ -3669,6 +3669,14 @@ Unary_expression::do_lower(Gogo*, Named_object*, int)
        }
     }
 
+  // Catching an invalid indirection of unsafe.Pointer here avoid
+  // having to deal with TYPE_VOID in other places.
+  if (op == OPERATOR_MULT && expr->type()->is_unsafe_pointer_type())
+    {
+      error_at(this->location(), "invalid indirect of %<unsafe.Pointer%>");
+      return Expression::make_error(this->location());
+    }
+
   if (op == OPERATOR_PLUS || op == OPERATOR_MINUS
       || op == OPERATOR_NOT || op == OPERATOR_XOR)
     {