diff options
author | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-05-26 18:42:21 +0000 |
---|---|---|
committer | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-05-26 18:42:21 +0000 |
commit | b444d47a3eb7c70492702b498da24bdcdee18148 (patch) | |
tree | e0b28595be44974817fef680c5e031a4b195ef68 /gcc/testsuite/gcc.dg/cpp | |
parent | 235d7594b104d4c89bd12bdfa44efbe50d7a5ff2 (diff) | |
download | gcc-b444d47a3eb7c70492702b498da24bdcdee18148.tar.gz |
* cppexp.c (possible_sum_sign, integer_overflow, left_shift,
right_shift): Remove.
(cpp_num, cpp_num_part, PART_PRECISION, HALF_MASK, LOW_PART,
HIGH_PART): New.
(struct op): Use cpp_num.
(num_zerop, num_eq, num_positive, num_greater_freq, num_trim,
num_part_mul, num_unary_op, num_binary_op, num_negate,
num_bitwise_op, num_inequality_op, num_equality_op, num_mul,
num_div_op, num_lshift, num_rshift, append_digit): New.
(interpret_number, parse_defined, eval_token, reduce): Update
for two-integer arithmetic.
(binary_handler): New typedef.
(optab): Update.
(COMPARE, EQUALITY, BITWISE, MINMAX, UNARY, SHIFT): Delete.
(_cpp_parse_expr, reduce): Update to handle two-integers.
* cpplib.c (_cpp_test_assertion): Back up on CPP_EOF.
testsuite:
* gcc.dg/cpp/arith-1.c: New semantic tests.
* gcc.dg/cpp/if-1.c: Update.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@53900 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.dg/cpp')
-rw-r--r-- | gcc/testsuite/gcc.dg/cpp/arith-1.c | 257 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/cpp/if-1.c | 2 |
2 files changed, 258 insertions, 1 deletions
diff --git a/gcc/testsuite/gcc.dg/cpp/arith-1.c b/gcc/testsuite/gcc.dg/cpp/arith-1.c new file mode 100644 index 00000000000..85d5848d800 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/arith-1.c @@ -0,0 +1,257 @@ +/* Preprocessor arithmetic semantic tests. */ + +/* Copyright (C) 2002 Free Software Foundation, Inc. */ +/* Source: Neil Booth, 25 May 2002. */ + +/* The file tests all aspects of preprocessor arithmetic that are + independent of target precision. */ + +/* { dg-do preprocess } */ +/* { dg-options -fno-show-column } */ + +/* Test || operator and its short circuiting. */ +#if 0 || 0 +# error /* { dg-bogus "error" } */ +#endif + +#if 5 || 0 +#else +# error /* { dg-bogus "error" } */ +#endif + +#if 0 || 1 +#else +# error /* { dg-bogus "error" } */ +#endif + +#if 1 || 4 +#else +# error /* { dg-bogus "error" } */ +#endif + +#if 1 || (8 / 0) /* { dg-bogus "division by zero" } */ +#else +# error /* { dg-bogus "error" } */ +#endif + +#if 1 || (1 << 256) /* { dg-bogus "overflow" } */ +#endif + +/* Test && operator and its short circuiting. */ +#if (0 && 0) || (0 && 1) || (1 && 0) +# error /* { dg-bogus "error" } */ +#endif + +#if 1 && 2 +#else +# error /* { dg-bogus "error" } */ +#endif + +#if 0 && (8 / 0)/* { dg-bogus "division by zero" } */ +# error /* { dg-bogus "error" } */ +#endif + +#if 0 && (1 << 256) /* { dg-bogus "overflow" } */ +#endif + +/* Test == and != operators, and their signedness. */ +#if 1 == 0 || 0 == 1 || 20 != 0x014 || 142 != 0216 +# error /* { dg-bogus "error" } */ +#endif + +#if (1 == 1) - 2 > 0 || (1U != 1U) - 2 > 0 +# error /* { dg-bogus "error" } */ +#endif + +/* Test ? : operator, its short circuiting, and its signedness. */ +#if (1 ? 3: 5) != 3 || (0 ? 3: 5) != 5 +# error /* { dg-bogus "error" } */ +#endif + +#if 1 ? 0: 1 / 0 /* { dg-bogus "division by zero" } */ +# error /* { dg-bogus "error" } */ +#endif + +#if 0 ? 1 / 0: 0 /* { dg-bogus "division by zero" } */ +# error /* { dg-bogus "error" } */ +#endif + +#if 0 ? (1 << 256): 0 /* { dg-bogus "overflow" } */ +#endif + +#if 1 ? 0: (1 << 256) /* { dg-bogus "overflow" } */ +#endif + +/* Test unary + and its signedness. */ + +#if 23 != +23 || 23 != + +23 +# error /* { dg-bogus "error" } */ +#endif + +#if (+1 - 2) > 0 || (+1U - 2) < 0 +# error /* { dg-bogus "error" } */ +#endif + +/* Test unary - and its signedness. */ + +#if -1 + 1 != 0 +# error /* { dg-bogus "error" } */ +#endif + +#if -1 >= 0 || -1U <= 0 +# error /* { dg-bogus "error" } */ +#endif + +/* Test unary ! and its signedness. */ +#if !5 != 0 || !1 != 0 || !0 != 1 +# error /* { dg-bogus "error" } */ +#endif + +#if !5 - 1 > 0 || !5U - 1 > 0 +# error /* { dg-bogus "error" } */ +#endif + +/* Test unary ~ and its signedness. */ +#if ~0 != -1 || ~~5 != 5 || ~-2 != 1 +# error /* { dg-bogus "error" } */ +#endif + +#if ~5 > 0 || ~5U < 0 +# error /* { dg-bogus "error" } */ +#endif + +/* Test comparison operators and their signedness. */ +#if 1 >= 1 && 2 >= 1 && -1 >= -1 && -1 >= -2 && 1 >= -1 && 1 >= -2 \ + && !(-2 >= -1) && !(2 >= 3) && -1U >= 2 && !(-1 >= 1) +#else +# error /* { dg-bogus "error" } */ +#endif + +#if ((1 > 0) - 2) > 0 || ((1U > 0) - 2) > 0 +# error /* { dg-bogus "error" } */ +#endif + +#if !(1 > 1) && 2 > 1 && !(-1 > -1) && -1 > -2 && 1 > -1 && 1 > -2 \ + && !(-2 > -1) && !(2 > 3) && -1U > 2 && !(-1 > 1) +#else +# error /* { dg-bogus "error" } */ +#endif + +#if ((1 >= 0) - 2) > 0 || ((1U >= 0) - 2) > 0 +# error /* { dg-bogus "error" } */ +#endif + +#if 1 <= 1 && !(2 <= 1) && -1 <= -1 && !(-1 <= -2) && !(1 <= -1) && !(1 <= -2) \ + && -2 <= -1 && 2 <= 3 && !(-1U <= 2) && -1 <= 1 +#else +# error /* { dg-bogus "error" } */ +#endif + +#if ((1 <= 0) - 2) > 0 || ((1U <= 0) - 2) > 0 +# error /* { dg-bogus "error" } */ +#endif + +#if !(1 < 1) && !(2 < 1) && !(-1 < -1) && !(-1 < -2) && !(1 < -1) && !(1 < -2) \ + && -2 < -1 && 2 < 3 && !(-1U < 2) && -1 < 1 +#else +# error /* { dg-bogus "error" } */ +#endif + +#if ((1 < 0) - 2) > 0 || ((1U < 0) - 2) > 0 +# error /* { dg-bogus "error" } */ +#endif + +/* Test bitwise operators and their signedness. */ +#if (3 & 7) != 3 || (-1 & 34) != 34 +# error /* { dg-bogus "error" } */ +#endif + +#if (3 & 7) - 20 > 0 || (3 & 7U) - 20 < 0 +# error /* { dg-bogus "error" } */ +#endif + +#if (3 | 5) != 7 || (-1 | 34) != -1 +# error /* { dg-bogus "error" } */ +#endif + +#if (3 | 7) - 20 > 0 || (3 | 7U) - 20 < 0 +# error /* { dg-bogus "error" } */ +#endif + +#if (7 ^ 5) != 2 || (-1 ^ 34) != ~34 +# error /* { dg-bogus "error" } */ +#endif + +#if (3 ^ 7) - 20 > 0 || (3 ^ 7U) - 20 < 0 +# error /* { dg-bogus "error" } */ +#endif + +/* Test shifts and their signedness. */ +#if 3 << 2 != 12 || 3 << -2 != 0 || -1 << 1 != -2 +# error /* { dg-bogus "error" } */ +#endif + +#if 5 >> 1 != 2 || 5 >> -2 != 20 || -5 >> 1 != -3 +# error /* { dg-bogus "error" } */ +#endif + +#if (5 >> 2) - 2 >= 0 || (5U >> 2) - 2 <= 0 +# error /* { dg-bogus "error" } */ +#endif + +#if (5 << 1) - 20 >= 0 || (5U << 1) - 20 <= 0 +# error /* { dg-bogus "error" } */ +#endif + +#if 0 +/* Test min / max and their signedness. */ +#if (3 >? 2) != 3 || (-3 >? -2) != -2 +# error /* { dg-bogus "error" } */ +#endif + +#if (3 <? 2) != 2 || (-3 <? -2) != -3 +# error /* { dg-bogus "error" } */ +#endif + +#if (3 >? 2) - 4 >= 0 || (3 >? 2U) - 4 <= 0 +# error /* { dg-bogus "error" } */ +#endif + +#if (3 <? 2) - 4 >= 0 || (3 <? 2U) - 4 <= 0 +# error /* { dg-bogus "error" } */ +#endif +#endif + +/* Test *, / and % and their signedness. */ +#if 3 * 2 != 6 || 3 * -2 != -6 || -2 * 3 != -6 || -2 * -3 != 6 +# error /* { dg-bogus "error" } */ +#endif + +#if 3 * 2 - 7 >= 0 || 3 * 2U - 7 < 0 +# error /* { dg-bogus "error" } */ +#endif + +#if 5 / 2 != 2 || -325 / 50 != -6 || 53 / -4 != -13 || -55 / -12 != 4 +# error /* { dg-bogus "error" } */ +#endif + +#if 3 / 2 - 7 >= 0 || 3 / 2U - 7 < 0 +# error /* { dg-bogus "error" } */ +#endif + +#if 5 % 2 != 1 || -325 % 50 != -25 || 53 % -4 != 1 || -55 % -12 != -7 +# error /* { dg-bogus "error" } */ +#endif + +#if 3 % 2 - 7 >= 0 || 3U % 2 - 7 < 0 +# error /* { dg-bogus "error" } */ +#endif + +/* Test , and its signedness. */ +#if (1, 2) != 2 || (2, 1) != 1 +# error /* { dg-bogus "error" } */ +#endif + +#if (1, 2) - 3 >= 0 || (1, 2U) - 3 <= 0 || (1U, 2) - 3 >= 0 +# error /* { dg-bogus "error" } */ +#endif diff --git a/gcc/testsuite/gcc.dg/cpp/if-1.c b/gcc/testsuite/gcc.dg/cpp/if-1.c index 863fa904753..c08fd2393d7 100644 --- a/gcc/testsuite/gcc.dg/cpp/if-1.c +++ b/gcc/testsuite/gcc.dg/cpp/if-1.c @@ -37,5 +37,5 @@ #if 099 /* { dg-error "digits beyond the radix" "decimal in octal constant" } */ #endif -#if 0xfffffffffffffffff /* { dg-error "integer constant out of range" "range error" } */ +#if 0xfffffffffffffffff /* { dg-error "integer constant" "range error" } */ #endif |