aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJoseph Myers <jsm28@cam.ac.uk>2000-08-07 10:48:23 +0100
committerJoseph Myers <jsm28@gcc.gnu.org>2000-08-07 10:48:23 +0100
commit1c5ecb11b7742cf328e1fbc41266a36f1b58a1b7 (patch)
treee4c2768c87ae171f154b2ac5ad5db6f9baa621f3 /gcc
parentae5f017f1451b4cec57df4dc52e68d50bfa63b03 (diff)
downloadgcc-1c5ecb11b7742cf328e1fbc41266a36f1b58a1b7.zip
gcc-1c5ecb11b7742cf328e1fbc41266a36f1b58a1b7.tar.gz
gcc-1c5ecb11b7742cf328e1fbc41266a36f1b58a1b7.tar.bz2
* gcc.dg/c90-printf-2.c, gcc.dg/c99-printf-2.c: New tests.
From-SVN: r35547
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/c90-printf-2.c36
-rw-r--r--gcc/testsuite/gcc.dg/c99-printf-2.c34
3 files changed, 74 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2c43e3f..f50a8de 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..6686d9d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c90-printf-2.c
@@ -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
index 0000000..8a9c661
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c99-printf-2.c
@@ -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" } */
+}