From 964c809fb28f2bbb5b7c35d7951911abff242b94 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Mon, 5 Feb 2018 01:50:22 +0000 Subject: compiler: in range, evaluate array if it has receives or calls The last change was incomplete, in that it did not evaluate the array argument in some cases where it had to be evaluated. This reuses the existing code for checking whether len/cap is constant. Also clean up the use of _ as the second variable in a for/range, which was previously inconsistent depending on whether the statement used = or :=. Updates golang/go#22313 Reviewed-on: https://go-review.googlesource.com/91715 From-SVN: r257377 --- gcc/go/gofrontend/expressions.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gcc/go/gofrontend/expressions.h') diff --git a/gcc/go/gofrontend/expressions.h b/gcc/go/gofrontend/expressions.h index 6b00cab..18fd91b 100644 --- a/gcc/go/gofrontend/expressions.h +++ b/gcc/go/gofrontend/expressions.h @@ -2406,6 +2406,11 @@ class Builtin_call_expression : public Call_expression is_builtin() { return true; } + // Return whether EXPR, of array type, is a constant if passed to + // len or cap. + static bool + array_len_is_constant(Expression* expr); + protected: // This overrides Call_expression::do_lower. Expression* -- cgit v1.1