From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- gcc/testsuite/gcc.dg/cpp/arith-1.c | 257 +++++++++++++++++++++++++++++++++++++ 1 file changed, 257 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/cpp/arith-1.c (limited to 'gcc/testsuite/gcc.dg/cpp/arith-1.c') 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 000000000..99e3cd7be --- /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 "" } */ + +/* 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) - 4 >= 0 || (3 >? 2U) - 4 <= 0 +# error /* { dg-bogus "error" } */ +#endif + +#if (3 = 0 || (3 = 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 -- cgit v1.2.3