From: Neil Booth Date: Sat, 28 Oct 2000 18:01:40 +0000 (+0000) Subject: 19960224-2.c, [...]: Update tests for new diagnostic messages. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=74f215d7e03e8d954412f872cf6f10ceeb8626f1;p=gcc.git 19960224-2.c, [...]: Update tests for new diagnostic messages. * 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. From-SVN: r37099 --- diff --git a/gcc/testsuite/gcc.dg/cpp/19960224-2.c b/gcc/testsuite/gcc.dg/cpp/19960224-2.c index 66d2abc9248..799382c8f06 100644 --- a/gcc/testsuite/gcc.dg/cpp/19960224-2.c +++ b/gcc/testsuite/gcc.dg/cpp/19960224-2.c @@ -2,5 +2,5 @@ #if 0 #if 0 -#endif / /* { dg-error "text after #endif" "text after #endif" } */ +#endif / /* { dg-warning "extra tokens" "extra tokens after #endif" } */ #endif diff --git a/gcc/testsuite/gcc.dg/cpp/20000625-2.c b/gcc/testsuite/gcc.dg/cpp/20000625-2.c index 0bd7903985a..fb458984b8c 100644 --- a/gcc/testsuite/gcc.dg/cpp/20000625-2.c +++ b/gcc/testsuite/gcc.dg/cpp/20000625-2.c @@ -1,18 +1,18 @@ /* More paste corner cases from glibc. */ /* { dg-do run } */ +#include +#include + #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)); -/* { dg-warning "valid preprocessing token" "" { target *-*-* } 8 } */ +/* { dg-warning "valid preprocessing token" "" { target *-*-* } 11 } */ const char b[] = str(getrlimit@GLIBC_2.0); const char c[] = "getrlimit@GLIBC_2.0"; -#include -#include - int main(void) { diff --git a/gcc/testsuite/gcc.dg/cpp/cxxcom2.c b/gcc/testsuite/gcc.dg/cpp/cxxcom2.c index 7d0fe09a214..f0fb2d01145 100644 --- a/gcc/testsuite/gcc.dg/cpp/cxxcom2.c +++ b/gcc/testsuite/gcc.dg/cpp/cxxcom2.c @@ -2,7 +2,7 @@ /* { dg-options "-pedantic -std=c89" } */ /* This is an extension and therefore gets a warning. */ -#line 5 "cxx-comments-2.c" 3 /* { dg-warning "garbage at end" "#line extension" } */ +#line 5 "cxx-comments-2.c" 3 /* { dg-warning "extra tokens" "#line extension" } */ /* A system header may contain C++ comments irrespective of mode. */ // C++ comment is not in C89 { dg-bogus "style comment" "bad warning" } diff --git a/gcc/testsuite/gcc.dg/cpp/directiv.c b/gcc/testsuite/gcc.dg/cpp/directiv.c index 718caa22174..2cb772d1233 100644 --- a/gcc/testsuite/gcc.dg/cpp/directiv.c +++ b/gcc/testsuite/gcc.dg/cpp/directiv.c @@ -28,8 +28,8 @@ EMPTY #define bar /* Check that directives always start a line, even if in middle of macro expansion. */ #define func(x) x -func (2 /* { dg-error "unterminated argument" } */ -#define foobar /* { dg-error "may not be used inside" } */ +func (2 /* { dg-error "unterminated" "" { target *-*-* } 32 } */ +#define foobar /* { dg-error "directives may not" } */ /* For tidiness, I think the directive should still be processed above. Certainly, continuing to try to find the closing ')' can diff --git a/gcc/testsuite/gcc.dg/cpp/endif.c b/gcc/testsuite/gcc.dg/cpp/endif.c index c12662cd52b..e6fd4b9f102 100644 --- a/gcc/testsuite/gcc.dg/cpp/endif.c +++ b/gcc/testsuite/gcc.dg/cpp/endif.c @@ -4,12 +4,12 @@ /* You can't get away with this in your own code... */ #ifdef KERNEL #define foo -#endif KERNEL /* { dg-warning "forbids text after" "good warning" } */ +#endif KERNEL /* { dg-warning "extra tokens" "good warning" } */ /* This will provoke a warning because the '3' is an extension. */ -#line 10 "endif-label.c" 3 /* { dg-warning "garbage at end" "#line extension" } */ +#line 10 "endif-label.c" 3 /* { dg-warning "extra tokens" "#line extension" } */ /* ... but in a system header, it's acceptable. */ #ifdef KERNEL #define foo -#endif KERNEL /* { dg-bogus "forbids text after" "bad warning" } */ +#endif KERNEL /* { dg-bogus "extra tokens" "bad warning" } */ diff --git a/gcc/testsuite/gcc.dg/cpp/if-4.c b/gcc/testsuite/gcc.dg/cpp/if-4.c index a39c11d412d..fbab9efc13b 100644 --- a/gcc/testsuite/gcc.dg/cpp/if-4.c +++ b/gcc/testsuite/gcc.dg/cpp/if-4.c @@ -2,7 +2,7 @@ NUL terminated, so we would print garbage after it. */ /* { dg-do compile } */ -#if 1 += 2 /* { dg-error "'\\+=' is not valid" "+= in if" } */ +#if 1 += 2 /* { dg-error "is not valid" "+= in if" } */ syntax_error #endif int foo; diff --git a/gcc/testsuite/gcc.dg/cpp/if-5.c b/gcc/testsuite/gcc.dg/cpp/if-5.c index 2eac73b6132..8238a12ae4b 100644 --- a/gcc/testsuite/gcc.dg/cpp/if-5.c +++ b/gcc/testsuite/gcc.dg/cpp/if-5.c @@ -2,11 +2,8 @@ Jakub Jelinek . */ /* { dg-do preprocess } */ -#ifdef 0 /* { dg-error "with invalid argument" } */ -#error not seen +#ifdef 0 /* { dg-error "macro names" } */ #endif -#ifndef 0 /* { dg-error "with invalid argument" } */ -#else -#error not seen +#ifndef 0 /* { dg-error "macro names" } */ #endif diff --git a/gcc/testsuite/gcc.dg/cpp/if-mop.c b/gcc/testsuite/gcc.dg/cpp/if-mop.c index 66270dab65d..a6a36f15088 100644 --- a/gcc/testsuite/gcc.dg/cpp/if-mop.c +++ b/gcc/testsuite/gcc.dg/cpp/if-mop.c @@ -2,6 +2,8 @@ /* { dg-do preprocess } */ +/* Source: Neil Booth. */ + /* Various illegal expressions with missing components. */ #if /* { dg-error "no expression" "empty #if" } */ 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); +} diff --git a/gcc/testsuite/gcc.dg/cpp/macsyntx.c b/gcc/testsuite/gcc.dg/cpp/macsyntx.c index d5506d4f3c9..e7f3528b49f 100644 --- a/gcc/testsuite/gcc.dg/cpp/macsyntx.c +++ b/gcc/testsuite/gcc.dg/cpp/macsyntx.c @@ -28,13 +28,14 @@ #define foo(, X) /* { dg-error "parameter name" } */ #define foo(X, X) /* { dg-error "duplicate" } */ #define foo(X Y) /* { dg-error "comma" } */ -#define foo(() /* { dg-error "token may not appear" } */ +#define foo(() /* { dg-error "may not appear" } */ #define foo(..., X) /* { dg-error "missing" } */ #define foo \ __VA_ARGS__ /* { dg-warning "__VA_ARGS__" } */ -#define foo(__VA_ARGS__) /* { dg-warning "__VA_ARGS__" } */ -#define foo(...) __VA_ARGS__ /* OK. */ +#define goo(__VA_ARGS__) /* { dg-warning "__VA_ARGS__" } */ +#define hoo(...) __VA_ARGS__ /* OK. */ #define __VA_ARGS__ /* { dg-warning "__VA_ARGS__" } */ +__VA_ARGS__ /* { dg-warning "__VA_ARGS__" } */ /* test # of supplied arguments. */ #define none() @@ -43,12 +44,12 @@ __VA_ARGS__ /* { dg-warning "__VA_ARGS__" } */ #define var0(...) #define var1(x, ...) none() /* OK. */ -none(ichi) /* { dg-error "too many" } */ +none(ichi) /* { dg-error "passed 1" } */ one() /* OK. */ one(ichi) /* OK. */ one(ichi\ -, ni) /* { dg-error "too many" } */ -two(ichi) /* { dg-error "not enough" } */ +, ni) /* { dg-error "passed 2" } */ +two(ichi) /* { dg-error "requires 2" } */ var0() /* OK. */ var0(ichi) /* OK. */ var1() /* { dg-warning "rest arguments to be used" } */ diff --git a/gcc/testsuite/gcc.dg/cpp/paste2.c b/gcc/testsuite/gcc.dg/cpp/paste2.c index adb70b5e8e1..97218565f5b 100644 --- a/gcc/testsuite/gcc.dg/cpp/paste2.c +++ b/gcc/testsuite/gcc.dg/cpp/paste2.c @@ -56,8 +56,8 @@ int main () err ("Operator >> pasting"); /* The LHS should not attempt to expand twice, and thus becomes a - call to the function glue, but the RHS should fully expand. */ - if (glue (gl, ue) (12) != glue (xgl, ue) (1, 2)) + call to the function glue. */ + if (glue (gl, ue) (12) != 12) err ("Recursive macros"); /* Test placemarker pasting. The glued lines should all appear @@ -106,6 +106,8 @@ int main () err ("Various operator pasting"); if (strcmp (hh, "%:%:")) err ("Pasted digraph spelling"); + /* glue3 here will only work if we paste left-to-right. If a + future implementation does not do this, change the test. */ if ((glue (., 0) glue (=, =) .0) + (glue3 (1.0e, +, 1) == 10.0) != 2) err ("Pasted numbers"); } diff --git a/gcc/testsuite/gcc.dg/cpp/paste6.c b/gcc/testsuite/gcc.dg/cpp/paste6.c index 0ac55df328a..6b6733c4e9d 100644 --- a/gcc/testsuite/gcc.dg/cpp/paste6.c +++ b/gcc/testsuite/gcc.dg/cpp/paste6.c @@ -7,6 +7,6 @@ extern int foo(int x); #define bar(x) foo(x) -#define baz(x) bar(##x) /* { dg-warning "nothing can be pasted" } */ +#define baz(x) bar(##x) -int quux(int y) { return baz(y); } +int quux(int y) { return baz(y); } /* { dg-warning "valid preprocessing" } */ diff --git a/gcc/testsuite/gcc.dg/cpp/paste8.c b/gcc/testsuite/gcc.dg/cpp/paste8.c index dc5fe8316a0..dd098947919 100644 --- a/gcc/testsuite/gcc.dg/cpp/paste8.c +++ b/gcc/testsuite/gcc.dg/cpp/paste8.c @@ -7,9 +7,9 @@ int foo(int, ...); a(1) a(1, 2, 3) #define b(x, y, z...) foo(x, ##y) -b(1, 2, 3) /* { dg-warning "pasting would not" } */ +b(1, 2, 3) /* { dg-warning "valid preprocessing token" } */ #define c(x, y, z...) foo(x, ##z) c(1, 2) c(1, 2, 3) -#define d(x) foo(##x) /* { dg-warning "nothing can be pasted" } */ -d(1) +#define d(x) fo(##x) +d(1) /* { dg-warning "valid preprocessing token" } */ diff --git a/gcc/testsuite/gcc.dg/cpp/redef2.c b/gcc/testsuite/gcc.dg/cpp/redef2.c index 0dacf07f651..5838c47506e 100644 --- a/gcc/testsuite/gcc.dg/cpp/redef2.c +++ b/gcc/testsuite/gcc.dg/cpp/redef2.c @@ -26,5 +26,5 @@ { dg-warning "previous" "prev def ro" { target *-*-* } 11 } { dg-warning "previous" "prev def va" { target *-*-* } 14 } - { dg-warning "varargs" "named varargs" { target *-*-* } 14 } - { dg-warning "varargs" "anon varargs" { target *-*-* } 15 } */ + { dg-warning "named variable" "named" { target *-*-* } 14 } + { dg-warning "anonymous variable" "anon" { target *-*-* } 15 } */ diff --git a/gcc/testsuite/gcc.dg/cpp/strp1.c b/gcc/testsuite/gcc.dg/cpp/strp1.c index 096d968c96b..6a1a5ebc839 100644 --- a/gcc/testsuite/gcc.dg/cpp/strp1.c +++ b/gcc/testsuite/gcc.dg/cpp/strp1.c @@ -16,7 +16,7 @@ static const char t1[] = "1.1"; #define f h #define h(a) a+f static const char s2[] = S( f(1)(2) ); -static const char t2[] = "1+h(2)"; +static const char t2[] = "1+f(2)"; #undef I #undef f diff --git a/gcc/testsuite/gcc.dg/cpp/tr-warn1.c b/gcc/testsuite/gcc.dg/cpp/tr-warn1.c index f96e1bc9087..2a818309c63 100644 --- a/gcc/testsuite/gcc.dg/cpp/tr-warn1.c +++ b/gcc/testsuite/gcc.dg/cpp/tr-warn1.c @@ -24,7 +24,7 @@ #assert baz(quux) /* { dg-bogus "indented" "^ #ext" } */ # assert quux(weeble) /* { dg-bogus "indented" "^ # ext" } */ -/* { dg-warning "ISO C does not" "extension warning" { target *-*-* } 22 } */ -/* { dg-warning "ISO C does not" "extension warning" { target *-*-* } 23 } */ -/* { dg-warning "ISO C does not" "extension warning" { target *-*-* } 24 } */ -/* { dg-warning "ISO C does not" "extension warning" { target *-*-* } 25 } */ +/* { dg-warning "GCC extension" "extension warning" { target *-*-* } 22 } */ +/* { dg-warning "GCC extension" "extension warning" { target *-*-* } 23 } */ +/* { dg-warning "GCC extension" "extension warning" { target *-*-* } 24 } */ +/* { dg-warning "GCC extension" "extension warning" { target *-*-* } 25 } */ diff --git a/gcc/testsuite/gcc.dg/cpp/tr-warn3.c b/gcc/testsuite/gcc.dg/cpp/tr-warn3.c index 4819d2f3bd3..e802b4dd0f7 100644 --- a/gcc/testsuite/gcc.dg/cpp/tr-warn3.c +++ b/gcc/testsuite/gcc.dg/cpp/tr-warn3.c @@ -55,7 +55,7 @@ #endif -/* { dg-warning "ISO C does not" "extension warning" { target *-*-* } 27 } */ -/* { dg-warning "ISO C does not" "extension warning" { target *-*-* } 28 } */ -/* { dg-warning "ISO C does not" "extension warning" { target *-*-* } 29 } */ -/* { dg-warning "ISO C does not" "extension warning" { target *-*-* } 30 } */ +/* { dg-warning "GCC extension" "extension warning" { target *-*-* } 27 } */ +/* { dg-warning "GCC extension" "extension warning" { target *-*-* } 28 } */ +/* { dg-warning "GCC extension" "extension warning" { target *-*-* } 29 } */ +/* { dg-warning "GCC extension" "extension warning" { target *-*-* } 30 } */ diff --git a/gcc/testsuite/gcc.dg/cpp/tr-warn6.c b/gcc/testsuite/gcc.dg/cpp/tr-warn6.c index 4068cc51db1..586c56c1044 100644 --- a/gcc/testsuite/gcc.dg/cpp/tr-warn6.c +++ b/gcc/testsuite/gcc.dg/cpp/tr-warn6.c @@ -4,16 +4,16 @@ /* { dg-do preprocess } */ /* { dg-options "-Wtraditional -fno-show-column" } */ -#define foo1(h) sdf "h3" fds "h" /* { dg-warning "macro arg \"h\" would be stringified" "traditional stringification" } */ -#define foo2(h2) sdf "h2" fds "h3" /* { dg-warning "macro arg \"h2\" would be stringified" "traditional stringification" } */ -#define foo3(h3) sdf "h2" fds "h3" /* { dg-warning "macro arg \"h3\" would be stringified" "traditional stringification" } */ -#define foo4(h) sdf 'h3' fds 'h' /* { dg-warning "macro arg \"h\" would be stringified" "traditional stringification" } */ -#define foo5(h2) sdf 'h2' fds 'h3' /* { dg-warning "macro arg \"h2\" would be stringified" "traditional stringification" } */ -#define foo6(h3) sdf 'h2' fds 'h3' /* { dg-warning "macro arg \"h3\" would be stringified" "traditional stringification" } */ -#define foo7(AA, hello, world, EEE) sdf "A B hello C,world,DhelloE F" fds EEE /* { dg-warning "macro arg \"hello\" would be stringified" "traditional stringification" } */ +#define foo1(h) sdf "h3" fds "h" /* { dg-warning "macro argument \"h\" would be stringified" "traditional stringification" } */ +#define foo2(h2) sdf "h2" fds "h3" /* { dg-warning "macro argument \"h2\" would be stringified" "traditional stringification" } */ +#define foo3(h3) sdf "h2" fds "h3" /* { dg-warning "macro argument \"h3\" would be stringified" "traditional stringification" } */ +#define foo4(h) sdf 'h3' fds 'h' /* { dg-warning "macro argument \"h\" would be stringified" "traditional stringification" } */ +#define foo5(h2) sdf 'h2' fds 'h3' /* { dg-warning "macro argument \"h2\" would be stringified" "traditional stringification" } */ +#define foo6(h3) sdf 'h2' fds 'h3' /* { dg-warning "macro argument \"h3\" would be stringified" "traditional stringification" } */ +#define foo7(AA, hello, world, EEE) sdf "A B hello C,world,DhelloE F" fds EEE /* { dg-warning "macro argument \"hello\" would be stringified" "traditional stringification" } */ /* Catch the second warning from the above line. */ -/* { dg-warning "macro arg \"world\" would be stringified" "traditional stringification" { target *-*-* } 13 } */ +/* { dg-warning "macro argument \"world\" would be stringified" "traditional stringification" { target *-*-* } 13 } */ #line 19 "sys-header.h" 3 /* We are in system headers now, no -Wtraditional warnings should issue. */ diff --git a/gcc/testsuite/gcc.dg/cpp/undef1.c b/gcc/testsuite/gcc.dg/cpp/undef1.c index 68118cff60c..821d6545311 100644 --- a/gcc/testsuite/gcc.dg/cpp/undef1.c +++ b/gcc/testsuite/gcc.dg/cpp/undef1.c @@ -9,6 +9,6 @@ #define foo(bar) bar -foo( blah /* { dg-error "unterminated argument" } */ +foo( blah /* { dg-error "unterminated" "" { target *-*-* } 13 } */ #undef foo /* { dg-error "may not be used inside" "foo(#undef foo)" } */ blah ) diff --git a/gcc/testsuite/gcc.dg/cpp/undef2.c b/gcc/testsuite/gcc.dg/cpp/undef2.c index 3ecfb6e9b6d..4e6a690dcc9 100644 --- a/gcc/testsuite/gcc.dg/cpp/undef2.c +++ b/gcc/testsuite/gcc.dg/cpp/undef2.c @@ -1,7 +1,9 @@ -/* C99 6.10.8 para 4: None of [the predefined macro names] shall be the - subject of a #define or an #undef preprocessing directive. */ +/* C99 6.10.8 para 4: None of [the predefined macro names] shall be + the subject of a #define or an #undef preprocessing directive. We + pass -fno-show-column as otherwise dejagnu gets confused. */ /* { dg-do preprocess } */ +/* { dg-options "-fno-show-column" } */ #undef __DATE__ /* { dg-warning "undefining" "__DATE__" } */ #undef __TIME__ /* { dg-warning "undefining" "__TIME__" } */ diff --git a/gcc/testsuite/gcc.dg/cpp/widestr1.c b/gcc/testsuite/gcc.dg/cpp/widestr1.c index 837efadf935..b846990e77f 100644 --- a/gcc/testsuite/gcc.dg/cpp/widestr1.c +++ b/gcc/testsuite/gcc.dg/cpp/widestr1.c @@ -4,6 +4,6 @@ /* { dg-do preprocess } */ -#line 1 L"foo" /* { dg-error "not a string" "wide string in #line" } */ +#line 1 L"foo" /* { dg-error "not a valid filename" "wide string in #line" } */ #include L"stdio.h" /* { dg-error "expects" "wide string in #include" } */ #pragma implementation L"test.h" /* { dg-error "malformed" "wide string in #pragma implementation" } */