]> gcc.gnu.org Git - gcc.git/commitdiff
2000-04-02 Neil Booth <NeilB@earthling.net>
authorNeil Booth <neilb@earthling.net>
Sun, 2 Apr 2000 07:20:26 +0000 (07:20 +0000)
committerNeil Booth <neil@gcc.gnu.org>
Sun, 2 Apr 2000 07:20:26 +0000 (07:20 +0000)
* 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

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/cpp-cond.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp-ifparen.c
gcc/testsuite/gcc.dg/cpp-missingop.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp-missingparen.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp-shift.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp-shortcircuit.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp-unary.c [new file with mode: 0644]

index b368cc3e8254679db7a9a88f53ef0819780ed9c8..2bb0cbada3fe49bd8c7c2c77721db8f9794b48ef 100644 (file)
@@ -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.
diff --git a/gcc/testsuite/gcc.dg/cpp-cond.c b/gcc/testsuite/gcc.dg/cpp-cond.c
new file mode 100644 (file)
index 0000000..e2af375
--- /dev/null
@@ -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
+
+
index b1c8ed30430d6da3cc01b8269571d971e01e01ed..98da88bfdc36a78488ccd1ed1c00741afe287713 100644 (file)
@@ -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 (file)
index 0000000..286896c
--- /dev/null
@@ -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 (file)
index 0000000..bd2b53b
--- /dev/null
@@ -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 (file)
index 0000000..cbcb37f
--- /dev/null
@@ -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 (file)
index 0000000..d0c4647
--- /dev/null
@@ -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 (file)
index 0000000..03758aa
--- /dev/null
@@ -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
This page took 0.08131 seconds and 5 git commands to generate.