diff options
author | Neil Booth <neilb@earthling.net> | 2000-05-05 02:50:47 +0000 |
---|---|---|
committer | Neil Booth <neil@gcc.gnu.org> | 2000-05-05 02:50:47 +0000 |
commit | 59b30ca6ddd5930d454517cd8e6c54701b21b97b (patch) | |
tree | cb203da69ed15685ed6848b058c0cf7cd4cf0385 /gcc | |
parent | 5f97a7dcfd4067fdf33b2db35af340490570932a (diff) | |
download | gcc-59b30ca6ddd5930d454517cd8e6c54701b21b97b.zip gcc-59b30ca6ddd5930d454517cd8e6c54701b21b97b.tar.gz gcc-59b30ca6ddd5930d454517cd8e6c54701b21b97b.tar.bz2 |
*** empty log message ***
From-SVN: r33697
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/cpp-opprec.c | 97 |
2 files changed, 102 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0ba575f..c431e0b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2000-05-04 Neil Booth <NeilB@earthling.net> + + * gcc.dg/cpp-opprec.c: New tests for operator precedence in the + preprocessor. + 2000-05-04 Richard Henderson <rth@cygnus.com> * gcc.c-torture/execute/20000503-1.c: Fix typo. diff --git a/gcc/testsuite/gcc.dg/cpp-opprec.c b/gcc/testsuite/gcc.dg/cpp-opprec.c new file mode 100644 index 0000000..3f06cd6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp-opprec.c @@ -0,0 +1,97 @@ +/* Copyright (C) 2000 Free Software Foundation, Inc. */ + +/* Test the full range of preprocessor operator precedence. Each + operator is tested with one of immediately higher precedence to + verify it is of strictly lower precedence. To avoid complications, + each test uses just those two operators. Occasionally this assumes + correct operation of if-then-else, so the first tests verify this. */ + +/* { dg-do preprocess } */ + +/* Ensure correct functioning of if-then-else. */ +#if 1 +#else +#error #else block evaluated for true conditional +#endif + +#if 0 +#error #if block evaluated for false conditional +#else +#endif + +/* , not higher than ?. This is not a syntax error if it is. */ +#if 1 ? 0, 1: 1 /* { dg-error "syntax" "? higher precedence than ," } */ +#error +#endif + +/* : strictly higher than ?. This would give a syntax error otherwise. */ +#if 0 ? 0 : 1 ? 1 : 1 +#endif + +/* || strictly higher than ?:. */ +#if 1 ? 0: 0 || 1 +#error operator ?: has higher precedence than operator || +#endif + +/* && strictly higher than ||. */ +#if 1 || 0 && 0 +#else +#error operator || has higher precedence than operator && +#endif + +/* | strictly higher than &&. */ +#if 0 && 0 | 1 +#error operator && has higher precedence than operator | +#endif + +/* ^ strictly higher than |. */ +#if 1 | 0 ^ 1 +#else +#error operator | has higher precedence than operator ^ +#endif + +/* & strictly higher than ^. */ +#if 1 ^ 0 & 0 +#else +#error operator ^ has higher precedence than operator & +#endif + +/* == (!=) strictly higher than &. */ +#if 0 & 0 == 0 +#error operator & has higher precedence than operator == +#endif + +/* < (>, <=, >=) strictly higher than == (!=). */ + +#if 0 == 0 < 0 +#else +#error operator == has higher precedence than operator < +#endif + +/* << (>>) strictly higher than < (>, <=, >=). */ +#if 1 < 1 << 1 +#else +#error operator < has higher precedence than operator << +#endif + +/* Binary + (-) strictly higher than << (>>). */ +#if 0 << 0 + 1 +#error operator << has higher precedence than binary + +#endif + +/* Binary * (/, %) strictly higher than binary + (-). */ +#if 1 + 0 * 0 +#else +#error binary + has higher precedence than binary * +#endif + +/* Unary operators (!, ~, -, +) strictly higher than binary * (/, %). + Equality is hard to detect because of right-associativity. */ +#if ~1 * 0 +#error binary * has higher precedence than operator ~ +#endif + +/* () > Unary. Unfortunately this requires an additional operator. */ +#if -(1 - 1) +#error unary - has higher precedence than operator () +#endif |