2000-04-02 Neil Booth <NeilB@earthling.net>
* gcc.dg/cpp-cond.c New tests. * gcc.dg/cpp-ifparen.c New tests. Amend existing tests to make accidental success less likely. * gcc.dg/cpp-missingop.c New tests. * gcc.dg/cpp-missingparen.c New tests. * gcc.dg/cpp-shift.c New tests. * gcc.dg/cpp-shortcircuit.c New tests. * gcc.dg/cpp-unary.c New tests. From-SVN: r32862
This commit is contained in:
parent
8dd2076d8a
commit
93fd8bf764
8 changed files with 170 additions and 4 deletions
|
@ -1,3 +1,14 @@
|
|||
2000-04-02 Neil Booth <NeilB@earthling.net>
|
||||
|
||||
* gcc.dg/cpp-cond.c New tests.
|
||||
* gcc.dg/cpp-ifparen.c New tests. Amend existing tests to make
|
||||
accidental success less likely.
|
||||
* gcc.dg/cpp-missingop.c New tests.
|
||||
* gcc.dg/cpp-missingparen.c New tests.
|
||||
* gcc.dg/cpp-shift.c New tests.
|
||||
* gcc.dg/cpp-shortcircuit.c New tests.
|
||||
* gcc.dg/cpp-unary.c New tests.
|
||||
|
||||
Wed Mar 29 13:44:23 2000 Jeffrey A Law (law@cygnus.com)
|
||||
|
||||
* gcc.c-torture/compile/20000329-1.c: New test.
|
||||
|
|
13
gcc/testsuite/gcc.dg/cpp-cond.c
Normal file
13
gcc/testsuite/gcc.dg/cpp-cond.c
Normal file
|
@ -0,0 +1,13 @@
|
|||
/* { dg-do preprocess } */
|
||||
|
||||
/* Test the ? : opearator, for precedence and both true and false. */
|
||||
|
||||
#if 1 ? 1 ? 2 : 0 : 0
|
||||
#error OK /* { dg-error "OK" "nested ? :" } */
|
||||
#endif
|
||||
|
||||
#if ((0) ? (1) ? (2) : (3) : (4) ? (5): (6)) == 5
|
||||
#error OK /* { dg-error "OK" "nested ? : with parens" } */
|
||||
#endif
|
||||
|
||||
|
|
@ -1,9 +1,29 @@
|
|||
/* { dg-do preprocess } */
|
||||
|
||||
#if 2048 < (16 * (40) + 192)
|
||||
#error /* { dg-bogus "error" "with paren" } */
|
||||
/* These now use "!=" rather than "<" to increase chance of failure. */
|
||||
#if 16 * (1) + 4 != 20
|
||||
#error /* { dg-bogus "error" "with paren" } */
|
||||
#endif
|
||||
|
||||
#if 2048 < (16 * 40 + 192)
|
||||
#error /* { dg-bogus "error" "without paren" } */
|
||||
#if 16 * 1 + 4 != 20
|
||||
#error /* { dg-bogus "error" "without paren" } */
|
||||
#endif
|
||||
|
||||
#if () /* { dg-error "expression between" "empty paren" } */
|
||||
#endif
|
||||
|
||||
#if (1) == 1
|
||||
#error /* { dg-error "error" "simple parens no. 1" } */
|
||||
#endif
|
||||
|
||||
#if (2)
|
||||
#error /* { dg-error "error" "simple parens no. 2" } */
|
||||
#endif
|
||||
|
||||
#if 3 == (3)
|
||||
#error /* { dg-error "error" "simple parens no. 3" } */
|
||||
#endif
|
||||
|
||||
#if (((-1) + 8)) == ((+2) * ((3)) - -1)
|
||||
#error /* { dg-error "error" "nested parentheses" } */
|
||||
#endif
|
||||
|
|
21
gcc/testsuite/gcc.dg/cpp-missingop.c
Normal file
21
gcc/testsuite/gcc.dg/cpp-missingop.c
Normal file
|
@ -0,0 +1,21 @@
|
|||
/* { dg-do preprocess } */
|
||||
|
||||
/* Various illegal expressions with missing components. */
|
||||
|
||||
#if /* { dg-error "no expression" "empty #if" } */
|
||||
#endif
|
||||
|
||||
#if ~ /* { dg-error "no right op" "no unary operand" } */
|
||||
#endif
|
||||
|
||||
#if 3 + * 6 + 4 /* { dg-error "no left op" "no left operand" } */
|
||||
#endif
|
||||
|
||||
#if 2 ~2 /* { dg-error "missing bin" "no binary operator" } */
|
||||
#endif
|
||||
|
||||
#if 1 + 2 (3) /* { dg-error "missing bin" "immediate then open paren" } */
|
||||
#endif
|
||||
|
||||
#if (2) 4 * 2 /* { dg-error "missing bin" "close paren then immediate" } */
|
||||
#endif
|
27
gcc/testsuite/gcc.dg/cpp-missingparen.c
Normal file
27
gcc/testsuite/gcc.dg/cpp-missingparen.c
Normal file
|
@ -0,0 +1,27 @@
|
|||
/* Test various combinations of missing parentheses give the correct
|
||||
missing parenthesis message. */
|
||||
|
||||
/* { dg-do preprocess } */
|
||||
|
||||
#if (1
|
||||
#endif
|
||||
|
||||
#if 2 * (3 + 4
|
||||
#endif
|
||||
|
||||
#if (2))
|
||||
#endif
|
||||
|
||||
#if )
|
||||
#endif
|
||||
|
||||
#if 4)
|
||||
#endif
|
||||
|
||||
/* { dg-error "missing '\\)'" "missing ')' no. 1" { target *-*-* } 6 } */
|
||||
/* { dg-error "missing '\\)'" "missing ')' no. 2" { target *-*-* } 9 } */
|
||||
/* { dg-error "missing '\\('" "missing '(' no. 1" { target *-*-* } 12 } */
|
||||
/* { dg-error "missing '\\('" "missing '(' no. 2" { target *-*-* } 15 } */
|
||||
/* { dg-error "missing '\\('" "missing '(' no. 3" { target *-*-* } 18 } */
|
||||
|
||||
|
20
gcc/testsuite/gcc.dg/cpp-shift.c
Normal file
20
gcc/testsuite/gcc.dg/cpp-shift.c
Normal file
|
@ -0,0 +1,20 @@
|
|||
/* { dg-do preprocess } */
|
||||
|
||||
/* Test shift operators. */
|
||||
|
||||
#if 1 << 4 != 16
|
||||
#error /* { dg-bogus "error" "<< +ve shift" } */
|
||||
#endif
|
||||
|
||||
#if 19 >> 2 != 4
|
||||
#error /* { dg-bogus "error" ">> +ve shift" } */
|
||||
#endif
|
||||
|
||||
#if 17 << -2 != 17 >> 2
|
||||
#error /* { dg-bogus "error" "<< -ve shift" } */
|
||||
#endif
|
||||
|
||||
#if 25 >> -2 != 25 << 2
|
||||
#error /* { dg-bogus "error" ">> -ve shift" } */
|
||||
#endif
|
||||
|
24
gcc/testsuite/gcc.dg/cpp-shortcircuit.c
Normal file
24
gcc/testsuite/gcc.dg/cpp-shortcircuit.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/* { dg-do preprocess } */
|
||||
|
||||
/* Test that all operators correctly short circuit. */
|
||||
|
||||
#if (2 || 3 / 0) != 1
|
||||
#error /* { dg-bogus "error" "|| short circuit" } */
|
||||
#endif
|
||||
|
||||
#if 0 && 3 / 0
|
||||
#error /* { dg-bogus "error" "&& short circuit" } */
|
||||
#endif
|
||||
|
||||
#if 1 ? 0 : 3 / 0
|
||||
#error /* { dg-bogus "error" "? : right short circuit" } */
|
||||
#endif
|
||||
|
||||
#if 0 ? 3 / 0 : 2
|
||||
#else
|
||||
#error /* { dg-bogus "error" "? : left short circuit" } */
|
||||
#endif
|
||||
|
||||
#if -1 ? 0 && 3 / 0 : 3 / 0 + 5 == 5
|
||||
#error /* { dg-bogus "error" "nested short circuiting" } */
|
||||
#endif
|
30
gcc/testsuite/gcc.dg/cpp-unary.c
Normal file
30
gcc/testsuite/gcc.dg/cpp-unary.c
Normal file
|
@ -0,0 +1,30 @@
|
|||
/* { dg-do preprocess } */
|
||||
|
||||
/* Test the various unary operators. */
|
||||
|
||||
#if 1 + + + 1 /* allow multiple unary sign operators :) */
|
||||
#endif
|
||||
|
||||
#if 8 - +3 != +4 + +1
|
||||
#error /* { dg-bogus "error" "unary +" } */
|
||||
#endif
|
||||
|
||||
#if -2 - -1 != -1
|
||||
#error /* { dg-bogus "error" "unary -" } */
|
||||
#endif
|
||||
|
||||
#if ~0 != -1
|
||||
#error /* { dg-bogus "error" "unary ~" } */
|
||||
#endif
|
||||
|
||||
#if !0 && (!1 == 0) && !!1 != 1
|
||||
#error /* { dg-bogus "error" "unary !" } */
|
||||
#endif
|
||||
|
||||
#if ~~8 != 8
|
||||
#error /* { dg-bogus "error" "double unary ~" } */
|
||||
#endif
|
||||
|
||||
#if 5 + +!-4 != 5
|
||||
#error /* { dg-bogus "error" "compound unary +, !, -" } */
|
||||
#endif
|
Loading…
Add table
Reference in a new issue