Better error when setting const to nil.
authorIan Lance Taylor <ian@gcc.gnu.org>
Sat, 26 Mar 2011 05:45:31 +0000 (05:45 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Sat, 26 Mar 2011 05:45:31 +0000 (05:45 +0000)
From-SVN: r171541

gcc/go/gofrontend/gogo.cc

index a09ffb3aaec95529a9574c598ef9d10fb69bbce9..9001d2b9ea7becaf7fd4cfb06701cccd7325f545 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();
     }