diff options
author | Roger Sayle <roger@eyesopen.com> | 2003-05-31 13:23:32 +0000 |
---|---|---|
committer | Roger Sayle <sayle@gcc.gnu.org> | 2003-05-31 13:23:32 +0000 |
commit | 4fa26a60791ec314128a9683fd4d657b251d0268 (patch) | |
tree | ae8dcbb261aaadbfa874d60f1fccd8dd93248b50 /gcc/toplev.c | |
parent | 82a2669ea738ba4bec4112408a16082e7356e7e1 (diff) | |
download | gcc-4fa26a60791ec314128a9683fd4d657b251d0268.zip gcc-4fa26a60791ec314128a9683fd4d657b251d0268.tar.gz gcc-4fa26a60791ec314128a9683fd4d657b251d0268.tar.bz2 |
flags.h (flag_wrapv): New flag controlling overflow semantics.
* flags.h (flag_wrapv): New flag controlling overflow semantics.
* toplev.c (flag_wrapv): Declare the variable with default false.
(lang_independent_options): New option "-fwrapv" to set the above.
* fold-const.c (extract_muldiv_1): Disable optimization of (2*x)/2
as x, when signed arithmetic overflow wraps around.
(fold): Optimize "-A - B" as "-B - A" if overflow wraps around.
* loop.c (basic_induction_var): Ignore BIVs that rely on undefined
overflow when flag_wrapv is true.
* java/lang.c (java_init_options): Prescribe wrap-around two's
complement arithmetic overflow by setting flag_wrapv.
* doc/invoke.texi: Document new -fwrapv command line option.
* doc/c-tree.texi: Mention that the overflow semantics of
NEGATE_EXPR, PLUS_EXPR, MINUS_EXPR and MULT_EXPR is dependent
upon both flag_wrapv and flag_trapv.
* gcc.dg/fwrapv-1.c: New test case.
* gcc.dg/fwrapv-2.c: New test case.
* libjava.lang/Overflow.java: New test.
* libjava.lang/Overflow.out: New file.
From-SVN: r67270
Diffstat (limited to 'gcc/toplev.c')
-rw-r--r-- | gcc/toplev.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/gcc/toplev.c b/gcc/toplev.c index 7cfb29e..f2c352f 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -977,8 +977,12 @@ typedef struct } lang_independent_options; +/* Nonzero if signed arithmetic overflow should trap. */ int flag_trapv = 0; +/* Nonzero if signed arithmetic overflow should wrap around. */ +int flag_wrapv = 0; + /* Add or remove a leading underscore from user symbols. */ int flag_leading_underscore = -1; @@ -1220,6 +1224,8 @@ static const lang_independent_options f_options[] = N_("Report on permanent memory allocation at end of run") }, { "trapv", &flag_trapv, 1, N_("Trap for signed overflow in addition / subtraction / multiplication") }, + { "wrapv", &flag_wrapv, 1, + N_("Assume signed arithmetic overflow wraps around") }, { "new-ra", &flag_new_regalloc, 1, N_("Use graph coloring register allocation.") }, }; |