diff options
author | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-10-28 18:01:40 +0000 |
---|---|---|
committer | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-10-28 18:01:40 +0000 |
commit | eee954bf975cf742e7651840d069fa4ce94ddb7e (patch) | |
tree | 8d48c96b0a801722146a2653cfbd2d9cf446bad2 /gcc/testsuite/gcc.dg/cpp/macro3.c | |
parent | 79bd622b1c2d25fb1e8d671a87c2d6157d249628 (diff) | |
download | gcc-eee954bf975cf742e7651840d069fa4ce94ddb7e.tar.gz |
* 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
Diffstat (limited to 'gcc/testsuite/gcc.dg/cpp/macro3.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/cpp/macro3.c | 47 |
1 files changed, 47 insertions, 0 deletions
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); +} |