Commit 9bee1c90 authored by jsm28's avatar jsm28
Browse files

* 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.


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@35843 138bc75d-0d04-0410-961f-82ee72b054a4
parent 4caacdba
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> 2000-08-21 Joseph S. Myers <jsm28@cam.ac.uk>
* c-common.c (scan_char_table): Add 'w' to flags for all formats * 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; ...@@ -1325,11 +1325,13 @@ static international_format_info *international_format_list = NULL;
static void check_format_info PARAMS ((function_format_info *, tree)); static void check_format_info PARAMS ((function_format_info *, tree));
/* Initialize the table of functions to perform format checking on. /* 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 included or not), since it is common to call printf without
including <stdio.h>. There shouldn't be a problem with this, including <stdio.h>. There shouldn't be a problem with this,
since ANSI reserves these function names whether you include the since ISO C reserves these function names whether you include the
header file or not. In any case, the checking is harmless. 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 Also initialize the name of function that modify the format string for
internationalization purposes. */ internationalization purposes. */
...@@ -1337,28 +1339,32 @@ static void check_format_info PARAMS ((function_format_info *, tree)); ...@@ -1337,28 +1339,32 @@ static void check_format_info PARAMS ((function_format_info *, tree));
void void
init_function_format_info () init_function_format_info ()
{ {
record_function_format (get_identifier ("printf"), NULL_TREE, if (flag_hosted)
printf_format_type, 1, 2); {
record_function_format (get_identifier ("fprintf"), NULL_TREE, /* Functions from ISO/IEC 9899:1990. */
printf_format_type, 2, 3); record_function_format (get_identifier ("printf"), NULL_TREE,
record_function_format (get_identifier ("sprintf"), NULL_TREE, printf_format_type, 1, 2);
printf_format_type, 2, 3); record_function_format (get_identifier ("fprintf"), NULL_TREE,
record_function_format (get_identifier ("scanf"), NULL_TREE, printf_format_type, 2, 3);
scanf_format_type, 1, 2); record_function_format (get_identifier ("sprintf"), NULL_TREE,
record_function_format (get_identifier ("fscanf"), NULL_TREE, printf_format_type, 2, 3);
scanf_format_type, 2, 3); record_function_format (get_identifier ("scanf"), NULL_TREE,
record_function_format (get_identifier ("sscanf"), NULL_TREE, scanf_format_type, 1, 2);
scanf_format_type, 2, 3); record_function_format (get_identifier ("fscanf"), NULL_TREE,
record_function_format (get_identifier ("vprintf"), NULL_TREE, scanf_format_type, 2, 3);
printf_format_type, 1, 0); record_function_format (get_identifier ("sscanf"), NULL_TREE,
record_function_format (get_identifier ("vfprintf"), NULL_TREE, scanf_format_type, 2, 3);
printf_format_type, 2, 0); record_function_format (get_identifier ("vprintf"), NULL_TREE,
record_function_format (get_identifier ("vsprintf"), NULL_TREE, printf_format_type, 1, 0);
printf_format_type, 2, 0); record_function_format (get_identifier ("vfprintf"), NULL_TREE,
record_function_format (get_identifier ("strftime"), NULL_TREE, printf_format_type, 2, 0);
strftime_format_type, 3, 0); record_function_format (get_identifier ("vsprintf"), NULL_TREE,
printf_format_type, 2, 0);
if (flag_isoc99) record_function_format (get_identifier ("strftime"), NULL_TREE,
strftime_format_type, 3, 0);
}
if (flag_hosted && flag_isoc99)
{ {
/* ISO C99 adds the snprintf and vscanf family functions. */ /* ISO C99 adds the snprintf and vscanf family functions. */
record_function_format (get_identifier ("snprintf"), NULL_TREE, record_function_format (get_identifier ("snprintf"), NULL_TREE,
...@@ -1373,9 +1379,13 @@ init_function_format_info () ...@@ -1373,9 +1379,13 @@ init_function_format_info ()
scanf_format_type, 2, 0); scanf_format_type, 2, 0);
} }
record_international_format (get_identifier ("gettext"), NULL_TREE, 1); if (flag_hosted && flag_noniso_default_format_attributes)
record_international_format (get_identifier ("dgettext"), NULL_TREE, 2); {
record_international_format (get_identifier ("dcgettext"), NULL_TREE, 2); /* 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 /* Record information for argument format checking. FUNCTION_IDENT is
...@@ -1872,7 +1882,8 @@ check_format_info (info, params) ...@@ -1872,7 +1882,8 @@ check_format_info (info, params)
if (pedantic && !flag_isoc99) if (pedantic && !flag_isoc99)
warning ("ISO C89 does not support the `hh' length modifier"); 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' if (format_chars[1] == 's' || format_chars[1] == 'S'
|| format_chars[1] == '[') || format_chars[1] == '[')
......
...@@ -195,6 +195,15 @@ extern int flag_isoc99; ...@@ -195,6 +195,15 @@ extern int flag_isoc99;
extern int flag_digraphs; 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. */ /* Nonzero means warn about suggesting putting in ()'s. */
extern int warn_parentheses; extern int warn_parentheses;
......
...@@ -345,6 +345,11 @@ int flag_digraphs = 1; ...@@ -345,6 +345,11 @@ int flag_digraphs = 1;
int flag_hosted = 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 /* Nonzero means to allow single precision math even if we're generally
being traditional. */ being traditional. */
int flag_allow_single_precision = 0; int flag_allow_single_precision = 0;
...@@ -550,6 +555,7 @@ c_decode_option (argc, argv) ...@@ -550,6 +555,7 @@ c_decode_option (argc, argv)
flag_writable_strings = 0; flag_writable_strings = 0;
flag_no_asm = 1; flag_no_asm = 1;
flag_no_nonansi_builtin = 1; flag_no_nonansi_builtin = 1;
flag_noniso_default_format_attributes = 0;
flag_isoc99 = 0; flag_isoc99 = 0;
} }
else if (!strcmp (argstart, "iso9899:199409")) else if (!strcmp (argstart, "iso9899:199409"))
...@@ -567,6 +573,7 @@ c_decode_option (argc, argv) ...@@ -567,6 +573,7 @@ c_decode_option (argc, argv)
flag_writable_strings = 0; flag_writable_strings = 0;
flag_no_asm = 1; flag_no_asm = 1;
flag_no_nonansi_builtin = 1; flag_no_nonansi_builtin = 1;
flag_noniso_default_format_attributes = 0;
flag_isoc99 = 1; flag_isoc99 = 1;
flag_digraphs = 1; flag_digraphs = 1;
flag_isoc94 = 1; flag_isoc94 = 1;
...@@ -577,6 +584,7 @@ c_decode_option (argc, argv) ...@@ -577,6 +584,7 @@ c_decode_option (argc, argv)
flag_writable_strings = 0; flag_writable_strings = 0;
flag_no_asm = 0; flag_no_asm = 0;
flag_no_nonansi_builtin = 0; flag_no_nonansi_builtin = 0;
flag_noniso_default_format_attributes = 1;
flag_isoc99 = 0; flag_isoc99 = 0;
flag_digraphs = 1; flag_digraphs = 1;
flag_isoc94 = 0; flag_isoc94 = 0;
...@@ -587,6 +595,7 @@ c_decode_option (argc, argv) ...@@ -587,6 +595,7 @@ c_decode_option (argc, argv)
flag_writable_strings = 0; flag_writable_strings = 0;
flag_no_asm = 0; flag_no_asm = 0;
flag_no_nonansi_builtin = 0; flag_no_nonansi_builtin = 0;
flag_noniso_default_format_attributes = 1;
flag_isoc99 = 1; flag_isoc99 = 1;
flag_digraphs = 1; flag_digraphs = 1;
flag_isoc94 = 1; flag_isoc94 = 1;
......
...@@ -299,10 +299,6 @@ extern int flag_cond_mismatch; ...@@ -299,10 +299,6 @@ extern int flag_cond_mismatch;
extern int flag_no_asm; extern int flag_no_asm;
/* Nonzero means environment is hosted (i.e., not freestanding) */
extern int flag_hosted;
/* Nonzero means warn about implicit declarations. */ /* Nonzero means warn about implicit declarations. */
extern int warn_implicit; extern int warn_implicit;
......
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> 2000-08-21 Gabriel Dos Reis <gdr@codesourcery.com>
* lex.c (lang_init_options): Default diagnostic message maximum * lex.c (lang_init_options): Default diagnostic message maximum
......
...@@ -345,6 +345,15 @@ int flag_isoc94; ...@@ -345,6 +345,15 @@ int flag_isoc94;
int flag_isoc99; 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'. */ /* Nonzero means give `double' the same size as `float'. */
extern int flag_short_double; extern int flag_short_double;
......
...@@ -822,7 +822,7 @@ lang_decode_option (argc, argv) ...@@ -822,7 +822,7 @@ lang_decode_option (argc, argv)
} }
else if (!strcmp (p, "-ansi")) else if (!strcmp (p, "-ansi"))
flag_no_nonansi_builtin = 1, flag_ansi = 1, 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 #ifdef SPEW_DEBUG
/* Undocumented, only ever used when you're invoking cc1plus by hand, since /* 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 it's probably safe to assume no sane person would ever want to use this
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment