OSDN Git Service

Better error when setting const to nil.
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 26 Mar 2011 05:45:31 +0000 (05:45 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 26 Mar 2011 05:45:31 +0000 (05:45 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@171541 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/go/gofrontend/gogo.cc

index a09ffb3..9001d2b 100644 (file)
@@ -1527,7 +1527,9 @@ Check_types_traverse::constant(Named_object* named_object, bool)
       && !ctype->is_boolean_type()
       && !ctype->is_string_type())
     {
-      if (!ctype->is_error())
+      if (ctype->is_nil_type())
+       error_at(constant->location(), "const initializer cannot be nil");
+      else if (!ctype->is_error())
        error_at(constant->location(), "invalid constant type");
       constant->set_error();
     }