diff options
author | Neil Booth <neilb@earthling.net> | 2000-10-29 11:49:09 +0000 |
---|---|---|
committer | Neil Booth <neil@gcc.gnu.org> | 2000-10-29 11:49:09 +0000 |
commit | 00c83d466116974609619c0c08dcafe7b79d5c81 (patch) | |
tree | 5a90721df34f0fbd284e9ba209cdb168101d88b2 /gcc | |
parent | 44ed91a1d664478bb2f6f2e277988908ce3675a5 (diff) | |
download | gcc-00c83d466116974609619c0c08dcafe7b79d5c81.zip gcc-00c83d466116974609619c0c08dcafe7b79d5c81.tar.gz gcc-00c83d466116974609619c0c08dcafe7b79d5c81.tar.bz2 |
macro4.c, macro5.c: New tests.
* gcc.dg/cpp/macro4.c, macro5.c: New tests.
* mi1.c, mi1c.h: Add null directives to multiple-include test.
* mi5.c: Test multiple includes work with -C.
* trigraphs.c: Test ^= version.
From-SVN: r37124
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/cpp/macro4.c | 24 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/cpp/macro5.c | 24 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/cpp/mi1.c | 11 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/cpp/mi1c.h | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/cpp/mi5.c | 13 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/cpp/trigraphs.c | 6 |
7 files changed, 81 insertions, 6 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3640a14..f6838e8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2000-10-29 Neil Booth <neilb@earthling.net> + + * gcc.dg/cpp/macro4.c, macro5.c: New tests. + * mi1.c, mi1c.h: Add null directives to multiple-include test. + * mi5.c: Test multiple includes work with -C. + * trigraphs.c: Test ^= version. + 2000-10-28 Neil Booth <neilb@earthling.net> New tests and test updates for new macro expander. diff --git a/gcc/testsuite/gcc.dg/cpp/macro4.c b/gcc/testsuite/gcc.dg/cpp/macro4.c new file mode 100644 index 0000000..c0dfe41 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/macro4.c @@ -0,0 +1,24 @@ +/* Copyright (C) 2000 Free Software Foundation, Inc. */ + +/* { dg-do run } */ + +/* Test source Neil Booth. GCC <= 2.96 don't get this right. */ + +extern void abort (void); + +int glue (int x, int y) +{ + return x + y; +} + +#define glue(x, y) x ## y +#define xglue(x, y) glue (x, y) + +int main () +{ + /* Should expand to glue (1, 2) as the second "glue" is nested. */ + if (glue (xgl, ue) (1, 2) != 3) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/cpp/macro5.c b/gcc/testsuite/gcc.dg/cpp/macro5.c new file mode 100644 index 0000000..9e226b8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/macro5.c @@ -0,0 +1,24 @@ +/* { dg-do preprocess } */ + +/* Test source Robert Lipe, with minor modifications for the testsuite + by Neil Booth. 29 Oct 2000. */ + +#define _VA_ARGS_0() 42 +#define _L_0() ( +#define _R_0() ) + +#define __VA_ARGLIST(argc,list) \ + _VA_ARGS_##argc list + +#define _CAT_LIST(argc,list1,list2) \ + _L_##argc list1 _R_##argc list2 + +#define _VA_ARGLIST(argc,list1,list2) \ + __VA_ARGLIST(argc, \ + _CAT_LIST(argc, list1, list2)) + +#define BLAH(a) _VA_ARGLIST(a, (), ()) + +#if BLAH (0) != 42 +#error Simulated varargs macros +#endif diff --git a/gcc/testsuite/gcc.dg/cpp/mi1.c b/gcc/testsuite/gcc.dg/cpp/mi1.c index 0e15c47..4aa66d6 100644 --- a/gcc/testsuite/gcc.dg/cpp/mi1.c +++ b/gcc/testsuite/gcc.dg/cpp/mi1.c @@ -1,9 +1,10 @@ /* Test "ignore redundant include" facility. - We must test with C and C++ comments outside the guard conditional; - also, we test guarding with #ifndef and #if !defined. - -H is used because cpp mi1ght confuse the issue by optimizing out - #line markers. This test only passes if each of the headers is - read exactly once. + + We must test with C and C++ comments, and null directives, outside + the guard conditional; also, we test guarding with #ifndef and #if + !defined. -H is used because cpp might confuse the issue by + optimizing out #line markers. This test only passes if each of the + headers is read exactly once. The disgusting regexp in the dg-error line, when stuck into dg.exp's compiler-output regexp, matches the correct -H output and diff --git a/gcc/testsuite/gcc.dg/cpp/mi1c.h b/gcc/testsuite/gcc.dg/cpp/mi1c.h index bae9d8b..2956286 100644 --- a/gcc/testsuite/gcc.dg/cpp/mi1c.h +++ b/gcc/testsuite/gcc.dg/cpp/mi1c.h @@ -1,4 +1,5 @@ /* Redundant header include test with C comments at top. */ +# /* And a null directive at the top. */ #ifndef CPP_MIC_H #define CPP_MIC_H @@ -7,4 +8,5 @@ int a; #endif +# /* And at the end, too! */ /* And at the end too! */ diff --git a/gcc/testsuite/gcc.dg/cpp/mi5.c b/gcc/testsuite/gcc.dg/cpp/mi5.c new file mode 100644 index 0000000..a6fdee2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp/mi5.c @@ -0,0 +1,13 @@ +/* Test "ignore redundant include" facility, with -C on. + + The disgusting regexp in the dg-error line, when stuck into + dg.exp's compiler-output regexp, matches the correct -H output and + only the correct -H output. It has to be all on one line because + otherwise it will not be interpreted all in one unit. */ + +/* { dg-do preprocess } + { dg-options "-H -C" } + { dg-error "mi1c\.h" "redundant include check with -C" { target *-*-* } 0 } */ + +#include "mi1c.h" +#include "mi1c.h" diff --git a/gcc/testsuite/gcc.dg/cpp/trigraphs.c b/gcc/testsuite/gcc.dg/cpp/trigraphs.c index 5f60b63..3ec5ed7 100644 --- a/gcc/testsuite/gcc.dg/cpp/trigraphs.c +++ b/gcc/testsuite/gcc.dg/cpp/trigraphs.c @@ -17,10 +17,14 @@ static const char str??(??) = "0123456789??/n"; int main(void) ??< + unsigned char x = 5; + if (sizeof str != TWELVE) abort (); - if ((5 ??' 3) != 6) + /* Test ^=, the only multi-character token to come from trigraphs. */ + x ??'= 3; + if (x != 6) abort (); if ((5 ??! 3) != 7) |