]> gcc.gnu.org Git - gcc.git/commitdiff
19960224-2.c, [...]: Update tests for new diagnostic messages.
authorNeil Booth <neil@gcc.gnu.org>
Sat, 28 Oct 2000 18:01:40 +0000 (18:01 +0000)
committerNeil Booth <neil@gcc.gnu.org>
Sat, 28 Oct 2000 18:01:40 +0000 (18:01 +0000)
* 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

21 files changed:
gcc/testsuite/gcc.dg/cpp/19960224-2.c
gcc/testsuite/gcc.dg/cpp/20000625-2.c
gcc/testsuite/gcc.dg/cpp/cxxcom2.c
gcc/testsuite/gcc.dg/cpp/directiv.c
gcc/testsuite/gcc.dg/cpp/endif.c
gcc/testsuite/gcc.dg/cpp/if-4.c
gcc/testsuite/gcc.dg/cpp/if-5.c
gcc/testsuite/gcc.dg/cpp/if-mop.c
gcc/testsuite/gcc.dg/cpp/macro3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp/macsyntx.c
gcc/testsuite/gcc.dg/cpp/paste2.c
gcc/testsuite/gcc.dg/cpp/paste6.c
gcc/testsuite/gcc.dg/cpp/paste8.c
gcc/testsuite/gcc.dg/cpp/redef2.c
gcc/testsuite/gcc.dg/cpp/strp1.c
gcc/testsuite/gcc.dg/cpp/tr-warn1.c
gcc/testsuite/gcc.dg/cpp/tr-warn3.c
gcc/testsuite/gcc.dg/cpp/tr-warn6.c
gcc/testsuite/gcc.dg/cpp/undef1.c
gcc/testsuite/gcc.dg/cpp/undef2.c
gcc/testsuite/gcc.dg/cpp/widestr1.c

index 66d2abc9248169b3a21851425e2dc4fec610944a..799382c8f06c8e36128adee3b5a24d8062b6ed22 100644 (file)
@@ -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
index 0bd7903985a0a4bb84c681aa69e6b1021b16fc80..fb458984b8c0ce03233eba86ce82fd12ca7f95b2 100644 (file)
@@ -1,18 +1,18 @@
 /* More paste corner cases from glibc.  */
 /* { dg-do run } */
 
+#include <stdlib.h>
+#include <string.h>
+
 #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 <stdlib.h>
-#include <string.h>
-
 int
 main(void)
 {
index 7d0fe09a2141313bf3fc4f10d91baa8c09e2b902..f0fb2d0114512bcf3443d158583dfcf6670adde6 100644 (file)
@@ -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" }
index 718caa22174bebcff7940caeecc6d71f7533acf7..2cb772d123300e156c1f3d7248b0bf7bedbc4fcd 100644 (file)
@@ -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
index c12662cd52ba6b2bdaef97f23f2cc385a904871d..e6fd4b9f1025800e0f3ebf673ed7cb64ccd9401d 100644 (file)
@@ -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" } */
index a39c11d412d0cf34cd8f7a9ec17062ec52bc39e7..fbab9efc13bdac142f6997a2119a15f1e1196fd5 100644 (file)
@@ -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;
index 2eac73b6132d3d6d0322f84f17c25c8bf15bb6c0..8238a12ae4bb4f599ddf0c4d50f784ee2957297f 100644 (file)
@@ -2,11 +2,8 @@
    Jakub Jelinek <jakub@redhat.com>.  */
 /* { 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
index 66270dab65d9daa0b2b1e57de8a9b64ce8a61e87..a6a36f150889a04a5d1b74c2b31d14954d55e92b 100644 (file)
@@ -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 (file)
index 0000000..b7adaea
--- /dev/null
@@ -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);
+}
index d5506d4f3c9e909e8f4bd55ed2666efa969b70d1..e7f3528b49f49c81174285b39f6aaebc40b86939 100644 (file)
 #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" } */
index adb70b5e8e1de629dc137f094f2342bcba5e65a8..97218565f5b01ff8862b0ea7ab0e44f9023e24a5 100644 (file)
@@ -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");
   }
index 0ac55df328aec64f67acd44e34bfcd056ea9b694..6b6733c4e9d8edb2d97d43d7ae355543540cda82 100644 (file)
@@ -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" } */
index dc5fe8316a0e16859f6693c41b87cbf0a4dcb484..dd098947919cee5c630f413b7eeae1260f55759f 100644 (file)
@@ -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" } */
index 0dacf07f651c2e81c49f23778d3e31ba2c8eb730..5838c47506e4861a0ebdf37ce14ed80f7ff7416e 100644 (file)
@@ -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 } */ 
index 096d968c96bd3d57c4c5a489fad932cc2d822125..6a1a5ebc839b5160b4023d39ff55ef151c3770c9 100644 (file)
@@ -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
index f96e1bc90876a9896a24b647b9409c0a0c1d1f90..2a818309c63020e6308c4111f4b7073af7bdd7c6 100644 (file)
@@ -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 } */
index 4819d2f3bd38bf4c4e59259806d9facb4548d342..e802b4dd0f754b12636674dff488d48e398aee60 100644 (file)
@@ -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 } */
index 4068cc51db12fb4d0e2b1e155d13b72d90e117c0..586c56c1044f0cbf731b94df2447c67f5ed1c642 100644 (file)
@@ -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.  */
index 68118cff60cb1ec5ef9fe07814162e113d90576c..821d65453119e67e3a7e2c67216566fe2ab8ed20 100644 (file)
@@ -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 )
index 3ecfb6e9b6df47c3f1e21af53a2568b1b774a35a..4e6a690dcc9c63562d8d66286261a87f093a820c 100644 (file)
@@ -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__" } */
index 837efadf935c311b6dafbeb3a56d3be2ec08e387..b846990e77fbc251da18c2adcf0c186fc3a5119b 100644 (file)
@@ -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" } */
This page took 0.093742 seconds and 5 git commands to generate.