c-common.c (check_format_info): Don't call a variadic function with a non-literal format string.

* c-common.c (check_format_info): Don't call a variadic function
	with a non-literal format string.

	* c-decl.c (grokdeclarator, start_struct, finish_struct): Likewise.

	* c-typeck.c (build_component_ref, build_unary_op, lvalue_or_else,
	pedantic_lvalue_warning, error_init, pedwarn_init, warning_init):
	Likewise.

	* cccp.c (check_macro_name, do_xifdef, vwarning_with_line):
	Likewise.

	* collect2.c (collect_wait): Likewise.

	* dbxout.c (dbxout_type): Likewise.

	* gcc.c (do_spec_1): Likewise.

	* genemit.c (gen_insn, gen_expand): Likewise.

	* genrecog.c (write_switch, write_subroutine): Likewise.

	* mips-tfile.c (catch_signal, botch): Likewise.

	* print-rtl.c (print_rtx): Likewise.

	* toplev.c (default_print_error_function, report_error_function,
	_fatal_insn): Likewise.

From-SVN: r30666
This commit is contained in:
Kaveh R. Ghazi 1999-11-25 16:58:32 +00:00 committed by Kaveh Ghazi
parent 7a12ace5bc
commit 913d08334a
13 changed files with 179 additions and 112 deletions

View File

@ -1,3 +1,34 @@
1999-11-25 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* c-common.c (check_format_info): Don't call a variadic function
with a non-literal format string.
* c-decl.c (grokdeclarator, start_struct, finish_struct): Likewise.
* c-typeck.c (build_component_ref, build_unary_op, lvalue_or_else,
pedantic_lvalue_warning, error_init, pedwarn_init, warning_init):
Likewise.
* cccp.c (check_macro_name, do_xifdef, vwarning_with_line):
Likewise.
* collect2.c (collect_wait): Likewise.
* dbxout.c (dbxout_type): Likewise.
* gcc.c (do_spec_1): Likewise.
* genemit.c (gen_insn, gen_expand): Likewise.
* genrecog.c (write_switch, write_subroutine): Likewise.
* mips-tfile.c (catch_signal, botch): Likewise.
* print-rtl.c (print_rtx): Likewise.
* toplev.c (default_print_error_function, report_error_function,
_fatal_insn): Likewise.
1999-11-25 Mark Mitchell <mark@codesourcery.com>
* tree.c (unsave_expr_now): Handle NULL_TREE as input.

View File

@ -1925,10 +1925,12 @@ check_format_info (info, params)
continue;
}
if (TREE_CODE (cur_type) != ERROR_MARK)
warning ((fci->pointer_count + aflag == 1
? "format argument is not a pointer (arg %d)"
: "format argument is not a pointer to a pointer (arg %d)"),
arg_num);
{
if (fci->pointer_count + aflag == 1)
warning ("format argument is not a pointer (arg %d)", arg_num);
else
warning ("format argument is not a pointer to a pointer (arg %d)", arg_num);
}
break;
}

View File

@ -4262,12 +4262,18 @@ grokdeclarator (declarator, declspecs, decl_context, initialized)
;
else
{
error ((decl_context == FIELD
? "storage class specified for structure field `%s'"
: (decl_context == PARM
? "storage class specified for parameter `%s'"
: "storage class specified for typename")),
name);
switch (decl_context)
{
case FIELD:
error ("storage class specified for structure field `%s'", name);
break;
case PARM:
error ("storage class specified for parameter `%s'", name);
break;
default:
error ("storage class specified for typename");
break;
}
specbits &= ~ ((1 << (int) RID_TYPEDEF) | (1 << (int) RID_REGISTER)
| (1 << (int) RID_AUTO) | (1 << (int) RID_STATIC)
| (1 << (int) RID_EXTERN));
@ -5243,8 +5249,8 @@ start_struct (code, name)
C_TYPE_BEING_DEFINED (ref) = 1;
TYPE_PACKED (ref) = flag_pack_struct;
if (TYPE_FIELDS (ref))
error ((code == UNION_TYPE ? "redefinition of `union %s'"
: "redefinition of `struct %s'"),
error ("redefinition of `%s %s'",
code == UNION_TYPE ? "union" : "struct",
IDENTIFIER_POINTER (name));
return ref;
@ -5316,11 +5322,11 @@ finish_struct (t, fieldlist, attributes)
if (in_parm_level_p ())
{
if (pedantic)
pedwarn ((TREE_CODE (t) == UNION_TYPE ? "union defined inside parms"
: "structure defined inside parms"));
pedwarn ("%s defined inside parms",
TREE_CODE (t) == UNION_TYPE ? "union" : "structure");
else if (! flag_traditional)
warning ((TREE_CODE (t) == UNION_TYPE ? "union defined inside parms"
: "structure defined inside parms"));
warning ("%s defined inside parms",
TREE_CODE (t) == UNION_TYPE ? "union" : "structure");
}
old_momentary = suspend_momentary ();
@ -5332,10 +5338,9 @@ finish_struct (t, fieldlist, attributes)
break;
if (x == 0)
pedwarn ((fieldlist
? "%s has no named members"
: "%s has no members"),
TREE_CODE (t) == UNION_TYPE ? "union" : "struct");
pedwarn ("%s has no %smembers",
TREE_CODE (t) == UNION_TYPE ? "union" : "struct",
fieldlist ? "named " : "");
}
/* Install struct as DECL_CONTEXT of each field decl.

View File

@ -1157,9 +1157,8 @@ build_component_ref (datum, component)
if (!field)
{
error (code == RECORD_TYPE
? "structure has no member named `%s'"
: "union has no member named `%s'",
error ("%s has no member named `%s'",
code == RECORD_TYPE ? "structure" : "union",
IDENTIFIER_POINTER (component));
return error_mark_node;
}
@ -2807,9 +2806,9 @@ build_unary_op (code, xarg, noconvert)
if (typecode != POINTER_TYPE
&& typecode != INTEGER_TYPE && typecode != REAL_TYPE)
{
error (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR
? "wrong type argument to increment"
: "wrong type argument to decrement");
error ("wrong type argument to %s",
code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR
? "increment" : "decrement");
return error_mark_node;
}
@ -2827,15 +2826,15 @@ build_unary_op (code, xarg, noconvert)
/* If pointer target is an undefined struct,
we just cannot know how to do the arithmetic. */
if (TYPE_SIZE (TREE_TYPE (result_type)) == 0)
error (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR
? "increment of pointer to unknown structure"
: "decrement of pointer to unknown structure");
error ("%s of pointer to unknown structure",
code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR
? "increment" : "decrement");
else if ((pedantic || warn_pointer_arith)
&& (TREE_CODE (TREE_TYPE (result_type)) == FUNCTION_TYPE
|| TREE_CODE (TREE_TYPE (result_type)) == VOID_TYPE))
pedwarn (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR
? "wrong type argument to increment"
: "wrong type argument to decrement");
pedwarn ("wrong type argument to %s",
code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR
? "increment" : "decrement");
inc = c_size_in_bytes (TREE_TYPE (result_type));
}
else
@ -3119,7 +3118,7 @@ lvalue_or_else (ref, msgid)
int win = lvalue_p (ref);
if (! win)
error (msgid);
error ("%s", msgid);
return win;
}
@ -3173,11 +3172,18 @@ pedantic_lvalue_warning (code)
enum tree_code code;
{
if (pedantic)
pedwarn (code == COND_EXPR
? "ANSI C forbids use of conditional expressions as lvalues"
: code == COMPOUND_EXPR
? "ANSI C forbids use of compound expressions as lvalues"
: "ANSI C forbids use of cast expressions as lvalues");
switch (code)
{
case COND_EXPR:
pedwarn ("ANSI C forbids use of conditional expressions as lvalues");
break;
case COMPOUND_EXPR:
pedwarn ("ANSI C forbids use of compound expressions as lvalues");
break;
default:
pedwarn ("ANSI C forbids use of cast expressions as lvalues");
break;
}
}
/* Warn about storing in something that is `const'. */
@ -4444,7 +4450,7 @@ error_init (msgid)
{
char *ofwhat;
error (msgid);
error ("%s", msgid);
ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
if (*ofwhat)
error ("(near initialization for `%s')", ofwhat);
@ -4460,7 +4466,7 @@ pedwarn_init (msgid)
{
char *ofwhat;
pedwarn (msgid);
pedwarn ("%s", msgid);
ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
if (*ofwhat)
pedwarn ("(near initialization for `%s')", ofwhat);
@ -4476,7 +4482,7 @@ warning_init (msgid)
{
char *ofwhat;
warning (msgid);
warning ("%s", msgid);
ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
if (*ofwhat)
warning ("(near initialization for `%s')", ofwhat);

View File

@ -6064,13 +6064,20 @@ check_macro_name (symname, assertion)
sym_length = p - symname;
if (sym_length == 0
|| (sym_length == 1 && *symname == 'L' && (*p == '\'' || *p == '"')))
error (assertion ? "invalid assertion name" : "invalid macro name");
{
if (assertion)
error ("invalid assertion name");
else
error ("invalid macro name");
}
else if (!is_idstart[*symname]
|| (sym_length == 7 && ! bcmp (symname, "defined", 7)))
error ((assertion
? "invalid assertion name `%.*s'"
: "invalid macro name `%.*s'"),
sym_length, symname);
{
if (assertion)
error ("invalid assertion name `%.*s'", sym_length, symname);
else
error ("invalid macro name `%.*s'", sym_length, symname);
}
return sym_length;
}
@ -7419,9 +7426,12 @@ do_xifdef (buf, limit, op, keyword)
if (end == buf) {
skip = (keyword->type == T_IFDEF);
if (! traditional)
pedwarn (end == limit ? "`#%s' with no argument"
: "`#%s' argument starts with punctuation",
keyword->name);
{
if (end == limit)
pedwarn ("`#%s' with no argument", keyword->name);
else
pedwarn ("`#%s' argument starts with punctuation", keyword->name);
}
} else {
HASHNODE *hp;
@ -9627,7 +9637,10 @@ vwarning_with_line (line, msgid, args)
if (ip != NULL) {
fwrite (ip->nominal_fname, sizeof ip->nominal_fname[0],
ip->nominal_fname_len, stderr);
fprintf (stderr, line ? ":%d: " : ": ", line);
if (line)
fprintf (stderr, ":%d: ", line);
else
fputs (": ", stderr);
}
notice ("warning: ");
vnotice (msgid, args);

View File

@ -1569,12 +1569,9 @@ collect_wait (prog)
if (WIFSIGNALED (status))
{
int sig = WTERMSIG (status);
error ((status & 0200
? "%s terminated with signal %d [%s]"
: "%s terminated with signal %d [%s], core dumped"),
prog,
sig,
strsignal(sig));
error ("%s terminated with signal %d [%s]%s",
prog, sig, strsignal(sig),
status & 0200 ? "" : ", core dumped");
collect_exit (FATAL_EXIT_CODE);
}

View File

@ -1382,7 +1382,7 @@ dbxout_type (type, full, show_arg_types)
If the type has a name, don't nest its definition within
another type's definition; instead, output an xref
and let the definition come when the name is defined. */
fprintf (asmfile, (TREE_CODE (type) == RECORD_TYPE) ? "xs" : "xu");
fputs ((TREE_CODE (type) == RECORD_TYPE) ? "xs" : "xu", asmfile);
CHARS (3);
#if 0 /* This assertion is legitimately false in C++. */
/* We shouldn't be outputting a reference to a type before its

View File

@ -3958,7 +3958,7 @@ do_spec_1 (spec, inswitch, soft_matched_part)
buf = (char *) alloca (p - q + 1);
strncpy (buf, q, p - q);
buf[p - q] = 0;
error (buf);
error ("%s", buf);
return -1;
}
break;

View File

@ -377,7 +377,10 @@ gen_insn (insn)
/* Output the function name and argument declarations. */
printf ("rtx\ngen_%s (", XSTR (insn, 0));
for (i = 0; i < operands; i++)
printf (i ? ", operand%d" : "operand%d", i);
if (i)
printf (", operand%d", i);
else
printf ("operand%d", i);
printf (")\n");
for (i = 0; i < operands; i++)
printf (" rtx operand%d;\n", i);
@ -428,7 +431,10 @@ gen_expand (expand)
/* Output the function name and argument declarations. */
printf ("rtx\ngen_%s (", XSTR (expand, 0));
for (i = 0; i < operands; i++)
printf (i ? ", operand%d" : "operand%d", i);
if (i)
printf (", operand%d", i);
else
printf ("operand%d", i);
printf (")\n");
for (i = 0; i < operands; i++)
printf (" rtx operand%d;\n", i);

View File

@ -1776,30 +1776,27 @@ write_switch (start, depth)
|| type == DT_elt_one_int
|| type == DT_elt_zero_wide)
{
const char *str;
printf (" switch (");
switch (type)
{
case DT_mode:
str = "GET_MODE (x%d)";
printf("GET_MODE (x%d)", depth);
break;
case DT_veclen:
str = "XVECLEN (x%d, 0)";
printf("XVECLEN (x%d, 0)", depth);
break;
case DT_elt_zero_int:
str = "XINT (x%d, 0)";
printf("XINT (x%d, 0)", depth);
break;
case DT_elt_one_int:
str = "XINT (x%d, 1)";
printf("XINT (x%d, 1)", depth);
break;
case DT_elt_zero_wide:
str = "XWINT (x%d, 0)";
printf("XWINT (x%d, 0)", depth);
break;
default:
abort ();
}
printf (str, depth);
printf (")\n {\n");
do
@ -2159,31 +2156,6 @@ write_subroutine (head, type)
struct decision_head *head;
enum routine_type type;
{
static const char * const proto_pattern[] = {
"%sint recog%s PROTO ((rtx, rtx, int *));\n",
"%srtx split%s PROTO ((rtx, rtx));\n",
"%srtx peephole2%s PROTO ((rtx, rtx, rtx *));\n"
};
static const char * const decl_pattern[] = {
"%sint\n\
recog%s (x0, insn, pnum_clobbers)\n\
register rtx x0;\n\
rtx insn ATTRIBUTE_UNUSED;\n\
int *pnum_clobbers ATTRIBUTE_UNUSED;\n",
"%srtx\n\
split%s (x0, insn)\n\
register rtx x0;\n\
rtx insn ATTRIBUTE_UNUSED;\n",
"%srtx\n\
peephole2%s (x0, insn, _plast_insn)\n\
register rtx x0;\n\
rtx insn ATTRIBUTE_UNUSED;\n\
rtx *_plast_insn ATTRIBUTE_UNUSED;\n"
};
int subfunction = head->first ? head->first->subroutine_number : 0;
const char *s_or_e;
char extension[32];
@ -2198,8 +2170,32 @@ peephole2%s (x0, insn, _plast_insn)\n\
else
strcpy (extension, "_insns");
printf (proto_pattern[type], s_or_e, extension);
printf (decl_pattern[type], s_or_e, extension);
switch (type)
{
case RECOG:
printf ("%sint recog%s PROTO ((rtx, rtx, int *));\n", s_or_e, extension);
printf ("%sint\n\
recog%s (x0, insn, pnum_clobbers)\n\
register rtx x0;\n\
rtx insn ATTRIBUTE_UNUSED;\n\
int *pnum_clobbers ATTRIBUTE_UNUSED;\n", s_or_e, extension);
break;
case SPLIT:
printf ("%srtx split%s PROTO ((rtx, rtx));\n", s_or_e, extension);
printf ("%srtx\n\
split%s (x0, insn)\n\
register rtx x0;\n\
rtx insn ATTRIBUTE_UNUSED;\n", s_or_e, extension);
break;
case PEEPHOLE2:
printf ("%srtx peephole2%s PROTO ((rtx, rtx, rtx *));\n", s_or_e, extension);
printf ("%srtx\n\
peephole2%s (x0, insn, _plast_insn)\n\
register rtx x0;\n\
rtx insn ATTRIBUTE_UNUSED;\n\
rtx *_plast_insn ATTRIBUTE_UNUSED;\n", s_or_e, extension);
break;
}
printf ("{\n register rtx * const operands = &recog_data.operand[0];\n");
for (i = 1; i <= max_depth; i++)

View File

@ -5027,7 +5027,7 @@ catch_signal (signum)
int signum;
{
(void) signal (signum, SIG_DFL); /* just in case... */
fatal (strsignal(signum));
fatal ("%s", strsignal(signum));
}
/* Print a fatal error message. NAME is the text.
@ -5630,7 +5630,7 @@ void
botch (s)
const char *s;
{
fatal (s);
fatal ("%s", s);
}

View File

@ -146,8 +146,12 @@ print_rtx (in_rtx)
if (XSTR (in_rtx, i) == 0)
fputs (dump_for_graph ? " \\\"\\\"" : " \"\"", outfile);
else
fprintf (outfile, dump_for_graph ? " (\\\"%s\\\")" : " (\"%s\")",
XSTR (in_rtx, i));
{
if (dump_for_graph)
fprintf (outfile, " (\\\"%s\\\")", XSTR (in_rtx, i));
else
fprintf (outfile, " (\"%s\")", XSTR (in_rtx, i));
}
sawclose = 1;
break;
@ -188,13 +192,16 @@ print_rtx (in_rtx)
}
else
{
char *str = X0STR (in_rtx, i);
const char * const str = X0STR (in_rtx, i);
if (str == 0)
fputs (dump_for_graph ? " \\\"\\\"" : " \"\"", outfile);
else
fprintf (outfile,
dump_for_graph ? " (\\\"%s\\\")" : " (\"%s\")",
str);
{
if (dump_for_graph)
fprintf (outfile, " (\\\"%s\\\")", str);
else
fprintf (outfile, " (\"%s\")", str);
}
}
}
break;

View File

@ -1549,10 +1549,14 @@ default_print_error_function (file)
if (current_function_decl == NULL)
notice ("At top level:\n");
else
notice ((TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE
? "In method `%s':\n"
: "In function `%s':\n"),
(*decl_printable_name) (current_function_decl, 2));
{
if (TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
notice ("In method `%s':\n",
(*decl_printable_name) (current_function_decl, 2));
else
notice ("In function `%s':\n",
(*decl_printable_name) (current_function_decl, 2));
}
last_error_function = current_function_decl;
}
@ -1584,10 +1588,10 @@ report_error_function (file)
&& input_file_stack_tick != last_error_tick)
{
for (p = input_file_stack->next; p; p = p->next)
notice ((p == input_file_stack->next
? "In file included from %s:%d"
: ",\n from %s:%d"),
p->name, p->line);
if (p == input_file_stack->next)
notice ("In file included from %s:%d", p->name, p->line);
else
notice (",\n from %s:%d", p->name, p->line);
fprintf (stderr, ":\n");
last_error_tick = input_file_stack_tick;
}
@ -1979,7 +1983,7 @@ _fatal_insn (msgid, insn, file, line, function)
int line;
const char *function;
{
error (msgid);
error ("%s", msgid);
debug_rtx (insn);
fancy_abort (file, line, function);
}