aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Myers <jsm28@cam.ac.uk>2000-08-24 17:14:55 +0100
committerJoseph Myers <jsm28@gcc.gnu.org>2000-08-24 17:14:55 +0100
commit4894ecce4d615cbd13ecf26e43fc928da5d6a3eb (patch)
tree7329a6c30d33cc1b1b92530a0cedede8f7b79a8e
parent2ab99c469c493c52c4977df10a2fbe2cd8ad82d9 (diff)
downloadgcc-4894ecce4d615cbd13ecf26e43fc928da5d6a3eb.zip
gcc-4894ecce4d615cbd13ecf26e43fc928da5d6a3eb.tar.gz
gcc-4894ecce4d615cbd13ecf26e43fc928da5d6a3eb.tar.bz2
c-common.c (time_char_table): Don't allow width with %F.
* c-common.c (time_char_table): Don't allow width with %F. (check_format_info): Don't allow "Z" length with scanf. testsuite: * gcc.dg/c99-scanf-2.c: Remove test for scanf "Z" length. * gcc.dg/format-ext-2.c: New test. From-SVN: r35940
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/c-common.c7
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/c99-scanf-2.c8
-rw-r--r--gcc/testsuite/gcc.dg/format-ext-2.c45
5 files changed, 63 insertions, 7 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f9f9c961..603fb4c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2000-08-24 Joseph S. Myers <jsm28@cam.ac.uk>
+
+ * c-common.c (time_char_table): Don't allow width with %F.
+ (check_format_info): Don't allow "Z" length with scanf.
+
2000-08-24 Gabriel Dos Reis <gdr@codesourcery.com>
* diagnostic.c (finish_diagnostic): Define.
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 689ad73..a7eaec8 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -1282,7 +1282,7 @@ static format_char_info time_char_table[] = {
{ "cx", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "3E" },
{ "%", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "" },
{ "X", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "E" },
- { "RTnrt", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "9" },
+ { "FRTnrt", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "9" },
{ "P", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "G" },
{ "HIMSUWdmw", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "-_0Ow" },
{ "e", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "-_0Ow9" },
@@ -1295,7 +1295,6 @@ static format_char_info time_char_table[] = {
{ "b", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "^" },
{ "h", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "^9" },
{ "Y", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "-_0EOow" },
- { "F", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "w9" },
{ "C", 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "-_0EOow9" },
{ NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
};
@@ -2054,7 +2053,9 @@ check_format_info (info, params)
warning ("ISO C does not support the `%c' length modifier",
length_char);
}
- else if (*format_chars == 'Z' || *format_chars == 'z')
+ else if (*format_chars == 'z'
+ || (*format_chars == 'Z'
+ && info->format_type == printf_format_type))
{
length_char = *format_chars++;
if (pedantic)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a21b34a..f5bb04d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2000-08-24 Joseph S. Myers <jsm28@cam.ac.uk>
+
+ * gcc.dg/c99-scanf-2.c: Remove test for scanf "Z" length.
+ * gcc.dg/format-ext-2.c: New test.
+
2000-08-23 Jason Merrill <jason@redhat.com>
* lib/old-dejagnu.exp: Also ignore "In member function" and
diff --git a/gcc/testsuite/gcc.dg/c99-scanf-2.c b/gcc/testsuite/gcc.dg/c99-scanf-2.c
index c769e6d..c4184c1 100644
--- a/gcc/testsuite/gcc.dg/c99-scanf-2.c
+++ b/gcc/testsuite/gcc.dg/c99-scanf-2.c
@@ -5,23 +5,23 @@
/* { dg-do compile } */
/* { dg-options "-std=iso9899:1999 -pedantic -Wformat" } */
-typedef __SIZE_TYPE__ size_t;
typedef __WCHAR_TYPE__ wchar_t;
extern int scanf (const char *, ...);
void
-foo (int *ip, long long int *llp, size_t *zp, wchar_t *ls)
+foo (int *ip, long long int *llp, wchar_t *ls)
{
- /* The length modifiers q, Z and L as applied to integer formats are
+ /* The length modifiers q and L as applied to integer formats are
extensions.
*/
scanf ("%qd", llp); /* { dg-warning "C" "%q length" } */
scanf ("%Ld", llp); /* { dg-warning "C" "%L length" } */
- scanf ("%Zu", zp); /* { dg-warning "C" "%Z length" } */
/* The conversion specifiers C and S are X/Open extensions. */
scanf ("%C", ls); /* { dg-warning "C" "scanf %C" } */
scanf ("%S", ls); /* { dg-warning "C" "scanf %S" } */
/* The use of operand number $ formats is an X/Open extension. */
scanf ("%1$d", ip); /* { dg-warning "C" "scanf $ format" } */
+ /* glibc also supports flags ' and I on scanf formats, but GCC
+ doesn't yet. */
}
diff --git a/gcc/testsuite/gcc.dg/format-ext-2.c b/gcc/testsuite/gcc.dg/format-ext-2.c
new file mode 100644
index 0000000..eec78ac
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/format-ext-2.c
@@ -0,0 +1,45 @@
+/* Test for format extensions beyond the C standard and X/Open standard.
+ Test for scanf formats.
+*/
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99 -Wformat" } */
+
+/* %q formats want a "quad"; GCC considers this to be a long long. */
+typedef long long int quad_t;
+typedef unsigned long long int u_quad_t;
+
+typedef __WCHAR_TYPE__ wchar_t;
+
+extern int scanf (const char *, ...);
+
+void
+foo (quad_t *qp, u_quad_t *uqp, quad_t *qn, long long int *llp,
+ unsigned long long int *ullp, float *fp, char *s, void **pp, wchar_t *ls)
+{
+ /* As an extension, GCC allows the BSD length "q" for integer formats.
+ This is largely obsoleted in C99 by %j, %ll and SCNd64.
+ */
+ scanf ("%qd%qi%qo%qu%qx%qX%qn", qp, qp, uqp, uqp, uqp, uqp, qn);
+ scanf ("%qf", fp); /* { dg-warning "length character" "bad use of %q" } */
+ scanf ("%qF", fp); /* { dg-warning "length character" "bad use of %q" } */
+ scanf ("%qe", fp); /* { dg-warning "length character" "bad use of %q" } */
+ scanf ("%qE", fp); /* { dg-warning "length character" "bad use of %q" } */
+ scanf ("%qg", fp); /* { dg-warning "length character" "bad use of %q" } */
+ scanf ("%qG", fp); /* { dg-warning "length character" "bad use of %q" } */
+ scanf ("%qa", fp); /* { dg-warning "length character" "bad use of %q" } */
+ scanf ("%qA", fp); /* { dg-warning "length character" "bad use of %q" } */
+ scanf ("%qs", s); /* { dg-warning "length character" "bad use of %q" } */
+ scanf ("%q[abc]", s); /* { dg-warning "length character" "bad use of %q" } */
+ scanf ("%qc", s); /* { dg-warning "length character" "bad use of %q" } */
+ scanf ("%qp", pp); /* { dg-warning "length character" "bad use of %q" } */
+ scanf ("%qC", ls); /* { dg-warning "length character" "bad use of %q" } */
+ scanf ("%qS", ls); /* { dg-warning "length character" "bad use of %q" } */
+ /* As an extension, GCC allows the length "L" on integer formats
+ (but not %n) as a synonym for "ll".
+ This should be considered deprecated.
+ */
+ scanf ("%Ld%Li%Lo%Lu%Lx%LX", llp, llp, ullp, ullp, ullp, ullp);
+ /* glibc also supports flags ' and I on scanf formats, but GCC
+ doesn't yet. */
+}