diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b368cc3e825..2bb0cbada3f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,14 @@ +2000-04-02 Neil Booth + + * 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. diff --git a/gcc/testsuite/gcc.dg/cpp-cond.c b/gcc/testsuite/gcc.dg/cpp-cond.c new file mode 100644 index 00000000000..e2af3752154 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp-cond.c @@ -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 + + diff --git a/gcc/testsuite/gcc.dg/cpp-ifparen.c b/gcc/testsuite/gcc.dg/cpp-ifparen.c index b1c8ed30430..98da88bfdc3 100644 --- a/gcc/testsuite/gcc.dg/cpp-ifparen.c +++ b/gcc/testsuite/gcc.dg/cpp-ifparen.c @@ -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 diff --git a/gcc/testsuite/gcc.dg/cpp-missingop.c b/gcc/testsuite/gcc.dg/cpp-missingop.c new file mode 100644 index 00000000000..286896c7417 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp-missingop.c @@ -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 diff --git a/gcc/testsuite/gcc.dg/cpp-missingparen.c b/gcc/testsuite/gcc.dg/cpp-missingparen.c new file mode 100644 index 00000000000..bd2b53bc037 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp-missingparen.c @@ -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 } */ + + diff --git a/gcc/testsuite/gcc.dg/cpp-shift.c b/gcc/testsuite/gcc.dg/cpp-shift.c new file mode 100644 index 00000000000..cbcb37fa090 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp-shift.c @@ -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 + diff --git a/gcc/testsuite/gcc.dg/cpp-shortcircuit.c b/gcc/testsuite/gcc.dg/cpp-shortcircuit.c new file mode 100644 index 00000000000..d0c4647e7df --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp-shortcircuit.c @@ -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 diff --git a/gcc/testsuite/gcc.dg/cpp-unary.c b/gcc/testsuite/gcc.dg/cpp-unary.c new file mode 100644 index 00000000000..03758aacf30 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp-unary.c @@ -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