c-format.c (init_function_format_info): Check __builtin_printf and __builtin_fprintf even if -ffreestanding.
* c-format.c (init_function_format_info): Check __builtin_printf and __builtin_fprintf even if -ffreestanding. Check C99 functions in gnu89 mode. testsuite: * gcc.dg/format/builtin-1.c, gcc.dg/format/ext-6.c: New tests. From-SVN: r45757
This commit is contained in:
parent
f6a67a813e
commit
040cc0718f
|
@ -1,3 +1,9 @@
|
|||
2001-09-22 Joseph S. Myers <jsm28@cam.ac.uk>
|
||||
|
||||
* c-format.c (init_function_format_info): Check __builtin_printf
|
||||
and __builtin_fprintf even if -ffreestanding. Check C99 functions
|
||||
in gnu89 mode.
|
||||
|
||||
Sat Sep 22 09:09:32 2001 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
|
||||
|
||||
* c-common.c (format_attribute_table): Remove decl.
|
||||
|
|
|
@ -325,17 +325,20 @@ static international_format_info *international_format_list = NULL;
|
|||
void
|
||||
init_function_format_info ()
|
||||
{
|
||||
/* __builtin functions should be checked unconditionally, even with
|
||||
-ffreestanding. */
|
||||
record_function_format (get_identifier ("__builtin_printf"), NULL_TREE,
|
||||
printf_format_type, 1, 2);
|
||||
record_function_format (get_identifier ("__builtin_fprintf"), NULL_TREE,
|
||||
printf_format_type, 2, 3);
|
||||
|
||||
if (flag_hosted)
|
||||
{
|
||||
/* Functions from ISO/IEC 9899:1990. */
|
||||
record_function_format (get_identifier ("printf"), NULL_TREE,
|
||||
printf_format_type, 1, 2);
|
||||
record_function_format (get_identifier ("__builtin_printf"), NULL_TREE,
|
||||
printf_format_type, 1, 2);
|
||||
record_function_format (get_identifier ("fprintf"), NULL_TREE,
|
||||
printf_format_type, 2, 3);
|
||||
record_function_format (get_identifier ("__builtin_fprintf"), NULL_TREE,
|
||||
printf_format_type, 2, 3);
|
||||
record_function_format (get_identifier ("sprintf"), NULL_TREE,
|
||||
printf_format_type, 2, 3);
|
||||
record_function_format (get_identifier ("scanf"), NULL_TREE,
|
||||
|
@ -354,7 +357,7 @@ init_function_format_info ()
|
|||
strftime_format_type, 3, 0);
|
||||
}
|
||||
|
||||
if (flag_hosted && flag_isoc99)
|
||||
if (flag_hosted && (flag_isoc99 || flag_noniso_default_format_attributes))
|
||||
{
|
||||
/* ISO C99 adds the snprintf and vscanf family functions. */
|
||||
record_function_format (get_identifier ("snprintf"), NULL_TREE,
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2001-09-22 Joseph S. Myers <jsm28@cam.ac.uk>
|
||||
|
||||
* gcc.dg/format/builtin-1.c, gcc.dg/format/ext-6.c: New tests.
|
||||
|
||||
2001-09-22 George Helffrich <george@geo.titech.ac.jp>
|
||||
|
||||
* g77.dg/strlen0.f: New test.
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
/* Test for format extensions. Test that the __builtin functions get their
|
||||
default attributes even with -ffreestanding.
|
||||
*/
|
||||
/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-std=gnu99 -Wformat -ffreestanding" } */
|
||||
|
||||
#include "format.h"
|
||||
|
||||
void
|
||||
foo (int i)
|
||||
{
|
||||
__builtin_fprintf (stdout, "%d", i);
|
||||
__builtin_fprintf (stdout, "%ld", i); /* { dg-warning "format" "__builtin_fprintf" } */
|
||||
__builtin_printf ("%d", i);
|
||||
__builtin_printf ("%ld", i); /* { dg-warning "format" "__builtin_printf" } */
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
/* Test for format extensions. Test that the C99 functions get their
|
||||
default attributes in gnu89 mode.
|
||||
*/
|
||||
/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-std=gnu89 -Wformat" } */
|
||||
|
||||
#include "format.h"
|
||||
|
||||
void
|
||||
foo (int i, char *s, size_t n, int *ip, va_list v0, va_list v1, va_list v2,
|
||||
va_list v3, va_list v4, va_list v5, va_list v6, va_list v7, va_list v8,
|
||||
va_list v9, va_list v10, va_list v11, va_list v12, va_list v13)
|
||||
{
|
||||
fprintf (stdout, "%d", i);
|
||||
fprintf (stdout, "%ld", i); /* { dg-warning "format" "fprintf" } */
|
||||
printf ("%d", i);
|
||||
printf ("%ld", i); /* { dg-warning "format" "printf" } */
|
||||
sprintf (s, "%d", i);
|
||||
sprintf (s, "%ld", i); /* { dg-warning "format" "sprintf" } */
|
||||
snprintf (s, n, "%d", i);
|
||||
snprintf (s, n, "%ld", i); /* { dg-warning "format" "snprintf" } */
|
||||
vfprintf (stdout, "%d", v0);
|
||||
vfprintf (stdout, "%Y", v1); /* { dg-warning "format" "vfprintf" } */
|
||||
vprintf ("%d", v2);
|
||||
vprintf ("%Y", v3); /* { dg-warning "format" "vprintf" } */
|
||||
vsprintf (s, "%d", v4);
|
||||
vsprintf (s, "%Y", v5); /* { dg-warning "format" "vsprintf" } */
|
||||
vsnprintf (s, n, "%d", v6);
|
||||
vsnprintf (s, n, "%Y", v7); /* { dg-warning "format" "vsnprintf" } */
|
||||
fscanf (stdin, "%d", ip);
|
||||
fscanf (stdin, "%ld", ip); /* { dg-warning "format" "fscanf" } */
|
||||
scanf ("%d", ip);
|
||||
scanf ("%ld", ip); /* { dg-warning "format" "scanf" } */
|
||||
sscanf (s, "%d", ip);
|
||||
sscanf (s, "%ld", ip); /* { dg-warning "format" "sscanf" } */
|
||||
vfscanf (stdin, "%d", v8);
|
||||
vfscanf (stdin, "%Y", v9); /* { dg-warning "format" "vfscanf" } */
|
||||
vscanf ("%d", v10);
|
||||
vscanf ("%Y", v11); /* { dg-warning "format" "vscanf" } */
|
||||
vsscanf (s, "%d", v12);
|
||||
vsscanf (s, "%Y", v13); /* { dg-warning "format" "vsscanf" } */
|
||||
}
|
Loading…
Reference in New Issue