From: Zack Weinberg Date: Sun, 25 Jun 2000 23:31:02 +0000 (+0000) Subject: 20000625-1.c, [...]: New tests. X-Git-Tag: prereleases/libstdc++-2.92~5672 X-Git-Url: https://gcc.gnu.org/git/?a=commitdiff_plain;h=b42115f711f164a05b1e9f3ca5565eb74ab3964b;p=gcc.git 20000625-1.c, [...]: New tests. * gcc.dg/20000625-1.c, gcc.dg/20000625-2.c, gcc.dg/cpp-mi3.c: New tests. * gcc.dg/cpp-mi3.def: New file. * gcc.dg/cpp-as1.c: Also test that macro expansion does not occur inside assertions. * gcc.dg/cpp-as2.c: Make error regexps match either old or new lexer's error messages. * gcc.dg/cpp-mi.c: Use -H and examine the output, don't try to divine anything from the linemarkers. * gcc.dg/cpp-micc.h: Fix typo (declare int b, not int a); * gcc.dg/poison-1.c: Preprocess only; apply -fno-show-column. From-SVN: r34701 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5b7babef7fb5..521e7eeb73f9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,18 @@ +2000-06-25 Zack Weinberg + + * gcc.dg/20000625-1.c, gcc.dg/20000625-2.c, gcc.dg/cpp-mi3.c: + New tests. + * gcc.dg/cpp-mi3.def: New file. + + * gcc.dg/cpp-as1.c: Also test that macro expansion does not occur + inside assertions. + * gcc.dg/cpp-as2.c: Make error regexps match either old or new + lexer's error messages. + * gcc.dg/cpp-mi.c: Use -H and examine the output, don't try to + divine anything from the linemarkers. + * gcc.dg/cpp-micc.h: Fix typo (declare int b, not int a); + * gcc.dg/poison-1.c: Preprocess only; apply -fno-show-column. + 2000-06-23 Geoffrey Keating * gcc.dg/20000623-1.c: New test. diff --git a/gcc/testsuite/gcc.dg/20000625-1.c b/gcc/testsuite/gcc.dg/20000625-1.c new file mode 100644 index 000000000000..717ffb05e286 --- /dev/null +++ b/gcc/testsuite/gcc.dg/20000625-1.c @@ -0,0 +1,18 @@ +/* Regression test for paste corner cases. Distilled from + syscall stub logic in glibc. */ + +/* { dg-do run } */ + +#include + +#define ENTRY(name) name##: +#define socket bind + +int +main(void) +{ + goto socket; + + ENTRY(socket) + return 0; +} diff --git a/gcc/testsuite/gcc.dg/20000625-2.c b/gcc/testsuite/gcc.dg/20000625-2.c new file mode 100644 index 000000000000..e9834503fd01 --- /dev/null +++ b/gcc/testsuite/gcc.dg/20000625-2.c @@ -0,0 +1,27 @@ +/* More paste corner cases from glibc. */ +/* { dg-do run } */ + +#define symbol_version(name, version) name##@##version + +#define str(x) xstr(x) +#define xstr(x) #x + +const char a[] = str(symbol_version(getrlimit, GLIBC_2.0)); +const char b[] = str(getrlimit@GLIBC_2.0); +const char c[] = "getrlimit@GLIBC_2.0"; + +#include +#include + +int +main(void) +{ + if(strcmp(a, b)) + abort(); + if(strcmp(b, c)) + abort(); + if(strcmp(c, a)) + abort(); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/cpp-as1.c b/gcc/testsuite/gcc.dg/cpp-as1.c index 6e8c0f827be3..ff7cc620bec9 100644 --- a/gcc/testsuite/gcc.dg/cpp-as1.c +++ b/gcc/testsuite/gcc.dg/cpp-as1.c @@ -2,6 +2,7 @@ /* { dg-do compile } */ /* { dg-options "" } */ +#define def unused expansion #define fail int fail #assert abc (def) diff --git a/gcc/testsuite/gcc.dg/cpp-as2.c b/gcc/testsuite/gcc.dg/cpp-as2.c index 2f40c286a9ed..26d3aad02610 100644 --- a/gcc/testsuite/gcc.dg/cpp-as2.c +++ b/gcc/testsuite/gcc.dg/cpp-as2.c @@ -3,17 +3,17 @@ /* { dg-options "-fno-show-column" } */ #assert /* { dg-error "without predicate" "assert w/o predicate" } */ -#assert % /* { dg-error "not an identifier" "assert punctuation" } */ -#assert 12 /* { dg-error "not an identifier" "assert number" } */ -#assert abc /* { dg-error "missing token-sequence" "assert w/o answer" } */ +#assert % /* { dg-error "an identifier" "assert punctuation" } */ +#assert 12 /* { dg-error "an identifier" "assert number" } */ +#assert abc /* { dg-error "missing" "assert w/o answer" } */ #if # /* { dg-error "without predicate" "test w/o predicate" } */ #endif -#if #% /* { dg-error "not an identifier" "test punctuation" } */ +#if #% /* { dg-error "an identifier" "test punctuation" } */ #endif -#if #12 /* { dg-error "not an identifier" "test number" } */ +#if #12 /* { dg-error "an identifier" "test number" } */ #endif #if #abc diff --git a/gcc/testsuite/gcc.dg/cpp-mi.c b/gcc/testsuite/gcc.dg/cpp-mi.c index f83a64d58719..3d05587ddb21 100644 --- a/gcc/testsuite/gcc.dg/cpp-mi.c +++ b/gcc/testsuite/gcc.dg/cpp-mi.c @@ -1,9 +1,18 @@ /* 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. */ + 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. -/* { dg-do preprocess } - { dg-options "" } */ + 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 compile } + { dg-options "-H" } + { dg-error "mic\.h\n\[^\n\]*micc\.h\n\[^\n\]*mind\.h\n\[^\n\]*mindp\.h\n\[^\n\]*mix\.h" "redundant include check" { target native } 0 } */ #include "cpp-mic.h" #include "cpp-mic.h" @@ -26,15 +35,3 @@ main (void) { return a + b + c + d; } - -/* - { dg-final { if ![file exists cpp-mi.i] { return } } } - - { dg-final { set tmp [grep cpp-mi.i {cpp-mi.*\.h} line] } } - { dg-final { # send_user "$tmp\n" } } - { dg-final { if [regexp "^{\[0-9\]+ cpp-mic\.h} {\[0-9\]+ cpp-micc\.h} {\[0-9\]+ cpp-mind\.h} {\[0-9\]+ cpp-mindp\.h} {\[0-9]+ cpp-mix\.h}$" $tmp] \{ } } - { dg-final { pass "cpp-mi.c: redundant include check" } } - { dg-final { \} else \{ } } - { dg-final { fail "cpp-mi.c: redundant include check" } } - { dg-final { \} } } -*/ diff --git a/gcc/testsuite/gcc.dg/cpp-mi3.c b/gcc/testsuite/gcc.dg/cpp-mi3.c new file mode 100644 index 000000000000..6055684b83f4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp-mi3.c @@ -0,0 +1,17 @@ +/* Another test case for over-eager multiple include optimization. + This one distilled from glibc's setlocale.c and categories.def. */ +/* { dg-do compile } */ + +#define X a +#include "cpp-mi3.def" +#undef X + +#define X b +#include "cpp-mi3.def" +#undef X + +int +main(void) +{ + return a + b; +} diff --git a/gcc/testsuite/gcc.dg/cpp-mi3.def b/gcc/testsuite/gcc.dg/cpp-mi3.def new file mode 100644 index 000000000000..375d9c7fe349 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp-mi3.def @@ -0,0 +1,10 @@ +/* Another test case for over-eager multiple include optimization. + This one distilled from glibc's setlocale.c and categories.def. + The #ifdef block doesn't cover the entire file, so it must not be + taken for a reinclude guard. */ + +#ifndef NO_POSTLOAD +#define NO_POSTLOAD NULL +#endif + +int X; diff --git a/gcc/testsuite/gcc.dg/cpp-micc.h b/gcc/testsuite/gcc.dg/cpp-micc.h index 52c9dccca891..46a38cded01a 100644 --- a/gcc/testsuite/gcc.dg/cpp-micc.h +++ b/gcc/testsuite/gcc.dg/cpp-micc.h @@ -3,7 +3,7 @@ #ifndef CPP_MICC_H #define CPP_MICC_H -int a; +int b; #endif diff --git a/gcc/testsuite/gcc.dg/poison-1.c b/gcc/testsuite/gcc.dg/poison-1.c index 6aa57e6f1702..79a910f6bf35 100644 --- a/gcc/testsuite/gcc.dg/poison-1.c +++ b/gcc/testsuite/gcc.dg/poison-1.c @@ -1,3 +1,6 @@ +/* { dg-do preprocess } + { dg-options "-fno-show-column" } */ + #pragma poison foo foo /* { dg-error "foo" "use of foo" } */ #pragma poison foo2 foo3