c-tree.h (flag_hosted): Move declaration from here...
* c-tree.h (flag_hosted): Move declaration from here... * c-common.h (flag_hosted): ... to here. (flag_noniso_default_format_attributes): New declaration. * c-decl.c (flag_noniso_default_format_attributes): New variable. (c_decode_option): Set it appropriately for options choosing language standard variant. * c-common.c (init_function_format_info): Only provide default format attributes if flag_hosted. Only provide the gettext formats if flag_noniso_default_format_attributes. Update comments. (check_format_info): Disable treatment of %a as a scanf flag in C99 mode. cp: * decl.c (flag_hosted, flag_noniso_default_format_attributes): New variables. * decl2.c (lang_decode_option): Disable gettext attributes for -ansi. From-SVN: r35843
This commit is contained in:
parent
f3d360aad1
commit
93e2382f2c
@ -1,3 +1,18 @@
|
||||
2000-08-21 Joseph S. Myers <jsm28@cam.ac.uk>
|
||||
|
||||
* c-tree.h (flag_hosted): Move declaration from here...
|
||||
* c-common.h (flag_hosted): ... to here.
|
||||
(flag_noniso_default_format_attributes): New declaration.
|
||||
* c-decl.c (flag_noniso_default_format_attributes): New variable.
|
||||
(c_decode_option): Set it appropriately for options choosing
|
||||
language standard variant.
|
||||
* c-common.c (init_function_format_info): Only provide default
|
||||
format attributes if flag_hosted. Only provide the gettext
|
||||
formats if flag_noniso_default_format_attributes. Update
|
||||
comments.
|
||||
(check_format_info): Disable treatment of %a as a scanf flag in
|
||||
C99 mode.
|
||||
|
||||
2000-08-21 Joseph S. Myers <jsm28@cam.ac.uk>
|
||||
|
||||
* c-common.c (scan_char_table): Add 'w' to flags for all formats
|
||||
|
@ -1325,11 +1325,13 @@ static international_format_info *international_format_list = NULL;
|
||||
static void check_format_info PARAMS ((function_format_info *, tree));
|
||||
|
||||
/* Initialize the table of functions to perform format checking on.
|
||||
The ANSI functions are always checked (whether <stdio.h> is
|
||||
The ISO C functions are always checked (whether <stdio.h> is
|
||||
included or not), since it is common to call printf without
|
||||
including <stdio.h>. There shouldn't be a problem with this,
|
||||
since ANSI reserves these function names whether you include the
|
||||
header file or not. In any case, the checking is harmless.
|
||||
since ISO C reserves these function names whether you include the
|
||||
header file or not. In any case, the checking is harmless. With
|
||||
-ffreestanding, these default attributes are disabled, and must be
|
||||
specified manually if desired.
|
||||
|
||||
Also initialize the name of function that modify the format string for
|
||||
internationalization purposes. */
|
||||
@ -1337,28 +1339,32 @@ static void check_format_info PARAMS ((function_format_info *, tree));
|
||||
void
|
||||
init_function_format_info ()
|
||||
{
|
||||
record_function_format (get_identifier ("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 ("sprintf"), NULL_TREE,
|
||||
printf_format_type, 2, 3);
|
||||
record_function_format (get_identifier ("scanf"), NULL_TREE,
|
||||
scanf_format_type, 1, 2);
|
||||
record_function_format (get_identifier ("fscanf"), NULL_TREE,
|
||||
scanf_format_type, 2, 3);
|
||||
record_function_format (get_identifier ("sscanf"), NULL_TREE,
|
||||
scanf_format_type, 2, 3);
|
||||
record_function_format (get_identifier ("vprintf"), NULL_TREE,
|
||||
printf_format_type, 1, 0);
|
||||
record_function_format (get_identifier ("vfprintf"), NULL_TREE,
|
||||
printf_format_type, 2, 0);
|
||||
record_function_format (get_identifier ("vsprintf"), NULL_TREE,
|
||||
printf_format_type, 2, 0);
|
||||
record_function_format (get_identifier ("strftime"), NULL_TREE,
|
||||
strftime_format_type, 3, 0);
|
||||
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 ("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,
|
||||
scanf_format_type, 1, 2);
|
||||
record_function_format (get_identifier ("fscanf"), NULL_TREE,
|
||||
scanf_format_type, 2, 3);
|
||||
record_function_format (get_identifier ("sscanf"), NULL_TREE,
|
||||
scanf_format_type, 2, 3);
|
||||
record_function_format (get_identifier ("vprintf"), NULL_TREE,
|
||||
printf_format_type, 1, 0);
|
||||
record_function_format (get_identifier ("vfprintf"), NULL_TREE,
|
||||
printf_format_type, 2, 0);
|
||||
record_function_format (get_identifier ("vsprintf"), NULL_TREE,
|
||||
printf_format_type, 2, 0);
|
||||
record_function_format (get_identifier ("strftime"), NULL_TREE,
|
||||
strftime_format_type, 3, 0);
|
||||
}
|
||||
|
||||
if (flag_isoc99)
|
||||
if (flag_hosted && flag_isoc99)
|
||||
{
|
||||
/* ISO C99 adds the snprintf and vscanf family functions. */
|
||||
record_function_format (get_identifier ("snprintf"), NULL_TREE,
|
||||
@ -1373,9 +1379,13 @@ init_function_format_info ()
|
||||
scanf_format_type, 2, 0);
|
||||
}
|
||||
|
||||
record_international_format (get_identifier ("gettext"), NULL_TREE, 1);
|
||||
record_international_format (get_identifier ("dgettext"), NULL_TREE, 2);
|
||||
record_international_format (get_identifier ("dcgettext"), NULL_TREE, 2);
|
||||
if (flag_hosted && flag_noniso_default_format_attributes)
|
||||
{
|
||||
/* Uniforum/GNU gettext functions, not in ISO C. */
|
||||
record_international_format (get_identifier ("gettext"), NULL_TREE, 1);
|
||||
record_international_format (get_identifier ("dgettext"), NULL_TREE, 2);
|
||||
record_international_format (get_identifier ("dcgettext"), NULL_TREE, 2);
|
||||
}
|
||||
}
|
||||
|
||||
/* Record information for argument format checking. FUNCTION_IDENT is
|
||||
@ -1872,7 +1882,8 @@ check_format_info (info, params)
|
||||
if (pedantic && !flag_isoc99)
|
||||
warning ("ISO C89 does not support the `hh' length modifier");
|
||||
}
|
||||
if (*format_chars == 'a' && info->format_type == scanf_format_type)
|
||||
if (*format_chars == 'a' && info->format_type == scanf_format_type
|
||||
&& !flag_isoc99)
|
||||
{
|
||||
if (format_chars[1] == 's' || format_chars[1] == 'S'
|
||||
|| format_chars[1] == '[')
|
||||
|
@ -195,6 +195,15 @@ extern int flag_isoc99;
|
||||
|
||||
extern int flag_digraphs;
|
||||
|
||||
/* Nonzero means environment is hosted (i.e., not freestanding) */
|
||||
|
||||
extern int flag_hosted;
|
||||
|
||||
/* Nonzero means add default format_arg attributes for functions not
|
||||
in ISO C. */
|
||||
|
||||
extern int flag_noniso_default_format_attributes;
|
||||
|
||||
/* Nonzero means warn about suggesting putting in ()'s. */
|
||||
|
||||
extern int warn_parentheses;
|
||||
|
@ -345,6 +345,11 @@ int flag_digraphs = 1;
|
||||
|
||||
int flag_hosted = 1;
|
||||
|
||||
/* Nonzero means add default format_arg attributes for functions not
|
||||
in ISO C. */
|
||||
|
||||
int flag_noniso_default_format_attributes = 1;
|
||||
|
||||
/* Nonzero means to allow single precision math even if we're generally
|
||||
being traditional. */
|
||||
int flag_allow_single_precision = 0;
|
||||
@ -550,6 +555,7 @@ c_decode_option (argc, argv)
|
||||
flag_writable_strings = 0;
|
||||
flag_no_asm = 1;
|
||||
flag_no_nonansi_builtin = 1;
|
||||
flag_noniso_default_format_attributes = 0;
|
||||
flag_isoc99 = 0;
|
||||
}
|
||||
else if (!strcmp (argstart, "iso9899:199409"))
|
||||
@ -567,6 +573,7 @@ c_decode_option (argc, argv)
|
||||
flag_writable_strings = 0;
|
||||
flag_no_asm = 1;
|
||||
flag_no_nonansi_builtin = 1;
|
||||
flag_noniso_default_format_attributes = 0;
|
||||
flag_isoc99 = 1;
|
||||
flag_digraphs = 1;
|
||||
flag_isoc94 = 1;
|
||||
@ -577,6 +584,7 @@ c_decode_option (argc, argv)
|
||||
flag_writable_strings = 0;
|
||||
flag_no_asm = 0;
|
||||
flag_no_nonansi_builtin = 0;
|
||||
flag_noniso_default_format_attributes = 1;
|
||||
flag_isoc99 = 0;
|
||||
flag_digraphs = 1;
|
||||
flag_isoc94 = 0;
|
||||
@ -587,6 +595,7 @@ c_decode_option (argc, argv)
|
||||
flag_writable_strings = 0;
|
||||
flag_no_asm = 0;
|
||||
flag_no_nonansi_builtin = 0;
|
||||
flag_noniso_default_format_attributes = 1;
|
||||
flag_isoc99 = 1;
|
||||
flag_digraphs = 1;
|
||||
flag_isoc94 = 1;
|
||||
|
@ -299,10 +299,6 @@ extern int flag_cond_mismatch;
|
||||
|
||||
extern int flag_no_asm;
|
||||
|
||||
/* Nonzero means environment is hosted (i.e., not freestanding) */
|
||||
|
||||
extern int flag_hosted;
|
||||
|
||||
/* Nonzero means warn about implicit declarations. */
|
||||
|
||||
extern int warn_implicit;
|
||||
|
@ -1,3 +1,10 @@
|
||||
2000-08-21 Joseph S. Myers <jsm28@cam.ac.uk>
|
||||
|
||||
* decl.c (flag_hosted, flag_noniso_default_format_attributes): New
|
||||
variables.
|
||||
* decl2.c (lang_decode_option): Disable gettext attributes for
|
||||
-ansi.
|
||||
|
||||
2000-08-21 Gabriel Dos Reis <gdr@codesourcery.com>
|
||||
|
||||
* lex.c (lang_init_options): Default diagnostic message maximum
|
||||
|
@ -345,6 +345,15 @@ int flag_isoc94;
|
||||
|
||||
int flag_isoc99;
|
||||
|
||||
/* Nonzero means we are a hosted implementation for code shared with C. */
|
||||
|
||||
int flag_hosted = 1;
|
||||
|
||||
/* Nonzero means add default format_arg attributes for functions not
|
||||
in ISO C. */
|
||||
|
||||
int flag_noniso_default_format_attributes = 1;
|
||||
|
||||
/* Nonzero means give `double' the same size as `float'. */
|
||||
|
||||
extern int flag_short_double;
|
||||
|
@ -822,7 +822,7 @@ lang_decode_option (argc, argv)
|
||||
}
|
||||
else if (!strcmp (p, "-ansi"))
|
||||
flag_no_nonansi_builtin = 1, flag_ansi = 1,
|
||||
flag_no_gnu_keywords = 1;
|
||||
flag_noniso_default_format_attributes = 0, flag_no_gnu_keywords = 1;
|
||||
#ifdef SPEW_DEBUG
|
||||
/* Undocumented, only ever used when you're invoking cc1plus by hand, since
|
||||
it's probably safe to assume no sane person would ever want to use this
|
||||
|
Loading…
Reference in New Issue
Block a user