From f1b6e17b3f753980527721aa8e949d2481b2560b Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Sat, 5 Dec 2020 21:16:13 -0800 Subject: compiler: use correct location for iota errors Also check for valid array length when reducing len/cap to a constant. For golang/go#8183 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/275654 --- gcc/go/gofrontend/parse.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'gcc/go/gofrontend/parse.cc') diff --git a/gcc/go/gofrontend/parse.cc b/gcc/go/gofrontend/parse.cc index b1925ed..a4740cf 100644 --- a/gcc/go/gofrontend/parse.cc +++ b/gcc/go/gofrontend/parse.cc @@ -1442,6 +1442,7 @@ Parse::const_decl() void Parse::const_spec(int iota, Type** last_type, Expression_list** last_expr_list) { + Location loc = this->location(); Typed_identifier_list til; this->identifier_list(&til); @@ -1466,7 +1467,11 @@ Parse::const_spec(int iota, Type** last_type, Expression_list** last_expr_list) for (Expression_list::const_iterator p = (*last_expr_list)->begin(); p != (*last_expr_list)->end(); ++p) - expr_list->push_back((*p)->copy()); + { + Expression* copy = (*p)->copy(); + copy->set_location(loc); + expr_list->push_back(copy); + } } else { -- cgit v1.1