From 2fbb4d751b0fc9ce11632570f71e267420d36384 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Sat, 26 Mar 2011 05:45:31 +0000 Subject: [PATCH] Better error when setting const to nil. From-SVN: r171541 --- gcc/go/gofrontend/gogo.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gcc/go/gofrontend/gogo.cc b/gcc/go/gofrontend/gogo.cc index a09ffb3aaec..9001d2b9ea7 100644 --- a/gcc/go/gofrontend/gogo.cc +++ b/gcc/go/gofrontend/gogo.cc @@ -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(); } -- 2.30.2