From eee954bf975cf742e7651840d069fa4ce94ddb7e Mon Sep 17 00:00:00 2001 From: neil Date: Sat, 28 Oct 2000 18:01:40 +0000 Subject: * gcc.dg/cpp/19960224-2.c, 20000625-2.c, cxxcom2.c, directiv.c, endif.c, if-4.c, if-5.c, if-mop.c, macsyntx.c, paste2.c, paste6.c, paste8.c, redef2.c, strify2.c, strp1.c, tr-warn1.c, tr-warn3.c, tr-warn6.c, undef1.c, undef2.c, widestr1.c: Update tests for new diagnostic messages. * gcc.dg/cpp/macro3.c: New tests. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@37099 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/testsuite/gcc.dg/cpp/macro3.c | 47 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/cpp/macro3.c (limited to 'gcc/testsuite/gcc.dg/cpp/macro3.c') diff --git a/gcc/testsuite/gcc.dg/cpp/macro3.c b/gcc/testsuite/gcc.dg/cpp/macro3.c new file mode 100644 index 00000000000..b7adaea6c68 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/macro3.c @@ -0,0 +1,47 @@ +/* { dg-do run } */ +/* { dg-options "-std=c99" } */ + +/* First two tests sourced from a bug report of Thomas Pornin. + Varargs test source Jamie Lokier. + All adapted for the testsuite by Neil Booth, Oct 2000. */ + +int c(int x) +{ + return x; +} + +int a(int x) +{ + return x; +} + +/* Tests various macro abuse is correctly expanded. */ +#define c(x) d +#define d(x) c(2) + +/* Every GCC <= 2.96 appears to fail this. */ +#define a(x) b( +#define b(x) a( + +#define apply(...) apply2 (__VA_ARGS__) +#define half(x) ((x) / 2) +#define apply2(f,x) f (x) + +extern void abort (void); +extern void exit (int); + +int main() +{ + /* Expands to c(2). */ + if (c(c)(c) != 2) + abort (); + + /* Expands to a(2). */ + if (a(a)x)2) != 2) + abort (); + + if (apply (half, 200) != 100) + abort (); + + exit (0); +} -- cgit v1.2.1