aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/format/z-1.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/format/z-1.c')
-rw-r--r--gcc/testsuite/gcc.dg/format/z-1.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/format/z-1.c b/gcc/testsuite/gcc.dg/format/z-1.c
new file mode 100644
index 0000000..4125d54
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/format/z-1.c
@@ -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|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" } */
+}