diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-10-10 03:51:11 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-10-10 03:51:11 +0000 |
commit | 1b10c5e747c2fede997fa6b84dfebf8ea7ab5763 (patch) | |
tree | 5df145f25fbc3fe02363eec28c63aadb42997c48 /gcc/go | |
parent | 02ffd97fe94b59b1fbf531f80476c1c53b6fcea3 (diff) | |
download | gcc-1b10c5e747c2fede997fa6b84dfebf8ea7ab5763.tar.gz |
compiler: Fix test for constant argument too large for make.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@203338 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/go')
-rw-r--r-- | gcc/go/gofrontend/expressions.cc | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 8b53331d073..0647a505800 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -7542,7 +7542,7 @@ Builtin_call_expression::check_int_value(Expression* e, bool is_length) switch (nc.to_unsigned_long(&v)) { case Numeric_constant::NC_UL_VALID: - return true; + break; case Numeric_constant::NC_UL_NOTINT: error_at(e->location(), "non-integer %s argument to make", is_length ? "len" : "cap"); @@ -7554,8 +7554,23 @@ Builtin_call_expression::check_int_value(Expression* e, bool is_length) case Numeric_constant::NC_UL_BIG: // We don't want to give a compile-time error for a 64-bit // value on a 32-bit target. - return true; + break; + } + + mpz_t val; + if (!nc.to_int(&val)) + go_unreachable(); + int bits = mpz_sizeinbase(val, 2); + mpz_clear(val); + Type* int_type = Type::lookup_integer_type("int"); + if (bits >= int_type->integer_type()->bits()) + { + error_at(e->location(), "%s argument too large for make", + is_length ? "len" : "cap"); + return false; } + + return true; } if (e->type()->integer_type() != NULL) |