c-common.h (GCC_DIAG_STYLE): Define.

* c-common.h (GCC_DIAG_STYLE): Define.
	* c-tree.h (GCC_DIAG_STYLE): Do not define.  Change minimum GCC
	version for format checking to 4.1.
	* c-format.c: Include toplev.h after c-common.h.
	(enum format_type): Add gcc_tdiag_format_type.
	(gcc_tdiag_length_specs, gcc_tdiag_flag_pairs,
	gcc_tdiag_flag_specs, gcc_tdiag_char_table): New.
	(format_types_orig): Add gcc_tdiag.
	(init_dynamic_diag_info): Support gcc_tdiag formats.
	(handle_format_attribute): Likewise.
	* toplev.h (NO_FRONT_END_DIAG, ATTRIBUTE_GCC_FE_DIAG): Remove.
	(GCC_DIAG_STYLE): Default to __gcc_tdiag__.  Change minimum GCC
	version for format checking to 4.1.
	(warning0, warning, error, pedwarn, sorry): Use
	ATTRIBUTE_GCC_DIAG.
	* config/rs6000/rs6000.c (altivec_expand_builtin), varasm.c
	(finish_aliases_1): Do not use %qE.
	* config/arm/arm.c, config/i386/i386.c, config/mmix/mmix.c,
	config/pdp11/pdp11.c, stor-layout.c, tree-eh.c, tree-ssa.c:
	Correct format bugs.
	* config/v850/v850-protos.h (v850_output_aligned_bss): Change size
	parameter to unsigned HOST_WIDE_INT.
	* config/v850/v850.c (v850_output_aligned_bss): Likewise.

cp:
	* cp-tree.h (GCC_DIAG_STYLE): #undef before defining.  Change
	minimum GCC version for format checking to 4.1.

testsuite:
	* gcc.dg/format/gcc_diag-1.c: Update.

From-SVN: r101543
This commit is contained in:
Joseph Myers 2005-07-03 01:38:49 +01:00 committed by Joseph Myers
parent 3be91f6470
commit ea40ba9c04
20 changed files with 182 additions and 42 deletions

View File

@ -1,3 +1,29 @@
2005-07-03 Joseph S. Myers <joseph@codesourcery.com>
* c-common.h (GCC_DIAG_STYLE): Define.
* c-tree.h (GCC_DIAG_STYLE): Do not define. Change minimum GCC
version for format checking to 4.1.
* c-format.c: Include toplev.h after c-common.h.
(enum format_type): Add gcc_tdiag_format_type.
(gcc_tdiag_length_specs, gcc_tdiag_flag_pairs,
gcc_tdiag_flag_specs, gcc_tdiag_char_table): New.
(format_types_orig): Add gcc_tdiag.
(init_dynamic_diag_info): Support gcc_tdiag formats.
(handle_format_attribute): Likewise.
* toplev.h (NO_FRONT_END_DIAG, ATTRIBUTE_GCC_FE_DIAG): Remove.
(GCC_DIAG_STYLE): Default to __gcc_tdiag__. Change minimum GCC
version for format checking to 4.1.
(warning0, warning, error, pedwarn, sorry): Use
ATTRIBUTE_GCC_DIAG.
* config/rs6000/rs6000.c (altivec_expand_builtin), varasm.c
(finish_aliases_1): Do not use %qE.
* config/arm/arm.c, config/i386/i386.c, config/mmix/mmix.c,
config/pdp11/pdp11.c, stor-layout.c, tree-eh.c, tree-ssa.c:
Correct format bugs.
* config/v850/v850-protos.h (v850_output_aligned_bss): Change size
parameter to unsigned HOST_WIDE_INT.
* config/v850/v850.c (v850_output_aligned_bss): Likewise.
2005-07-02 David Edelsohn <edelsohn@gnu.org>
PR middle-end/21742

View File

@ -926,4 +926,13 @@ extern void preprocess_file (cpp_reader *);
extern void pp_file_change (const struct line_map *);
extern void pp_dir_change (cpp_reader *, const char *);
/* In order for the format checking to accept the C frontend
diagnostic framework extensions, you must include this file before
toplev.h, not after. The C front end formats are a subset of those
for C++, so they are the appropriate set to use in common code;
cp-tree.h overrides this for C++. */
#ifndef GCC_DIAG_STYLE
#define GCC_DIAG_STYLE __gcc_cdiag__
#endif
#endif /* ! GCC_C_COMMON_H */

View File

@ -25,8 +25,8 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
#include "tm.h"
#include "tree.h"
#include "flags.h"
#include "toplev.h"
#include "c-common.h"
#include "toplev.h"
#include "intl.h"
#include "diagnostic.h"
#include "langhooks.h"
@ -58,7 +58,8 @@ set_Wformat (int setting)
format_type_error. Target-specific format types do not have
matching enum values. */
enum format_type { printf_format_type, asm_fprintf_format_type,
gcc_diag_format_type, gcc_cdiag_format_type,
gcc_diag_format_type, gcc_tdiag_format_type,
gcc_cdiag_format_type,
gcc_cxxdiag_format_type,
scanf_format_type, strftime_format_type,
strfmon_format_type, format_type_error = -1};
@ -310,6 +311,7 @@ static const format_length_info gcc_diag_length_specs[] =
};
/* The custom diagnostics all accept the same length specifiers. */
#define gcc_tdiag_length_specs gcc_diag_length_specs
#define gcc_cdiag_length_specs gcc_diag_length_specs
#define gcc_cxxdiag_length_specs gcc_diag_length_specs
@ -386,6 +388,7 @@ static const format_flag_pair gcc_diag_flag_pairs[] =
{ 0, 0, 0, 0 }
};
#define gcc_tdiag_flag_pairs gcc_diag_flag_pairs
#define gcc_cdiag_flag_pairs gcc_diag_flag_pairs
#define gcc_cxxdiag_flag_pairs gcc_diag_flag_pairs
@ -398,6 +401,7 @@ static const format_flag_spec gcc_diag_flag_specs[] =
{ 0, 0, 0, NULL, NULL, 0 }
};
#define gcc_tdiag_flag_specs gcc_diag_flag_specs
#define gcc_cdiag_flag_specs gcc_diag_flag_specs
static const format_flag_spec gcc_cxxdiag_flag_specs[] =
@ -543,6 +547,29 @@ static const format_char_info gcc_diag_char_table[] =
{ NULL, 0, 0, NOLENGTHS, NULL, NULL, NULL }
};
static const format_char_info gcc_tdiag_char_table[] =
{
/* C89 conversion specifiers. */
{ "di", 0, STD_C89, { T89_I, BADLEN, BADLEN, T89_L, T9L_LL, BADLEN, BADLEN, BADLEN, BADLEN }, "q", "", NULL },
{ "ox", 0, STD_C89, { T89_UI, BADLEN, BADLEN, T89_UL, T9L_ULL, BADLEN, BADLEN, BADLEN, BADLEN }, "q", "", NULL },
{ "u", 0, STD_C89, { T89_UI, BADLEN, BADLEN, T89_UL, T9L_ULL, BADLEN, BADLEN, BADLEN, BADLEN }, "q", "", NULL },
{ "c", 0, STD_C89, { T89_I, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q", "", NULL },
{ "s", 1, STD_C89, { T89_C, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "pq", "cR", NULL },
{ "p", 1, STD_C89, { T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q", "c", NULL },
/* Custom conversion specifiers. */
/* %H will require "location_t" at runtime. */
{ "H", 0, STD_C89, { T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q", "", NULL },
/* These will require a "tree" at runtime. */
{ "DFJT", 0, STD_C89, { T89_V, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "q+", "", NULL },
{ "<>'", 0, STD_C89, NOARGUMENTS, "", "", NULL },
{ "m", 0, STD_C89, NOARGUMENTS, "q", "", NULL },
{ NULL, 0, 0, NOLENGTHS, NULL, NULL, NULL }
};
static const format_char_info gcc_cdiag_char_table[] =
{
/* C89 conversion specifiers. */
@ -666,6 +693,12 @@ static const format_kind_info format_types_orig[] =
0, 0, 'p', 0, 'L',
NULL, &integer_type_node
},
{ "gcc_tdiag", gcc_tdiag_length_specs, gcc_tdiag_char_table, "q+", NULL,
gcc_tdiag_flag_specs, gcc_tdiag_flag_pairs,
FMT_FLAG_ARG_CONVERT,
0, 0, 'p', 0, 'L',
NULL, &integer_type_node
},
{ "gcc_cdiag", gcc_cdiag_length_specs, gcc_cdiag_char_table, "q+", NULL,
gcc_cdiag_flag_specs, gcc_cdiag_flag_pairs,
FMT_FLAG_ARG_CONVERT,
@ -2360,7 +2393,7 @@ init_dynamic_diag_info (void)
if (!loc || !t || !hwi)
{
static format_char_info *diag_fci, *cdiag_fci, *cxxdiag_fci;
static format_char_info *diag_fci, *tdiag_fci, *cdiag_fci, *cxxdiag_fci;
static format_length_info *diag_ls;
unsigned int i;
@ -2441,6 +2474,7 @@ init_dynamic_diag_info (void)
/* All the GCC diag formats use the same length specs. */
if (!diag_ls)
dynamic_format_types[gcc_diag_format_type].length_char_specs =
dynamic_format_types[gcc_tdiag_format_type].length_char_specs =
dynamic_format_types[gcc_cdiag_format_type].length_char_specs =
dynamic_format_types[gcc_cxxdiag_format_type].length_char_specs =
diag_ls = (format_length_info *)
@ -2479,6 +2513,30 @@ init_dynamic_diag_info (void)
diag_fci[i].pointer_count = 1;
}
/* Handle the __gcc_tdiag__ format specifics. */
if (!tdiag_fci)
dynamic_format_types[gcc_tdiag_format_type].conversion_specs =
tdiag_fci = (format_char_info *)
xmemdup (gcc_tdiag_char_table,
sizeof (gcc_tdiag_char_table),
sizeof (gcc_tdiag_char_table));
if (loc)
{
i = find_char_info_specifier_index (tdiag_fci, 'H');
tdiag_fci[i].types[0].type = &loc;
tdiag_fci[i].pointer_count = 1;
}
if (t)
{
/* All specifiers taking a tree share the same struct. */
i = find_char_info_specifier_index (tdiag_fci, 'D');
tdiag_fci[i].types[0].type = &t;
tdiag_fci[i].pointer_count = 1;
i = find_char_info_specifier_index (tdiag_fci, 'J');
tdiag_fci[i].types[0].type = &t;
tdiag_fci[i].pointer_count = 1;
}
/* Handle the __gcc_cdiag__ format specifics. */
if (!cdiag_fci)
dynamic_format_types[gcc_cdiag_format_type].conversion_specs =
@ -2603,6 +2661,7 @@ handle_format_attribute (tree *node, tree ARG_UNUSED (name), tree args,
initialize certain bits a runtime. */
if (info.format_type == asm_fprintf_format_type
|| info.format_type == gcc_diag_format_type
|| info.format_type == gcc_tdiag_format_type
|| info.format_type == gcc_cdiag_format_type
|| info.format_type == gcc_cxxdiag_format_type)
{
@ -2620,6 +2679,7 @@ handle_format_attribute (tree *node, tree ARG_UNUSED (name), tree args,
/* If this is one of the diagnostic attributes, then we have to
initialize 'location_t' and 'tree' at runtime. */
else if (info.format_type == gcc_diag_format_type
|| info.format_type == gcc_tdiag_format_type
|| info.format_type == gcc_cdiag_format_type
|| info.format_type == gcc_cxxdiag_format_type)
init_dynamic_diag_info ();

View File

@ -608,8 +608,7 @@ extern void c_write_global_declarations (void);
/* In order for the format checking to accept the C frontend
diagnostic framework extensions, you must include this file before
toplev.h, not after. */
#define GCC_DIAG_STYLE __gcc_cdiag__
#if GCC_VERSION >= 3005
#if GCC_VERSION >= 4001
#define ATTRIBUTE_GCC_CDIAG(m, n) __attribute__ ((__format__ (GCC_DIAG_STYLE, m ,n))) ATTRIBUTE_NONNULL(m)
#else
#define ATTRIBUTE_GCC_CDIAG(m, n) ATTRIBUTE_NONNULL(m)

View File

@ -14750,7 +14750,7 @@ arm_unwind_emit_stm (FILE * asm_out_file, rtx p)
else if (reg >= FIRST_FPA_REGNUM && reg <= LAST_FPA_REGNUM)
{
/* FPA registers are done differently. */
asm_fprintf (asm_out_file, "\t.save %r, %d\n", reg, nregs);
asm_fprintf (asm_out_file, "\t.save %r, %wd\n", reg, nregs);
return;
}
else
@ -14848,7 +14848,7 @@ arm_unwind_emit_set (FILE * asm_out_file, rtx p)
|| GET_CODE (XEXP (e1, 1)) != CONST_INT)
abort ();
asm_fprintf (asm_out_file, "\t.pad #%d\n",
asm_fprintf (asm_out_file, "\t.pad #%wd\n",
-INTVAL (XEXP (e1, 1)));
}
else if (REGNO (e0) == HARD_FRAME_POINTER_REGNUM)
@ -14863,7 +14863,7 @@ arm_unwind_emit_set (FILE * asm_out_file, rtx p)
abort ();
reg = REGNO (XEXP (e1, 0));
offset = INTVAL (XEXP (e1, 1));
asm_fprintf (asm_out_file, "\t.setfp %r, %r, #%d\n",
asm_fprintf (asm_out_file, "\t.setfp %r, %r, #%wd\n",
HARD_FRAME_POINTER_REGNUM, reg,
INTVAL (XEXP (e1, 1)));
}

View File

@ -14659,7 +14659,7 @@ get_element_number (tree vec_type, tree arg)
if (!host_integerp (arg, 1)
|| (elt = tree_low_cst (arg, 1), elt > max))
{
error ("selector must be an integer constant in the range 0..%i", max);
error ("selector must be an integer constant in the range 0..%wi", max);
return 0;
}

View File

@ -1891,7 +1891,7 @@ mmix_expand_prologue (void)
/* Make sure we don't get an unaligned stack. */
if ((stack_space_to_allocate % 8) != 0)
internal_error ("stack frame not a multiple of 8 bytes: %d",
internal_error ("stack frame not a multiple of 8 bytes: %wd",
stack_space_to_allocate);
if (current_function_pretend_args_size)
@ -2127,7 +2127,7 @@ mmix_expand_epilogue (void)
/* Make sure we don't get an unaligned stack. */
if ((stack_space_to_deallocate % 8) != 0)
internal_error ("stack frame not a multiple of octabyte: %d",
internal_error ("stack frame not a multiple of octabyte: %wd",
stack_space_to_deallocate);
/* We will add back small offsets to the stack pointer as we go.

View File

@ -245,7 +245,7 @@ pdp11_output_function_prologue (FILE *stream, HOST_WIDE_INT size)
{
fprintf (stream, "\t/*abuse empty parameter slot for locals!*/\n");
if (size > 2)
fprintf(stream, "\tsub $%#o, sp\n", size - 2);
asm_fprintf (stream, "\tsub $%#wo, sp\n", size - 2);
}
}
@ -285,7 +285,7 @@ pdp11_output_function_prologue (FILE *stream, HOST_WIDE_INT size)
/* make frame */
if (fsize)
fprintf (stream, "\tsub $%#o, sp\n", fsize);
asm_fprintf (stream, "\tsub $%#wo, sp\n", fsize);
/* save CPU registers */
for (regno = 0; regno < 8; regno++)

View File

@ -6826,7 +6826,7 @@ altivec_expand_builtin (tree exp, rtx target, bool *expandedp)
&& fcode <= ALTIVEC_BUILTIN_OVERLOADED_LAST)
{
*expandedp = true;
error ("unresolved overload for Altivec builtin %qE", fndecl);
error ("unresolved overload for Altivec builtin %qF", fndecl);
return const0_rtx;
}

View File

@ -61,7 +61,7 @@ extern rtx function_arg (CUMULATIVE_ARGS *, Mmode, tree, int
#ifdef TREE_CODE
extern int v850_interrupt_function_p (tree);
extern void v850_output_aligned_bss (FILE *, tree, const char *, int, int);
extern void v850_output_aligned_bss (FILE *, tree, const char *, unsigned HOST_WIDE_INT, int);
extern void v850_output_common (FILE *, tree, const char *, int, int);
extern void v850_output_local (FILE *, tree, const char *, int, int);
extern v850_data_area v850_get_data_area (tree);

View File

@ -2485,7 +2485,7 @@ void
v850_output_aligned_bss (FILE * file,
tree decl,
const char * name,
int size,
unsigned HOST_WIDE_INT size,
int align)
{
switch (v850_get_data_area (decl))

View File

@ -1,3 +1,8 @@
2005-07-03 Joseph S. Myers <joseph@codesourcery.com>
* cp-tree.h (GCC_DIAG_STYLE): #undef before defining. Change
minimum GCC version for format checking to 4.1.
2005-07-02 Kazu Hirata <kazu@codesourcery.com>
* Make-lang.in (cc1plus-checksum.c): Use

View File

@ -4367,9 +4367,11 @@ extern void cp_genericize (tree);
/* In order for the format checking to accept the C++ frontend
diagnostic framework extensions, you must include this file before
toplev.h, not after. */
toplev.h, not after. We override the definition of GCC_DIAG_STYLE
in c-common.h. */
#undef GCC_DIAG_STYLE
#define GCC_DIAG_STYLE __gcc_cxxdiag__
#if GCC_VERSION >= 3004
#if GCC_VERSION >= 4001
#define ATTRIBUTE_GCC_CXXDIAG(m, n) __attribute__ ((__format__ (GCC_DIAG_STYLE, m, n))) ATTRIBUTE_NONNULL(m)
#else
#define ATTRIBUTE_GCC_CXXDIAG(m, n) ATTRIBUTE_NONNULL(m)

View File

@ -30,6 +30,7 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
#include "flags.h"
#include "function.h"
#include "expr.h"
#include "output.h"
#include "toplev.h"
#include "ggc.h"
#include "target.h"
@ -453,7 +454,7 @@ layout_decl (tree decl, unsigned int known_align)
if (compare_tree_int (size, size_as_int) == 0)
warning (0, "size of %q+D is %d bytes", decl, size_as_int);
else
warning (0, "size of %q+D is larger than %d bytes",
warning (0, "size of %q+D is larger than %wd bytes",
decl, larger_than_size);
}
}

View File

@ -1,3 +1,7 @@
2005-07-03 Joseph S. Myers <joseph@codesourcery.com>
* gcc.dg/format/gcc_diag-1.c: Update.
2005-07-02 Jeff Law <law@redhat.com>
* gcc.dg/tree-ssa/pr22051-1.c: New test.

View File

@ -21,6 +21,7 @@ union tree_node;
typedef union tree_node *tree;
extern int diag (const char *, ...) ATTRIBUTE_DIAG(__gcc_diag__);
extern int tdiag (const char *, ...) ATTRIBUTE_DIAG(__gcc_tdiag__);
extern int cdiag (const char *, ...) ATTRIBUTE_DIAG(__gcc_cdiag__);
extern int cxxdiag (const char *, ...) ATTRIBUTE_DIAG(__gcc_cxxdiag__);
@ -35,42 +36,57 @@ foo (int i, int i1, int i2, unsigned int u, double d, char *s, void *p,
{
/* Acceptable C90 specifiers, flags and modifiers. */
diag ("%%");
tdiag ("%%");
cdiag ("%%");
cxxdiag ("%%");
diag ("%d%i%o%u%x%c%s%p%%", i, i, u, u, u, i, s, p);
tdiag ("%d%i%o%u%x%c%s%p%%", i, i, u, u, u, i, s, p);
cdiag ("%d%i%o%u%x%c%s%p%%", i, i, u, u, u, i, s, p);
cxxdiag ("%d%i%o%u%x%c%s%p%%", i, i, u, u, u, i, s, p);
diag ("%qd%qi%qo%qu%qx%qc%qs%qp%<%%%'%>", i, i, u, u, u, i, s, p);
tdiag ("%qd%qi%qo%qu%qx%qc%qs%qp%<%%%'%>", i, i, u, u, u, i, s, p);
cdiag ("%qd%qi%qo%qu%qx%qc%qs%qp%<%%%'%>", i, i, u, u, u, i, s, p);
cxxdiag ("%qd%qi%qo%qu%qx%qc%qs%qp%<%%%'%>", i, i, u, u, u, i, s, p);
diag ("%ld%li%lo%lu%lx", l, l, ul, ul, ul);
tdiag ("%ld%li%lo%lu%lx", l, l, ul, ul, ul);
cdiag ("%ld%li%lo%lu%lx", l, l, ul, ul, ul);
cxxdiag ("%ld%li%lo%lu%lx", l, l, ul, ul, ul);
diag ("%lld%lli%llo%llu%llx", ll, ll, ull, ull, ull);
tdiag ("%lld%lli%llo%llu%llx", ll, ll, ull, ull, ull);
cdiag ("%lld%lli%llo%llu%llx", ll, ll, ull, ull, ull);
cxxdiag ("%lld%lli%llo%llu%llx", ll, ll, ull, ull, ull);
diag ("%wd%wi%wo%wu%wx", ll, ll, ull, ull, ull);
tdiag ("%wd%wi%wo%wu%wx", ll, ll, ull, ull, ull);
cdiag ("%wd%wi%wo%wu%wx", ll, ll, ull, ull, ull);
cxxdiag ("%wd%wi%wo%wu%wx", ll, ll, ull, ull, ull);
diag ("%.*s", i, s);
tdiag ("%.*s", i, s);
cdiag ("%.*s", i, s);
cxxdiag ("%.*s", i, s);
/* Extensions provided in the diagnostic framework. */
diag ("%m");
tdiag ("%m");
cdiag ("%m");
cxxdiag ("%m");
diag ("%H", loc);
tdiag ("%H", loc);
cdiag ("%H", loc);
cxxdiag ("%H", loc);
diag ("%J", t1);
tdiag ("%J", t1);
cdiag ("%J", t1);
cxxdiag ("%J", t1);
tdiag ("%D%F%T", t1, t1, t1);
tdiag ("%+D%+F%+T", t1, t1, t1);
tdiag ("%q+D%q+F%q+T", t1, t1, t1);
tdiag ("%D%D%D%D", t1, t2, *t3, t4[5]);
cdiag ("%D%F%T", t1, t1, t1);
cdiag ("%+D%+F%+T", t1, t1, t1);
cdiag ("%q+D%q+F%q+T", t1, t1, t1);
cdiag ("%D%D%D%D", t1, t2, *t3, t4[5]);
cdiag ("%E", t1);
cxxdiag ("%A%D%E%F%T%V", t1, t1, t1, t1, t1, t1);
cxxdiag ("%D%D%D%D", t1, t2, *t3, t4[5]);
cxxdiag ("%#A%#D%#E%#F%#T%#V", t1, t1, t1, t1, t1, t1);
@ -80,36 +96,49 @@ foo (int i, int i1, int i2, unsigned int u, double d, char *s, void *p,
/* Bad stuff with extensions. */
diag ("%m", i); /* { dg-warning "format" "extra arg" } */
tdiag ("%m", i); /* { dg-warning "format" "extra arg" } */
cdiag ("%m", i); /* { dg-warning "format" "extra arg" } */
cxxdiag ("%m", i); /* { dg-warning "format" "extra arg" } */
diag ("%#m"); /* { dg-warning "format" "bogus modifier" } */
tdiag ("%#m"); /* { dg-warning "format" "bogus modifier" } */
cdiag ("%#m"); /* { dg-warning "format" "bogus modifier" } */
cxxdiag ("%#m"); /* { dg-warning "format" "bogus modifier" } */
diag ("%+m"); /* { dg-warning "format" "bogus modifier" } */
tdiag ("%+m"); /* { dg-warning "format" "bogus modifier" } */
cdiag ("%+m"); /* { dg-warning "format" "bogus modifier" } */
cxxdiag ("%+m"); /* { dg-warning "format" "bogus modifier" } */
diag ("%H"); /* { dg-warning "format" "missing arg" } */
tdiag ("%H"); /* { dg-warning "format" "missing arg" } */
cdiag ("%H"); /* { dg-warning "format" "missing arg" } */
cxxdiag ("%H"); /* { dg-warning "format" "missing arg" } */
diag ("%J"); /* { dg-warning "format" "missing arg" } */
tdiag ("%J"); /* { dg-warning "format" "missing arg" } */
cdiag ("%J"); /* { dg-warning "format" "missing arg" } */
cxxdiag ("%J"); /* { dg-warning "format" "missing arg" } */
diag ("%H", i); /* { dg-warning "format" "wrong arg" } */
tdiag ("%H", i); /* { dg-warning "format" "wrong arg" } */
cdiag ("%H", i); /* { dg-warning "format" "wrong arg" } */
cxxdiag ("%H", i); /* { dg-warning "format" "wrong arg" } */
diag ("%H", p); /* { dg-warning "format" "wrong arg" } */
tdiag ("%H", p); /* { dg-warning "format" "wrong arg" } */
cdiag ("%H", p); /* { dg-warning "format" "wrong arg" } */
cxxdiag ("%H", p); /* { dg-warning "format" "wrong arg" } */
diag ("%J", loc); /* { dg-warning "format" "wrong arg" } */
tdiag ("%J", loc); /* { dg-warning "format" "wrong arg" } */
cdiag ("%J", loc); /* { dg-warning "format" "wrong arg" } */
cxxdiag ("%J", loc); /* { dg-warning "format" "wrong arg" } */
diag ("%#H", loc); /* { dg-warning "format" "bogus modifier" } */
tdiag ("%#H", loc); /* { dg-warning "format" "bogus modifier" } */
cdiag ("%#H", loc); /* { dg-warning "format" "bogus modifier" } */
cxxdiag ("%#H", loc); /* { dg-warning "format" "bogus modifier" } */
diag ("%+H", loc); /* { dg-warning "format" "bogus modifier" } */
tdiag ("%+H", loc); /* { dg-warning "format" "bogus modifier" } */
cdiag ("%+H", loc); /* { dg-warning "format" "bogus modifier" } */
cxxdiag ("%+H", loc); /* { dg-warning "format" "bogus modifier" } */
diag ("%D", t1); /* { dg-warning "format" "bogus tree" } */
tdiag ("%A", t1); /* { dg-warning "format" "bogus tree" } */
tdiag ("%E", t1); /* { dg-warning "format" "bogus tree" } */
tdiag ("%#D", t1); /* { dg-warning "format" "bogus modifier" } */
cdiag ("%A", t1); /* { dg-warning "format" "bogus tree" } */
cdiag ("%#D", t1); /* { dg-warning "format" "bogus modifier" } */
cdiag ("%+D", t1);
@ -118,10 +147,13 @@ foo (int i, int i1, int i2, unsigned int u, double d, char *s, void *p,
cxxdiag ("%C", i, i); /* { dg-warning "format" "extra arg" } */
cxxdiag ("%#C", i); /* { dg-warning "format" "bogus modifier" } */
cxxdiag ("%+C", i); /* { dg-warning "format" "bogus modifier" } */
tdiag ("%D"); /* { dg-warning "format" "missing arg" } */
cdiag ("%D"); /* { dg-warning "format" "missing arg" } */
cxxdiag ("%D"); /* { dg-warning "format" "missing arg" } */
tdiag ("%D", i); /* { dg-warning "format" "wrong arg" } */
cdiag ("%D", i); /* { dg-warning "format" "wrong arg" } */
cxxdiag ("%D", i); /* { dg-warning "format" "wrong arg" } */
tdiag ("%D", t1, t1); /* { dg-warning "format" "extra arg" } */
cdiag ("%D", t1, t1); /* { dg-warning "format" "extra arg" } */
cxxdiag ("%D", t1, t1); /* { dg-warning "format" "extra arg" } */
@ -137,36 +169,47 @@ foo (int i, int i1, int i2, unsigned int u, double d, char *s, void *p,
/* Various tests of bad argument types. */
diag ("%-d", i); /* { dg-warning "format" "bad flag" } */
tdiag ("%-d", i); /* { dg-warning "format" "bad flag" } */
cdiag ("%-d", i); /* { dg-warning "format" "bad flag" } */
cxxdiag ("%-d", i); /* { dg-warning "format" "bad flag" } */
diag ("% d", i); /* { dg-warning "format" "bad flag" } */
tdiag ("% d", i); /* { dg-warning "format" "bad flag" } */
cdiag ("% d", i); /* { dg-warning "format" "bad flag" } */
cxxdiag ("% d", i); /* { dg-warning "format" "bad flag" } */
diag ("%#o", u); /* { dg-warning "format" "bad flag" } */
tdiag ("%#o", u); /* { dg-warning "format" "bad flag" } */
cdiag ("%#o", u); /* { dg-warning "format" "bad flag" } */
cxxdiag ("%#o", u); /* { dg-warning "format" "bad flag" } */
diag ("%0d", i); /* { dg-warning "format" "bad flag" } */
tdiag ("%0d", i); /* { dg-warning "format" "bad flag" } */
cdiag ("%0d", i); /* { dg-warning "format" "bad flag" } */
cxxdiag ("%0d", i); /* { dg-warning "format" "bad flag" } */
diag ("%08d", i); /* { dg-warning "format" "bad flag" } */
tdiag ("%08d", i); /* { dg-warning "format" "bad flag" } */
cdiag ("%08d", i); /* { dg-warning "format" "bad flag" } */
cxxdiag ("%08d", i); /* { dg-warning "format" "bad flag" } */
diag ("%+d\n", i); /* { dg-warning "format" "bad flag" } */
tdiag ("%+d\n", i); /* { dg-warning "format" "bad flag" } */
cdiag ("%+d\n", i); /* { dg-warning "format" "bad flag" } */
cxxdiag ("%+d\n", i); /* { dg-warning "format" "bad flag" } */
diag ("%3d\n", i); /* { dg-warning "format" "bad flag" } */
tdiag ("%3d\n", i); /* { dg-warning "format" "bad flag" } */
cdiag ("%3d\n", i); /* { dg-warning "format" "bad flag" } */
cxxdiag ("%3d\n", i); /* { dg-warning "format" "bad flag" } */
diag ("%-3d\n", i); /* { dg-warning "format" "bad flag" } */
tdiag ("%-3d\n", i); /* { dg-warning "format" "bad flag" } */
cdiag ("%-3d\n", i); /* { dg-warning "format" "bad flag" } */
cxxdiag ("%-3d\n", i); /* { dg-warning "format" "bad flag" } */
diag ("%.7d\n", i); /* { dg-warning "format" "bad flag" } */
tdiag ("%.7d\n", i); /* { dg-warning "format" "bad flag" } */
cdiag ("%.7d\n", i); /* { dg-warning "format" "bad flag" } */
cxxdiag ("%.7d\n", i); /* { dg-warning "format" "bad flag" } */
diag ("%+9.4d\n", i); /* { dg-warning "format" "bad flag" } */
tdiag ("%+9.4d\n", i); /* { dg-warning "format" "bad flag" } */
cdiag ("%+9.4d\n", i); /* { dg-warning "format" "bad flag" } */
cxxdiag ("%+9.4d\n", i); /* { dg-warning "format" "bad flag" } */
diag ("%.3ld\n", l); /* { dg-warning "format" "bad flag" } */
tdiag ("%.3ld\n", l); /* { dg-warning "format" "bad flag" } */
cdiag ("%.3ld\n", l); /* { dg-warning "format" "bad flag" } */
cxxdiag ("%.3ld\n", l); /* { dg-warning "format" "bad flag" } */
diag ("%d %lu\n", i, ul);

View File

@ -44,34 +44,25 @@ extern void _fatal_insn (const char *, rtx, const char *, int, const char *)
/* If we haven't already defined a frontend specific diagnostics
style, use the generic one. */
#ifndef GCC_DIAG_STYLE
#define GCC_DIAG_STYLE __gcc_diag__
#define NO_FRONT_END_DIAG
#define GCC_DIAG_STYLE __gcc_tdiag__
#endif
/* None of these functions are suitable for ATTRIBUTE_PRINTF, because
each language front end can extend them with its own set of format
specifiers. We must use custom format checks. Note that at present
the front-end %D specifier is used in non-front-end code with some
functions, and those formats can only be checked in front-end code. */
#if GCC_VERSION >= 3005
specifiers. We must use custom format checks. */
#if GCC_VERSION >= 4001
#define ATTRIBUTE_GCC_DIAG(m, n) __attribute__ ((__format__ (GCC_DIAG_STYLE, m, n))) ATTRIBUTE_NONNULL(m)
#ifdef NO_FRONT_END_DIAG
#define ATTRIBUTE_GCC_FE_DIAG(m, n) ATTRIBUTE_NONNULL(m)
#else
#define ATTRIBUTE_GCC_FE_DIAG(m, n) __attribute__ ((__format__ (GCC_DIAG_STYLE, m, n))) ATTRIBUTE_NONNULL(m)
#endif
#else
#define ATTRIBUTE_GCC_DIAG(m, n) ATTRIBUTE_NONNULL(m)
#define ATTRIBUTE_GCC_FE_DIAG(m, n) ATTRIBUTE_NONNULL(m)
#endif
extern void internal_error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2)
ATTRIBUTE_NORETURN;
extern void warning0 (const char *, ...) ATTRIBUTE_GCC_FE_DIAG(1,2);
extern void warning (int, const char *, ...) ATTRIBUTE_GCC_FE_DIAG(2,3);
extern void error (const char *, ...) ATTRIBUTE_GCC_FE_DIAG(1,2);
extern void warning0 (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
extern void warning (int, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
extern void error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
extern void fatal_error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2)
ATTRIBUTE_NORETURN;
extern void pedwarn (const char *, ...) ATTRIBUTE_GCC_FE_DIAG(1,2);
extern void sorry (const char *, ...) ATTRIBUTE_GCC_FE_DIAG(1,2);
extern void pedwarn (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
extern void sorry (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
extern void inform (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
extern void verbatim (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);

View File

@ -1764,7 +1764,7 @@ mark_eh_edge (struct eh_region *region, void *data)
e = find_edge (src, dst);
if (!e)
{
error ("EH edge %i->%i is missing %i %i.", src->index, dst->index, src, dst);
error ("EH edge %i->%i is missing.", src->index, dst->index);
mark_eh_edge_found_error = true;
}
else if (!(e->flags & EDGE_EH))

View File

@ -346,7 +346,7 @@ verify_phi_args (tree phi, basic_block bb, basic_block *definition_block)
if (e->dest != bb)
{
error ("Wrong edge %d->%d for PHI argument\n",
e->src->index, e->dest->index, bb->index);
e->src->index, e->dest->index);
err = true;
}

View File

@ -4583,11 +4583,11 @@ finish_aliases_1 (void)
target_decl = find_decl_and_mark_needed (p->decl, p->target);
if (target_decl == NULL)
error ("%q+D aliased to undefined symbol %qE",
p->decl, p->target);
error ("%q+D aliased to undefined symbol %qs",
p->decl, IDENTIFIER_POINTER (p->target));
else if (DECL_EXTERNAL (target_decl))
error ("%q+D aliased to external symbol %qE",
p->decl, p->target);
error ("%q+D aliased to external symbol %qs",
p->decl, IDENTIFIER_POINTER (p->target));
}
}