Commit b8458e3e by Joseph Myers Committed by Joseph Myers

c-common.h (flag_isoc94): Declare.

	* c-common.h (flag_isoc94): Declare.
	* c-decl.c (flag_isoc94): Define.
	(c_decode_option): Set flag_isoc94 as appropriate.
	* c-common.c (T_PD, T_IM, T_UIM): Define.
	(format_char_info): Add tlen and jlen.
	(print_char_table): Add entries for %t and %j.  Allow %zn.  Allow
	%F.  Allow %lf.
	(scan_char_table): Add entries for %t and %j.  Allow %F.  Allow
	%l[.
	(time_char_table): Add NULL entries for %t and %j.
	(check_format_info): Allow for %t and %j.  Warn for %F if pedantic
	and not C99.  Warn for %lc, %ls and %l[ if pedantic and not C94.
	Warn for printf %lf if pedantic and not C99.  Don't warn for empty
	precision.  Allow precision argument to be unsigned int.  If
	pedantic, warn for %p passed an argument not a pointer to possibly
	qualified void or a possibly qualified character type, and for
	pointer targets of the wrong sign, except for character pointers.

cp:
	* decl.c (flag_isoc94): New variable.

testsuite:
	* gcc.dg/c90-printf-1.c, gcc.dg/c94-printf-1.c: New tests.

From-SVN: r35482
parent c5ab7f91
2000-08-04 Joseph S. Myers <jsm28@cam.ac.uk> 2000-08-04 Joseph S. Myers <jsm28@cam.ac.uk>
* c-common.h (flag_isoc94): Declare.
* c-decl.c (flag_isoc94): Define.
(c_decode_option): Set flag_isoc94 as appropriate.
* c-common.c (T_PD, T_IM, T_UIM): Define.
(format_char_info): Add tlen and jlen.
(print_char_table): Add entries for %t and %j. Allow %zn. Allow
%F. Allow %lf.
(scan_char_table): Add entries for %t and %j. Allow %F. Allow
%l[.
(time_char_table): Add NULL entries for %t and %j.
(check_format_info): Allow for %t and %j. Warn for %F if pedantic
and not C99. Warn for %lc, %ls and %l[ if pedantic and not C94.
Warn for printf %lf if pedantic and not C99. Don't warn for empty
precision. Allow precision argument to be unsigned int. If
pedantic, warn for %p passed an argument not a pointer to possibly
qualified void or a possibly qualified character type, and for
pointer targets of the wrong sign, except for character pointers.
2000-08-04 Joseph S. Myers <jsm28@cam.ac.uk>
* ginclude/stddef.h: Don't declare wint_t unless __need_wint_t. * ginclude/stddef.h: Don't declare wint_t unless __need_wint_t.
* c-common.h (enum c_tree_index): Add CTI_WINT_TYPE. * c-common.h (enum c_tree_index): Add CTI_WINT_TYPE.
(wint_type_node): Define. (wint_type_node): Define.
......
...@@ -179,6 +179,10 @@ extern int warn_format; ...@@ -179,6 +179,10 @@ extern int warn_format;
extern int flag_traditional; extern int flag_traditional;
/* Nonzero means enable C89 Amendment 1 features, other than digraphs. */
extern int flag_isoc94;
/* Nonzero means use the ISO C99 dialect of C. */ /* Nonzero means use the ISO C99 dialect of C. */
extern int flag_isoc99; extern int flag_isoc99;
......
...@@ -330,6 +330,10 @@ int flag_no_nonansi_builtin; ...@@ -330,6 +330,10 @@ int flag_no_nonansi_builtin;
int flag_traditional; int flag_traditional;
/* Nonzero means enable C89 Amendment 1 features, other than digraphs. */
int flag_isoc94 = 0;
/* Nonzero means use the ISO C99 dialect of C. */ /* Nonzero means use the ISO C99 dialect of C. */
int flag_isoc99 = 0; int flag_isoc99 = 0;
...@@ -541,6 +545,7 @@ c_decode_option (argc, argv) ...@@ -541,6 +545,7 @@ c_decode_option (argc, argv)
{ {
iso_1990: iso_1990:
flag_digraphs = 0; flag_digraphs = 0;
flag_isoc94 = 0;
iso_1990_digraphs: iso_1990_digraphs:
flag_traditional = 0; flag_traditional = 0;
flag_writable_strings = 0; flag_writable_strings = 0;
...@@ -551,7 +556,7 @@ c_decode_option (argc, argv) ...@@ -551,7 +556,7 @@ c_decode_option (argc, argv)
else if (!strcmp (argstart, "iso9899:199409")) else if (!strcmp (argstart, "iso9899:199409"))
{ {
flag_digraphs = 1; flag_digraphs = 1;
/* ??? The other changes since ISO C 1990 are not supported. */ flag_isoc94 = 1;
goto iso_1990_digraphs; goto iso_1990_digraphs;
} }
else if (!strcmp (argstart, "iso9899:199x") else if (!strcmp (argstart, "iso9899:199x")
...@@ -565,6 +570,7 @@ c_decode_option (argc, argv) ...@@ -565,6 +570,7 @@ c_decode_option (argc, argv)
flag_no_nonansi_builtin = 1; flag_no_nonansi_builtin = 1;
flag_isoc99 = 1; flag_isoc99 = 1;
flag_digraphs = 1; flag_digraphs = 1;
flag_isoc94 = 1;
} }
else if (!strcmp (argstart, "gnu89")) else if (!strcmp (argstart, "gnu89"))
{ {
...@@ -574,6 +580,7 @@ c_decode_option (argc, argv) ...@@ -574,6 +580,7 @@ c_decode_option (argc, argv)
flag_no_nonansi_builtin = 0; flag_no_nonansi_builtin = 0;
flag_isoc99 = 0; flag_isoc99 = 0;
flag_digraphs = 1; flag_digraphs = 1;
flag_isoc94 = 0;
} }
else if (!strcmp (argstart, "gnu9x") || !strcmp (argstart, "gnu99")) else if (!strcmp (argstart, "gnu9x") || !strcmp (argstart, "gnu99"))
{ {
...@@ -583,6 +590,7 @@ c_decode_option (argc, argv) ...@@ -583,6 +590,7 @@ c_decode_option (argc, argv)
flag_no_nonansi_builtin = 0; flag_no_nonansi_builtin = 0;
flag_isoc99 = 1; flag_isoc99 = 1;
flag_digraphs = 1; flag_digraphs = 1;
flag_isoc94 = 1;
} }
else else
error ("unknown C standard `%s'", argstart); error ("unknown C standard `%s'", argstart);
......
2000-08-04 Joseph S. Myers <jsm28@cam.ac.uk>
* decl.c (flag_isoc94): New variable.
2000-08-02 Jason Merrill <jason@redhat.com> 2000-08-02 Jason Merrill <jason@redhat.com>
* pt.c (do_type_instantiation): Add complain parm; don't complain * pt.c (do_type_instantiation): Add complain parm; don't complain
......
...@@ -337,6 +337,10 @@ struct named_label_list ...@@ -337,6 +337,10 @@ struct named_label_list
tree current_function_return_value; tree current_function_return_value;
/* Nonzero means use the ISO C94 dialect of C. */
int flag_isoc94;
/* Nonzero means use the ISO C99 dialect of C. */ /* Nonzero means use the ISO C99 dialect of C. */
int flag_isoc99; int flag_isoc99;
......
2000-08-04 Joseph S. Myers <jsm28@cam.ac.uk>
* gcc.dg/c90-printf-1.c, gcc.dg/c94-printf-1.c: New tests.
2000-08-03 Zack Weinberg <zack@wolery.cumb.org> 2000-08-03 Zack Weinberg <zack@wolery.cumb.org>
* gcc.dg/cpp/20000625-2.c: Don't expect a warning on line 4. * gcc.dg/cpp/20000625-2.c: Don't expect a warning on line 4.
......
/* Test for printf formats. Changes in C94 to C90. */
/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
/* { dg-do compile } */
/* { dg-options "-std=iso9899:199409 -pedantic -Wformat" } */
typedef __WCHAR_TYPE__ wchar_t;
#ifndef __WINT_TYPE__
#define __WINT_TYPE__ unsigned int
#endif
typedef __WINT_TYPE__ wint_t;
extern int printf (const char *, ...);
void
foo (wint_t lc, wchar_t *ls)
{
/* See ISO/IEC 9899:1990 (E) subclause 7.9.6.1 (pages 131-134),
as amended by ISO/IEC 9899:1990/Amd.1:1995 (E) (pages 4-5).
We do not repeat here all the C90 format checks, but just verify
that %ls and %lc are accepted without warning.
*/
printf ("%lc", lc);
printf ("%ls", ls);
}
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