]> gcc.gnu.org Git - gcc.git/commitdiff
* gcc.dg/formatz-1.c: New test.
authorJoseph Myers <jsm28@cam.ac.uk>
Mon, 17 Jul 2000 09:03:54 +0000 (03:03 -0600)
committerJeff Law <law@gcc.gnu.org>
Mon, 17 Jul 2000 09:03:54 +0000 (03:03 -0600)
From-SVN: r35082

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/formatz-1.c [new file with mode: 0644]

index 6c7e322fef8a9efd600d627617da0462c01bdd35..e4a5eec4dcfa0e673b745288dd38d83f56657d32 100644 (file)
@@ -4,6 +4,8 @@
 
 2000-07-17  Joseph S. Myers  <jsm28@cam.ac.uk>
 
+       * gcc.dg/formatz-1.c: New test.
+
        * gcc.dg/c90-digraph-1.c, gcc.dg/c94-digraph.c,
        * gcc.dg/c99-digraph.c: New tests.
 
diff --git a/gcc/testsuite/gcc.dg/formatz-1.c b/gcc/testsuite/gcc.dg/formatz-1.c
new file mode 100644 (file)
index 0000000..4436959
--- /dev/null
@@ -0,0 +1,31 @@
+/* Test for bugs with %z and %Z formats.  See PRs c/89, c/156, c/376.  */
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-Wformat" } */
+
+typedef __SIZE_TYPE__ size_t;
+
+extern int printf (const char *, ...);
+extern int scanf (const char *, ...);
+
+size_t
+foo (void)
+{
+  size_t t;
+  scanf ("%zu", &t); /* { dg-bogus "length character|format" "bogus scanf warning" } */
+  return t;
+}
+
+void
+bar (size_t t)
+{
+  printf ("%zu\n", t); /* { dg-bogus "format" "bogus printf warning" } */
+}
+
+/* The %Z printf format is an old GNU libc extension to do the same thing.  */
+
+void
+baz (size_t t)
+{
+  printf ("%Zu\n", t); /* { dg-bogus "format" "bogus printf warning" } */
+}
This page took 0.074594 seconds and 5 git commands to generate.