]> gcc.gnu.org Git - gcc.git/commitdiff
* gcc.dg/c90-printf-2.c, gcc.dg/c99-printf-2.c: New tests.
authorJoseph Myers <jsm28@cam.ac.uk>
Mon, 7 Aug 2000 09:48:23 +0000 (10:48 +0100)
committerJoseph Myers <jsm28@gcc.gnu.org>
Mon, 7 Aug 2000 09:48:23 +0000 (10:48 +0100)
From-SVN: r35547

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/c90-printf-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/c99-printf-2.c [new file with mode: 0644]

index 2c43e3f9853896f82eb1aa342d9630dd3298e6eb..f50a8de7c205e24ab2f5e99dfd560e1aa06fa0b1 100644 (file)
@@ -1,3 +1,7 @@
+2000-08-07  Joseph S. Myers  <jsm28@cam.ac.uk>
+
+       * gcc.dg/c90-printf-2.c, gcc.dg/c99-printf-2.c: New tests.
+
 Sun Aug  6 11:41:51 2000  Ovidiu Predescu  <ovidiu@cup.hp.com>
 
        * lib/objc.exp (objc_target_compile): Set the ld_library_path so
diff --git a/gcc/testsuite/gcc.dg/c90-printf-2.c b/gcc/testsuite/gcc.dg/c90-printf-2.c
new file mode 100644 (file)
index 0000000..6686d9d
--- /dev/null
@@ -0,0 +1,36 @@
+/* Test for printf formats.  Formats using C99 features should be rejected
+   outside of C99 mode.
+*/
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1990 -pedantic -Wformat" } */
+
+typedef __SIZE_TYPE__ size_t;
+typedef __PTRDIFF_TYPE__ ptrdiff_t;
+
+__extension__ typedef long long int llong;
+
+/* This next definition is broken.  When GCC has a <stdint.h> and
+   an internal understanding of intmax_t, it should be
+   replaced by an include of <stdint.h> or by a definition for internal
+   macros or typedefs.
+*/
+__extension__ typedef long long int intmax_t;
+
+extern int printf (const char *, ...);
+
+void
+foo (int i, double d, llong ll, intmax_t j, size_t z, ptrdiff_t t)
+{
+  /* Some tests already in c90-printf-1.c, e.g. %lf.  */
+  /* The widths hh, ll, j, z, t are new.  */
+  printf ("%hhd", i); /* { dg-warning "length character|C" "%hh in C90" } */
+  printf ("%lld", ll); /* { dg-warning "length character|C" "%ll in C90" } */
+  printf ("%jd", j); /* { dg-warning "length character|C" "%j in C90" } */
+  printf ("%zu", z); /* { dg-warning "length character|C" "%z in C90" } */
+  printf ("%td", t); /* { dg-warning "length character|C" "%t in C90" } */
+  /* The formats F, a, A are new.  */
+  printf ("%F", d); /* { dg-warning "C" "%F in C90" } */
+  printf ("%a", d); /* { dg-warning "C" "%a in C90" } */
+  printf ("%A", d); /* { dg-warning "C" "%A in C90" } */
+}
diff --git a/gcc/testsuite/gcc.dg/c99-printf-2.c b/gcc/testsuite/gcc.dg/c99-printf-2.c
new file mode 100644 (file)
index 0000000..8a9c661
--- /dev/null
@@ -0,0 +1,34 @@
+/* Test for printf formats.  Formats using extensions to the standard
+   should be rejected in strict pedantic mode.
+*/
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1999 -pedantic -Wformat" } */
+
+typedef __SIZE_TYPE__ size_t;
+typedef __WCHAR_TYPE__ wchar_t;
+typedef __WINT_TYPE__ wint_t;
+
+extern int printf (const char *, ...);
+
+void
+foo (int i, long long ll, size_t z, wint_t lc, wchar_t *ls)
+{
+  /* The length modifiers q, Z and L as applied to integer formats are
+     extensions.
+  */
+  printf ("%qd", ll); /* { dg-warning "C" "%q length" } */
+  printf ("%Ld", ll); /* { dg-warning "C" "%L length" } */
+  printf ("%Zd", z); /* { dg-warning "C" "%Z length" } */
+  /* The conversion specifiers C and S are X/Open extensions; the
+     conversion specifier m is a GNU extension.
+  */
+  printf ("%m"); /* { dg-warning "C" "printf %m" } */
+  printf ("%C", lc); /* { dg-warning "C" "printf %C" } */
+  printf ("%S", ls); /* { dg-warning "C" "printf %S" } */
+  /* The flag character ', and the use of operand number $ formats, are
+     X/Open extensions.
+  */
+  printf ("%'d", i); /* { dg-warning "C" "printf ' flag" } */
+  printf ("%1$d", i); /* { dg-warning "C" "printf $ format" } */
+}
This page took 0.071085 seconds and 5 git commands to generate.