diff options
author | Ian Lance Taylor <iant@google.com> | 2012-04-20 19:21:39 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-04-20 19:21:39 +0000 |
commit | 63d1e46df06893b073418be4e27f95eebd05ba26 (patch) | |
tree | c10e54920198d7e76b320d82626dc392302ee553 /libgo | |
parent | 0e27a180fd0f9270bcfacec0b4940283eaf6eb61 (diff) | |
download | gcc-63d1e46df06893b073418be4e27f95eebd05ba26.zip gcc-63d1e46df06893b073418be4e27f95eebd05ba26.tar.gz gcc-63d1e46df06893b073418be4e27f95eebd05ba26.tar.bz2 |
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.
From-SVN: r186637
Diffstat (limited to 'libgo')
-rw-r--r-- | libgo/runtime/go-runtime-error.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/libgo/runtime/go-runtime-error.c b/libgo/runtime/go-runtime-error.c index f732e7f..68db8ac 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"); } |