diff options
author | Joseph Myers <joseph@codesourcery.com> | 2013-12-10 01:23:37 +0000 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2013-12-10 01:23:37 +0000 |
commit | 3a4efce7c246b190ef35a8ce1f108f572274521f (patch) | |
tree | 17fee4f3cb77d383b7ed61dc4891d6ab12174ac5 /gcc/testsuite/gcc.dg/cpp/expr-overflow-1.c | |
parent | e73d2479dd03132a1147c013426ea8e88c10d2ff (diff) | |
download | gcc-3a4efce7c246b190ef35a8ce1f108f572274521f.zip gcc-3a4efce7c246b190ef35a8ce1f108f572274521f.tar.gz gcc-3a4efce7c246b190ef35a8ce1f108f572274521f.tar.bz2 |
re PR preprocessor/55715 (bogus overflow warning for #if A-B when A<0 & B==minimum integer)
PR preprocessor/55715
libcpp:
* expr.c (num_binary_op): Implement subtraction directly rather
than with negation and falling through into addition case.
gcc/testsuite:
* gcc.dg/cpp/expr-overflow-1.c: New test.
From-SVN: r205846
Diffstat (limited to 'gcc/testsuite/gcc.dg/cpp/expr-overflow-1.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/cpp/expr-overflow-1.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/cpp/expr-overflow-1.c b/gcc/testsuite/gcc.dg/cpp/expr-overflow-1.c new file mode 100644 index 0000000..8a67aaa --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/expr-overflow-1.c @@ -0,0 +1,44 @@ +/* Test overflow in preprocessor arithmetic. PR 55715. */ +/* { dg-do preprocess } */ +/* { dg-options "-std=c99" } */ + +#include <stdint.h> + +#if -1 - INTMAX_MIN +#endif + +#if 0 - INTMAX_MIN /* { dg-warning "overflow" } */ +#endif + +#if 1 * INTMAX_MIN +#endif + +#if -1 * INTMAX_MIN /* { dg-warning "overflow" } */ +#endif + +#if 0 * INTMAX_MIN +#endif + +#if -INTMAX_MIN /* { dg-warning "overflow" } */ +#endif + +#if +INTMAX_MIN +#endif + +#if INTMAX_MIN / 1 +#endif + +#if INTMAX_MIN / -1 /* { dg-warning "overflow" } */ +#endif + +#if UINTMAX_MAX * UINTMAX_MAX +#endif + +#if UINTMAX_MAX / -1 +#endif + +#if UINTMAX_MAX + INTMAX_MAX +#endif + +#if UINTMAX_MAX - INTMAX_MIN +#endif |