mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-01-28 00:34:41 +08:00
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
This commit is contained in:
parent
2ab99c469c
commit
4894ecce4d
@ -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.
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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. */
|
||||
}
|
||||
|
45
gcc/testsuite/gcc.dg/format-ext-2.c
Normal file
45
gcc/testsuite/gcc.dg/format-ext-2.c
Normal file
@ -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. */
|
||||
}
|
Loading…
Reference in New Issue
Block a user