mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-01-28 00:34:41 +08:00
cppexp.c (possible_sum_sign, [...]): Remove.
* 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. From-SVN: r53900
This commit is contained in:
parent
bcb6a2be20
commit
913189081f
@ -1,3 +1,22 @@
|
||||
2002-05-26 Neil Booth <neil@daikokuya.demon.co.uk>
|
||||
|
||||
* 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.
|
||||
|
||||
2002-05-26 Marek Michalkiewicz <marekm@amelek.gda.pl>
|
||||
|
||||
* config/avr/avr.c (avr_asm_only_p): New variable.
|
||||
|
1130
gcc/cppexp.c
1130
gcc/cppexp.c
File diff suppressed because it is too large
Load Diff
@ -1652,6 +1652,8 @@ _cpp_test_assertion (pfile, value)
|
||||
if (node)
|
||||
*value = (node->type == NT_ASSERTION &&
|
||||
(answer == 0 || *find_answer (node, answer) != 0));
|
||||
else if (pfile->cur_token[-1].type == CPP_EOF)
|
||||
_cpp_backup_tokens (pfile, 1);
|
||||
|
||||
/* We don't commit the memory for the answer - it's temporary only. */
|
||||
return node == 0;
|
||||
|
@ -1,3 +1,8 @@
|
||||
2002-05-26 Neil Booth <neil@daikokuya.demon.co.uk>
|
||||
|
||||
* gcc.dg/cpp/arith-1.c: New semantic tests.
|
||||
* gcc.dg/cpp/if-1.c: Update.
|
||||
|
||||
2002-05-24 Ben Elliston <bje@redhat.com>
|
||||
|
||||
* lib/c-torture.exp (c-torture-execute): Handle multiple sources.
|
||||
|
257
gcc/testsuite/gcc.dg/cpp/arith-1.c
Normal file
257
gcc/testsuite/gcc.dg/cpp/arith-1.c
Normal file
@ -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
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user