aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Booth <neil@cat.daikokuya.demon.co.uk>2001-07-31 06:52:21 +0000
committerNeil Booth <neil@gcc.gnu.org>2001-07-31 06:52:21 +0000
commitdd666a872b497162a7e2130415936df27f532b35 (patch)
treef505c554fcb366f358e3e22dd4131785b97c75ce
parent91abf72dfcfd9dddafdadd0d1262f1465bfb8abc (diff)
downloadgcc-dd666a872b497162a7e2130415936df27f532b35.zip
gcc-dd666a872b497162a7e2130415936df27f532b35.tar.gz
gcc-dd666a872b497162a7e2130415936df27f532b35.tar.bz2
* gcc.dg/cpp/macro8.c: New tests.
From-SVN: r44502
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/cpp/macro8.c29
2 files changed, 33 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 87d3d799..8a88b5e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2001-07-31 Neil Booth <neil@cat.daikokuya.demon.co.uk>
+
+ * gcc.dg/cpp/macro8.c: New test.
+
2001-07-27 Nathan Sidwell <nathan@codesourcery.com>
* g++.dg/abi/vbase8-21.C: New test.
diff --git a/gcc/testsuite/gcc.dg/cpp/macro8.c b/gcc/testsuite/gcc.dg/cpp/macro8.c
new file mode 100644
index 0000000..f49b0be
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/macro8.c
@@ -0,0 +1,29 @@
+/* { dg-do compile } */
+/* { dg-options -std=gnu89 } */
+
+/* GCC 2.95.2 used to get the following variable argument macro
+ expansions wrong.
+
+ Source: Neil Booth, from PR 3852 with persmission. 31 Jul 2001. */
+
+#define TEST_WORSE(args...) (5, ## args)
+#define TEST_BAD(foo, args...) (2, (foo), ## args)
+
+extern void abort ();
+
+static int add (int a, int b)
+{
+ return a + b;
+}
+
+int main ()
+{
+ /* Would expand to a single closing parenthesis, maybe because of
+ the "no args requires space" brokenness. */
+ if (TEST_WORSE () != 5)
+ abort ();
+ /* The macro would expand to (0, (0) with a missing closing parenthesis. */
+ if (add TEST_BAD (5) != 7)
+ abort ();
+ return 0;
+}