aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Myers <jsm28@cam.ac.uk>2000-08-21 15:30:38 +0100
committerJoseph Myers <jsm28@gcc.gnu.org>2000-08-21 15:30:38 +0100
commit93e2382f2cf48b874a5f2ff6359f134878498b69 (patch)
treecbd1a1410505f0820a83aa92687d31f4e159e3d8
parentf3d360aad1dbc188c0f0bbe7d44a32bdb20cd62c (diff)
downloadgcc-93e2382f2cf48b874a5f2ff6359f134878498b69.zip
gcc-93e2382f2cf48b874a5f2ff6359f134878498b69.tar.gz
gcc-93e2382f2cf48b874a5f2ff6359f134878498b69.tar.bz2
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
-rw-r--r--gcc/ChangeLog15
-rw-r--r--gcc/c-common.c69
-rw-r--r--gcc/c-common.h9
-rw-r--r--gcc/c-decl.c9
-rw-r--r--gcc/c-tree.h4
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/decl.c9
-rw-r--r--gcc/cp/decl2.c2
8 files changed, 90 insertions, 34 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b95fbcd..5f289b4 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,20 @@
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
except 'n'.
(check_format_info): Set 'wide' for scanf format widths. Warn for
diff --git a/gcc/c-common.c b/gcc/c-common.c
index e9c84f9..c0b9816 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -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_isoc99)
+ 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_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] == '[')
diff --git a/gcc/c-common.h b/gcc/c-common.h
index 50823df..0fc84a5 100644
--- a/gcc/c-common.h
+++ b/gcc/c-common.h
@@ -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;
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 48e842e..c9afb28 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -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;
diff --git a/gcc/c-tree.h b/gcc/c-tree.h
index 3af50a4..f3ad275 100644
--- a/gcc/c-tree.h
+++ b/gcc/c-tree.h
@@ -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;
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 55f3111..98fb669 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index c8599fa..d9e2e98 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -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;
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index c45a272..31e42ae 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -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