Patch to fix legit "format not a string literal" warnings part 1/2

Kaveh R. Ghazi ghazi@caip.rutgers.edu
Tue Oct 12 08:26:00 GMT 1999


	Here's a patch to silence many of the legitimate warnings
stemming from the new behavior of -Wformat, namely "format not a
string literal..."

This bootstraps on Irix6, but I'd really appreciate a careful review
since most of the code exists along error paths not taken during a
succesful compile.  (However I am slightly reassured because the
effect of this patch is to allow the format checks to work in more
cases where they previously couldn't.)

Also, I happened to notice that the chill compiler looks like it has
several memory leaks in ch/tasking.c (in part2.)  Take a look at the
get_* functions, get_tasking_code_name() allocates a string with
alloca and passes it to get_identifier(), the others allocate a string
with xmalloc and never free it.  If someone can verify these are
leaks, I will fix them.

This is part 1/2.  Okay to install?

		--Kaveh




1999-10-12  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.

	* cppexp.c (cpp_parse_expr): Likewise.

	* cpplib.c (check_macro_name): 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.

diff -rup orig/egcs-CVS19991010/gcc/c-common.c egcs-CVS19991010/gcc/c-common.c
--- orig/egcs-CVS19991010/gcc/c-common.c	Sun Oct 10 07:42:44 1999
+++ egcs-CVS19991010/gcc/c-common.c	Sun Oct 10 21:34:36 1999
@@ -1917,10 +1917,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;
 	}
 
diff -rup orig/egcs-CVS19991010/gcc/c-decl.c egcs-CVS19991010/gcc/c-decl.c
--- orig/egcs-CVS19991010/gcc/c-decl.c	Thu Oct  7 20:10:09 1999
+++ egcs-CVS19991010/gcc/c-decl.c	Sun Oct 10 21:24:32 1999
@@ -4262,12 +4262,18 @@ grokdeclarator (declarator, declspecs, d
 	  ;
 	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;
@@ -5336,11 +5342,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 ();
@@ -5352,9 +5358,8 @@ finish_struct (t, fieldlist, attributes)
 	  break;
 
       if (x == 0)
-	pedwarn ((fieldlist
-		  ? "%s has no named members"
-		  : "%s has no members"),
+	pedwarn ("%s has no %smembers",
+		 fieldlist ? "named " : "",
 		 TREE_CODE (t) == UNION_TYPE ? "union" : "struct");
     }
 
diff -rup orig/egcs-CVS19991010/gcc/c-typeck.c egcs-CVS19991010/gcc/c-typeck.c
--- orig/egcs-CVS19991010/gcc/c-typeck.c	Thu Sep 30 02:19:54 1999
+++ egcs-CVS19991010/gcc/c-typeck.c	Mon Oct 11 10:27:48 1999
@@ -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;
 	}
@@ -2806,9 +2805,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;
 	}
 
@@ -2826,15 +2825,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
@@ -3118,7 +3117,7 @@ lvalue_or_else (ref, msgid)
   int win = lvalue_p (ref);
 
   if (! win)
-    error (msgid);
+    error ("%s", msgid);
 
   return win;
 }
@@ -3172,11 +3171,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'.  */
@@ -4443,7 +4449,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);
@@ -4459,7 +4465,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);
@@ -4475,7 +4481,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);
diff -rup orig/egcs-CVS19991010/gcc/cccp.c egcs-CVS19991010/gcc/cccp.c
--- orig/egcs-CVS19991010/gcc/cccp.c	Sun Oct  3 12:08:31 1999
+++ egcs-CVS19991010/gcc/cccp.c	Sun Oct 10 20:46:43 1999
@@ -6029,13 +6029,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;
 }
 
@@ -7377,9 +7384,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;
 
@@ -9579,7 +9589,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);
diff -rup orig/egcs-CVS19991010/gcc/collect2.c egcs-CVS19991010/gcc/collect2.c
--- orig/egcs-CVS19991010/gcc/collect2.c	Wed Oct  6 10:48:38 1999
+++ egcs-CVS19991010/gcc/collect2.c	Mon Oct 11 12:09:36 1999
@@ -1546,12 +1546,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);
 	}
 
diff -rup orig/egcs-CVS19991010/gcc/cppexp.c egcs-CVS19991010/gcc/cppexp.c
--- orig/egcs-CVS19991010/gcc/cppexp.c	Thu Sep  9 00:00:36 1999
+++ egcs-CVS19991010/gcc/cppexp.c	Mon Oct 11 12:17:17 1999
@@ -1009,11 +1009,11 @@ cpp_parse_expr (pfile)
 		}
 	      break;
 	    default:
-	      cpp_error (pfile,
-			 (top[1].op >= ' ' && top[1].op <= '~'
-			  ? "unimplemented operator '%c'\n"
-			  : "unimplemented operator '\\%03o'\n"),
-			 top[1].op);
+	      if (top[1].op >= ' ' && top[1].op <= '~')
+		cpp_error (pfile, "unimplemented operator '%c'\n", top[1].op);
+	      else
+		cpp_error (pfile, "unimplemented operator '\\%03o'\n",
+			   top[1].op);
 	    }
 	}
       if (op.op == 0)
diff -rup orig/egcs-CVS19991010/gcc/cpplib.c egcs-CVS19991010/gcc/cpplib.c
--- orig/egcs-CVS19991010/gcc/cpplib.c	Sun Oct  3 12:28:31 1999
+++ egcs-CVS19991010/gcc/cpplib.c	Mon Oct 11 12:15:43 1999
@@ -613,19 +613,22 @@ check_macro_name (pfile, symname, assert
   sym_length = p - symname;
   if (sym_length == 0
       || (sym_length == 1 && *symname == 'L' && (*p == '\'' || *p == '"')))
-    cpp_error (pfile,
-	       assertion ? "invalid assertion name" : "invalid macro name");
+    {
+      if (assertion)
+	cpp_error (pfile, "invalid assertion name");
+      else
+	cpp_error (pfile, "invalid macro name");
+    }
   else if (!is_idstart[*symname]
 	   || (! strncmp (symname, "defined", 7) && sym_length == 7)) {
     U_CHAR *msg;			/* what pain...  */
     msg = (U_CHAR *) alloca (sym_length + 1);
     bcopy (symname, msg, sym_length);
     msg[sym_length] = 0;
-    cpp_error (pfile,
-	       (assertion
-		? "invalid assertion name `%s'"
-		: "invalid macro name `%s'"),
-	       msg);
+    if (assertion)
+      cpp_error (pfile, "invalid assertion name `%s'", msg);
+    else
+      cpp_error (pfile, "invalid macro name `%s'", msg);
   }
   return sym_length;
 }
diff -rup orig/egcs-CVS19991010/gcc/dbxout.c egcs-CVS19991010/gcc/dbxout.c
--- orig/egcs-CVS19991010/gcc/dbxout.c	Thu Sep 23 08:36:04 1999
+++ egcs-CVS19991010/gcc/dbxout.c	Sun Oct 10 21:01:15 1999
@@ -1349,7 +1349,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
diff -rup orig/egcs-CVS19991010/gcc/gcc.c egcs-CVS19991010/gcc/gcc.c
--- orig/egcs-CVS19991010/gcc/gcc.c	Sat Sep 25 09:11:16 1999
+++ egcs-CVS19991010/gcc/gcc.c	Mon Oct 11 10:33:14 1999
@@ -3668,7 +3668,7 @@ do_spec_1 (spec, inswitch, soft_matched_
 	      buf = (char *) alloca (p - q + 1);
 	      strncpy (buf, q, p - q);
 	      buf[p - q] = 0;
-	      error (buf);
+	      error ("%s", buf);
 	      return -1;
 	    }
 	    break;
diff -rup orig/egcs-CVS19991010/gcc/genemit.c egcs-CVS19991010/gcc/genemit.c
--- orig/egcs-CVS19991010/gcc/genemit.c	Mon Sep 20 05:59:56 1999
+++ egcs-CVS19991010/gcc/genemit.c	Sun Oct 10 21:13:18 1999
@@ -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);
diff -rup orig/egcs-CVS19991010/gcc/genrecog.c egcs-CVS19991010/gcc/genrecog.c
--- orig/egcs-CVS19991010/gcc/genrecog.c	Sun Oct 10 07:42:47 1999
+++ egcs-CVS19991010/gcc/genrecog.c	Sun Oct 10 21:10:15 1999
@@ -1451,30 +1451,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
@@ -1834,31 +1831,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->subroutine_number;
   const char *s_or_e;
   char extension[32];
@@ -1873,8 +1845,33 @@ 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++)
diff -rup orig/egcs-CVS19991010/gcc/mips-tfile.c egcs-CVS19991010/gcc/mips-tfile.c
--- orig/egcs-CVS19991010/gcc/mips-tfile.c	Tue Sep 21 18:31:29 1999
+++ egcs-CVS19991010/gcc/mips-tfile.c	Mon Oct 11 10:45:25 1999
@@ -5025,7 +5025,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.
@@ -5628,7 +5628,7 @@ void
 botch (s)
      const char *s;
 {
-  fatal (s);
+  fatal ("%s", s);
 }
 
 
diff -rup orig/egcs-CVS19991010/gcc/print-rtl.c egcs-CVS19991010/gcc/print-rtl.c
--- orig/egcs-CVS19991010/gcc/print-rtl.c	Wed Sep 15 19:05:04 1999
+++ egcs-CVS19991010/gcc/print-rtl.c	Sun Oct 10 20:52:17 1999
@@ -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;
diff -rup orig/egcs-CVS19991010/gcc/toplev.c egcs-CVS19991010/gcc/toplev.c
--- orig/egcs-CVS19991010/gcc/toplev.c	Sat Oct  9 15:47:18 1999
+++ egcs-CVS19991010/gcc/toplev.c	Mon Oct 11 10:22:18 1999
@@ -1519,10 +1519,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;
     }
@@ -1554,10 +1558,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;
     }
@@ -1949,7 +1953,7 @@ _fatal_insn (msgid, insn, file, line, fu
      int line;
      const char *function;
 {
-  error (msgid);
+  error ("%s", msgid);
   debug_rtx (insn);
   fancy_abort (file, line, function);
 }


More information about the Gcc-patches mailing list