From 29a2d1d882d48402827e0cbe85b819c828921d09 Mon Sep 17 00:00:00 2001 From: ian Date: Fri, 20 Apr 2012 19:21:39 +0000 Subject: compiler, runtime: Add explicit checks for zero and overflow division. * lang.opt: Add -fgo-check-divide-zero and -fgo-check-divide-overflow. * gccgo.texi (Invoking gccgo): Document new options. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@186637 138bc75d-0d04-0410-961f-82ee72b054a4 --- libgo/runtime/go-runtime-error.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'libgo') diff --git a/libgo/runtime/go-runtime-error.c b/libgo/runtime/go-runtime-error.c index f732e7f017f..68db8acd8b1 100644 --- a/libgo/runtime/go-runtime-error.c +++ b/libgo/runtime/go-runtime-error.c @@ -46,7 +46,10 @@ enum MAKE_MAP_OUT_OF_BOUNDS = 8, /* Channel capacity out of bounds in make: negative or overflow. */ - MAKE_CHAN_OUT_OF_BOUNDS = 9 + MAKE_CHAN_OUT_OF_BOUNDS = 9, + + /* Integer division by zero. */ + DIVISION_BY_ZERO = 10 }; extern void __go_runtime_error () __attribute__ ((noreturn)); @@ -78,6 +81,9 @@ __go_runtime_error (int i) case MAKE_CHAN_OUT_OF_BOUNDS: runtime_panicstring ("make chan len out of range"); + case DIVISION_BY_ZERO: + runtime_panicstring ("integer divide by zero"); + default: runtime_panicstring ("unknown runtime error"); } -- cgit v1.2.1