This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

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


	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 2/2.  Okay to install?

		--Kaveh




1999-10-12  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

ch:
	* expr.c (build_chill_function_call): Don't call a variadic
	function with a non-literal format string.
	
	* grant.c (write_spec_module): Likewise.
	
	* parse.c (require, expect): Likewise.

	* tasking.c (get_struct_type_name, get_struct_debug_type_name,
	get_tasking_code_name, get_struct_variable_name,
	get_process_wrapper_name, build_start_process): Likewise.

	* typeck.c (valid_array_index_p): Likewise.

cp:
	* decl.c (pushdecl, grokdeclarator): Likewise.

	* lex.c (do_identifier): Likewise.

	* typeck.c (build_unary_op): Likewise.

java:
	* jcf-dump.c (print_constant, disassemble_method): Likewise.

	* parse-scan.y (report_main_declaration): Likewise.

	* parse.h (ERROR_CAST_NEEDED_TO_INTEGRAL): Likewise.

	* parse.y (read_import_dir, patch_assignment, patch_binop,
	patch_array_ref): Likewise.

	* typeck.c (build_java_array_type): Likewise.

	* verify.c (verify_jvm_instructions): Likewise.

diff -rup orig/egcs-CVS19991010/gcc/ch/expr.c egcs-CVS19991010/gcc/ch/expr.c
--- orig/egcs-CVS19991010/gcc/ch/expr.c	Fri Sep 10 06:35:49 1999
+++ egcs-CVS19991010/gcc/ch/expr.c	Sun Oct 10 22:01:47 1999
@@ -2512,20 +2512,20 @@ build_chill_function_call (function, exp
  
   if (valtail != 0 && TREE_VALUE (valtail) != void_type_node)
     {
-      const char *errstr = "too many arguments to procedure";
       if (name)
-	error ("%s `%s'", errstr, IDENTIFIER_POINTER (name));
+	error ("too many arguments to procedure `%s'",
+	       IDENTIFIER_POINTER (name));
       else
-	error (errstr);
+	error ("too many arguments to procedure");
       return error_mark_node;
     }
   else if (typetail != 0 && TREE_VALUE (typetail) != void_type_node)
     {
-      const char *errstr = "too few arguments to procedure";
       if (name)
-	error ("%s `%s'", errstr, IDENTIFIER_POINTER (name));
+	error ("too few arguments to procedure `%s'",
+	       IDENTIFIER_POINTER (name));
       else
-	error (errstr);
+	error ("too few arguments to procedure");
       return error_mark_node;
     }
   
diff -rup orig/egcs-CVS19991010/gcc/ch/grant.c egcs-CVS19991010/gcc/ch/grant.c
--- orig/egcs-CVS19991010/gcc/ch/grant.c	Sun Aug 29 09:34:10 1999
+++ egcs-CVS19991010/gcc/ch/grant.c	Sun Oct 10 21:59:30 1999
@@ -2829,9 +2829,8 @@ really_grant_this (decl, granted_decls)
 
 /* Write a SPEC MODULE using the declarations in the list DECLS. */
 static int header_written = 0;
-static const char *header_template =
-"--\n-- WARNING: this file was generated by\n\
--- GNUCHILL version %s\n-- based on gcc version %s\n--\n";
+#define HEADER_TEMPLATE "--\n-- WARNING: this file was generated by\n\
+-- GNUCHILL version %s\n-- based on gcc version %s\n--\n"
 
 void
 write_spec_module (decls, granted_decls)
@@ -2850,8 +2849,8 @@ write_spec_module (decls, granted_decls)
     {
       hdr = (char*) alloca (strlen (gnuchill_version)
 			    + strlen (version_string)
-			    + strlen (header_template) + 1);
-      sprintf (hdr, header_template, gnuchill_version, version_string);
+			    + sizeof (HEADER_TEMPLATE) /* includes \0 */);
+      sprintf (hdr, HEADER_TEMPLATE, gnuchill_version, version_string);
       APPEND (gstring, hdr);
       header_written = 1;
     }      
diff -rup orig/egcs-CVS19991010/gcc/ch/parse.c egcs-CVS19991010/gcc/ch/parse.c
--- orig/egcs-CVS19991010/gcc/ch/parse.c	Mon Aug 30 22:15:54 1999
+++ egcs-CVS19991010/gcc/ch/parse.c	Mon Oct 11 10:46:45 1999
@@ -332,11 +332,7 @@ require(token)
      enum terminal token;
 {
   if (PEEK_TOKEN() != token)
-    {
-      char buf[80];
-      sprintf (buf, "internal parser error - expected token %d", (int)token);
-      fatal(buf);
-    }
+    fatal ("internal parser error - expected token %d", (int)token);
   FORWARD_TOKEN();
 }
 
@@ -361,7 +357,7 @@ expect(token, message)
   if (PEEK_TOKEN() != token)
     {
       if (pass == 1)
-	error(message ? message : "syntax error");
+	error("%s", message ? message : "syntax error");
       return 0;
     }
   else
diff -rup orig/egcs-CVS19991010/gcc/ch/tasking.c egcs-CVS19991010/gcc/ch/tasking.c
--- orig/egcs-CVS19991010/gcc/ch/tasking.c	Fri Sep 24 06:06:53 1999
+++ egcs-CVS19991010/gcc/ch/tasking.c	Sun Oct 10 23:32:27 1999
@@ -69,18 +69,19 @@ tree tasking_list = NULL_TREE;
 #define TASK_INFO_STUFF_TYPE(NODE) TREE_VEC_ELT(NODE,4)
 
 /* name template for process argument type */
-static const char * struct_name = "__tmp_%s_arg_type";
+#define STRUCT_NAME "__tmp_%s_arg_type"
 
 /* name template for process arguments for debugging type */
-static const char * struct_debug_name = "__tmp_%s_debug_type";
+#define STRUCT_DEBUG_NAME "__tmp_%s_debug_type"
 
-#if 0
 /* name template for process argument variable */
-static const char * data_name = "__tmp_%s_arg_variable";
-#endif
+#define DATA_NAME  "__tmp_%s_arg_variable"
 
 /* name template for process wrapper */
-static const char * wrapper_name = "__tmp_%s_wrapper";
+#define WRAPPER_NAME "__tmp_%s_wrapper"
+
+/* name template for process code */
+#define SKELNAME "__tmp_%s_code"
 
 extern int ignoring;
 static tree void_ftype_void;
@@ -92,9 +93,9 @@ get_struct_type_name (name)
      tree name;
 {
   const char *idp = IDENTIFIER_POINTER (name);        /* process name */
-  char *tmpname = xmalloc (strlen (idp) + strlen (struct_name) + 1);
+  char *tmpname = xmalloc (strlen (idp) + sizeof (STRUCT_NAME));
 
-  sprintf (tmpname, struct_name, idp);
+  sprintf (tmpname, STRUCT_NAME, idp);
   return get_identifier (tmpname);
 }
 
@@ -103,9 +104,9 @@ get_struct_debug_type_name (name)
      tree name;
 {
   const char *idp = IDENTIFIER_POINTER (name);        /* process name */
-  char *tmpname = xmalloc (strlen (idp) + strlen (struct_debug_name) + 1);
+  char *tmpname = xmalloc (strlen (idp) + sizeof (STRUCT_DEBUG_NAME));
 
-  sprintf (tmpname, struct_debug_name, idp);
+  sprintf (tmpname, STRUCT_DEBUG_NAME, idp);
   return get_identifier (tmpname);
 }
 
@@ -114,12 +115,11 @@ tree
 get_tasking_code_name (name)
      tree name;
 {
-  const char *skelname = "__tmp_%s_code";
   const char *name_str = IDENTIFIER_POINTER (name);
-  char *tmpname  = (char *)alloca (IDENTIFIER_LENGTH (name) +
-				   strlen (skelname) + 1);
-
-  sprintf (tmpname, skelname, name_str);
+  char *tmpname  = (char *) alloca (IDENTIFIER_LENGTH (name) +
+				    sizeof (SKELNAME));
+  
+  sprintf (tmpname, SKELNAME, name_str);
   return get_identifier (tmpname);
 }
 
@@ -129,9 +129,9 @@ get_struct_variable_name (name)
      tree name;
 {
   const char *idp = IDENTIFIER_POINTER (name);        /* process name */
-  char *tmpname = xmalloc (strlen (idp) + strlen (data_name) + 1);
+  char *tmpname = xmalloc (strlen (idp) + sizeof (DATA_NAME));
 
-  sprintf (tmpname, data_name, idp);
+  sprintf (tmpname, DATA_NAME, idp);
   return get_identifier (tmpname);
 }
 #endif
@@ -141,9 +141,9 @@ get_process_wrapper_name (name)
     tree name;
 {
   const char *idp = IDENTIFIER_POINTER (name);
-  char *tmpname = xmalloc (strlen (idp) + strlen (wrapper_name) + 1);
+  char *tmpname = xmalloc (strlen (idp) + sizeof (WRAPPER_NAME));
     
-  sprintf (tmpname, wrapper_name, idp);
+  sprintf (tmpname, WRAPPER_NAME, idp);
   return get_identifier (tmpname);
 }
 
@@ -627,19 +627,19 @@ build_start_process (process_name, copyn
   
       if (valtail != 0 && TREE_VALUE (valtail) != void_type_node)
 	{
-	  const char *errstr = "too many arguments to process";
 	  if (process_name)
-	    error ("%s `%s'", errstr, IDENTIFIER_POINTER (process_name));
+	    error ("too many arguments to process `%s'",
+		   IDENTIFIER_POINTER (process_name));
 	  else
-	    error (errstr);
+	    error ("too many arguments to process");
 	}
       else if (typetail != 0 && TREE_VALUE (typetail) != void_type_node)
 	{
-	  const char *errstr = "too few arguments to process";
 	  if (process_name)
-	    error ("%s `%s'", errstr, IDENTIFIER_POINTER (process_name));
+	    error ("too few arguments to process `%s'",
+		   IDENTIFIER_POINTER (process_name));
 	  else
-	    error (errstr);
+	    error ("too few arguments to process");
 	}
       else
       {
diff -rup orig/egcs-CVS19991010/gcc/ch/typeck.c egcs-CVS19991010/gcc/ch/typeck.c
--- orig/egcs-CVS19991010/gcc/ch/typeck.c	Fri Sep 10 06:35:49 1999
+++ egcs-CVS19991010/gcc/ch/typeck.c	Mon Oct 11 10:47:44 1999
@@ -154,7 +154,7 @@ valid_array_index_p (array, idx, error_m
     {
       if (tree_int_cst_equal (cond, boolean_false_node))
 	return idx;       /* condition met at compile time */
-      error (error_message); /* condition failed at compile time */
+      error ("%s", error_message); /* condition failed at compile time */
       return error_mark_node;
     }
   else if (range_checking)
diff -rup orig/egcs-CVS19991010/gcc/cp/decl.c egcs-CVS19991010/gcc/cp/decl.c
--- orig/egcs-CVS19991010/gcc/cp/decl.c	Sat Oct  9 17:06:03 1999
+++ egcs-CVS19991010/gcc/cp/decl.c	Sun Oct 10 23:39:34 1999
@@ -4020,22 +4020,21 @@ pushdecl (x)
 		   /* No shadow warnings for vars made for inlining.  */
 		   && ! DECL_FROM_INLINE (x))
 	    {
-	      const char *warnstring = NULL;
-
 	      if (oldlocal != NULL_TREE && TREE_CODE (oldlocal) == PARM_DECL)
-		warnstring = "declaration of `%s' shadows a parameter";
+		warning("declaration of `%s' shadows a parameter",
+			IDENTIFIER_POINTER (name));
 	      else if (IDENTIFIER_CLASS_VALUE (name) != NULL_TREE
 		       && current_class_ptr
 		       && !TREE_STATIC (name))
-		warnstring = "declaration of `%s' shadows a member of `this'";
+		warning("declaration of `%s' shadows a member of `this'",
+			IDENTIFIER_POINTER (name));
 	      else if (oldlocal != NULL_TREE)
-		warnstring = "declaration of `%s' shadows previous local";
+		warning("declaration of `%s' shadows previous local",
+			IDENTIFIER_POINTER (name));
 	      else if (oldglobal != NULL_TREE)
 		/* XXX shadow warnings in outer-more namespaces */
-		warnstring = "declaration of `%s' shadows global declaration";
-
-	      if (warnstring)
-		warning (warnstring, IDENTIFIER_POINTER (name));
+		warning("declaration of `%s' shadows global declaration",
+			IDENTIFIER_POINTER (name));
 	    }
 	}
 
@@ -9675,9 +9674,12 @@ grokdeclarator (declarator, declspecs, d
 		     op ? operator_name_string (tmp) : name);
 	    }
 	  else
-	    error (((decl_context == PARM || decl_context == CATCHPARM)
-		    ? "storage class specified for parameter `%s'"
-		    : "storage class specified for typename"), name);
+	    {
+	      if (decl_context == PARM || decl_context == CATCHPARM)
+		error ("storage class specified for parameter `%s'", name);
+	      else
+		error ("storage class specified for typename");
+	    }
 	  RIDBIT_RESET (RID_REGISTER, specbits);
 	  RIDBIT_RESET (RID_AUTO, specbits);
 	  RIDBIT_RESET (RID_EXTERN, specbits);
diff -rup orig/egcs-CVS19991010/gcc/cp/lex.c egcs-CVS19991010/gcc/cp/lex.c
--- orig/egcs-CVS19991010/gcc/cp/lex.c	Fri Oct  8 01:50:44 1999
+++ egcs-CVS19991010/gcc/cp/lex.c	Mon Oct 11 11:03:45 1999
@@ -3181,18 +3181,18 @@ do_identifier (token, parsing, args)
 	}
       else if (!DECL_ERROR_REPORTED (id))
 	{
-	  static char msg[]
-	    = "name lookup of `%s' changed for new ANSI `for' scoping";
 	  DECL_ERROR_REPORTED (id) = 1;
 	  if (TYPE_NEEDS_DESTRUCTOR (TREE_TYPE (id)))
 	    {
-	      error (msg, IDENTIFIER_POINTER (token));
+	      error ("name lookup of `%s' changed for new ANSI `for' scoping",
+		     IDENTIFIER_POINTER (token));
 	      cp_error_at ("  cannot use obsolete binding at `%D' because it has a destructor", id);
 	      id = error_mark_node;
 	    }
 	  else
 	    {
-	      pedwarn (msg, IDENTIFIER_POINTER (token));
+	      pedwarn ("name lookup of `%s' changed for new ANSI `for' scoping",
+		       IDENTIFIER_POINTER (token));
 	      cp_pedwarn_at ("  using obsolete binding at `%D'", id);
 	    }
 	}
diff -rup orig/egcs-CVS19991010/gcc/cp/typeck.c egcs-CVS19991010/gcc/cp/typeck.c
--- orig/egcs-CVS19991010/gcc/cp/typeck.c	Wed Oct  6 15:01:43 1999
+++ egcs-CVS19991010/gcc/cp/typeck.c	Mon Oct 11 11:05:14 1999
@@ -4789,7 +4789,7 @@ build_unary_op (code, xarg, noconvert)
       return fold (build1 (code, argtype, arg));
     }
 
-  error (errstring);
+  error ("%s", errstring);
   return error_mark_node;
 }
 
diff -rup orig/egcs-CVS19991010/gcc/java/jcf-dump.c egcs-CVS19991010/gcc/java/jcf-dump.c
--- orig/egcs-CVS19991010/gcc/java/jcf-dump.c	Thu Sep  2 17:57:08 1999
+++ egcs-CVS19991010/gcc/java/jcf-dump.c	Mon Oct 11 12:07:19 1999
@@ -386,7 +386,12 @@ DEFUN(print_constant, (out, jcf, index, 
     case CONSTANT_Class:
       n = JPOOL_USHORT1 (jcf, index);
       if (verbosity > 0)
-	fprintf (out, verbosity > 1 ? "Class name: %d=" : "Class ", n);
+	{
+	  if (verbosity > 1)
+	    fprintf (out, "Class name: %d=", n);
+	  else
+	    fprintf (out, "Class ");
+	}
       if (! CPOOL_INDEX_IN_RANGE (&jcf->cpool, n))
 	fprintf (out, "<out of range>");
       else if (verbosity < 2 && JPOOL_TAG (jcf, n) == CONSTANT_Utf8)
@@ -412,8 +417,10 @@ DEFUN(print_constant, (out, jcf, index, 
 	else if (verbosity > 0)
 	    fprintf (out, "%s ", str);
 	print_constant_terse (out, jcf, tclass, CONSTANT_Class);
-	fprintf (out, verbosity < 2 ? "." : " name_and_type: %d=<",
-		 name_and_type);
+	if (verbosity < 2)
+	  fprintf (out, ".");
+	else
+	  fprintf (out, " name_and_type: %d=<", name_and_type);
 	print_constant_terse (out, jcf, name_and_type, CONSTANT_NameAndType);
 	if (verbosity == 2)
 	  fputc ('>', out);
@@ -422,7 +429,12 @@ DEFUN(print_constant, (out, jcf, index, 
     case CONSTANT_String:
       j = JPOOL_USHORT1 (jcf, index);
       if (verbosity > 0)
-	fprintf (out, verbosity > 1 ? "String %d=" : "String ", j);
+	{
+	  if (verbosity > 1)
+	    fprintf (out, "String %d=", j);
+	  else
+	    fprintf (out, "String ");
+	}
       print_constant_terse (out, jcf, j, CONSTANT_Utf8);
       break;
     case CONSTANT_Integer:
@@ -473,8 +485,12 @@ DEFUN(print_constant, (out, jcf, index, 
 	uint16 name = JPOOL_USHORT1 (jcf, index);
 	uint16 sig = JPOOL_USHORT2 (jcf, index);
 	if (verbosity > 0)
-	  fprintf (out, verbosity > 1 ? "%s name: %d=" : "%s ",
-		   "NameAndType", name);
+	  {
+	    if (verbosity > 1)
+	      fprintf (out, "NameAndType name: %d=", name);
+	    else
+	      fprintf (out, "NameAndType ");
+	  }
 	print_name (out, jcf, name);
 	if (verbosity <= 1)
 	  fputc (' ', out);
@@ -1002,19 +1018,17 @@ DEFUN(disassemble_method, (jcf, byte_ops
 #define ARRAY_NEW(TYPE) ARRAY_NEW_##TYPE
 #define ARRAY_NEW_NUM \
  INT_temp = IMMEDIATE_u1; \
- { const char *str; \
-  switch (INT_temp) {  \
-    case  4: str = "boolean"; break; \
-    case  5: str = "char"; break; \
-    case  6: str = "float"; break; \
-    case  7: str = "double"; break; \
-    case  8: str = "byte"; break; \
-    case  9: str = "short"; break; \
-    case 10: str = "int"; break; \
-    case 11: str = "long"; break; \
-    default: str = "<unknown type code %d>"; break; \
-  } \
-  fputc (' ', out); fprintf (out, str, INT_temp); }
+ { switch (INT_temp) {  \
+    case  4: fputs (" boolean", out); break; \
+    case  5: fputs (" char", out); break; \
+    case  6: fputs (" float", out); break; \
+    case  7: fputs (" double", out); break; \
+    case  8: fputs (" byte", out); break; \
+    case  9: fputs (" short", out); break; \
+    case 10: fputs (" int", out); break; \
+    case 11: fputs (" long", out); break; \
+    default: fprintf (out, " <unknown type code %ld>", (long)INT_temp); break;\
+  } }
 
 #define ARRAY_NEW_PTR  \
   fputc (' ', out); print_constant_ref (out, jcf, IMMEDIATE_u2);
diff -rup orig/egcs-CVS19991010/gcc/java/parse-scan.y egcs-CVS19991010/gcc/java/parse-scan.y
--- orig/egcs-CVS19991010/gcc/java/parse-scan.y	Mon Oct  4 16:32:08 1999
+++ egcs-CVS19991010/gcc/java/parse-scan.y	Mon Oct 11 11:54:21 1999
@@ -1156,7 +1156,7 @@ report_main_declaration (declarator)
 	  if (package_name)
 	    fprintf (out, "%s.%s ", package_name, current_class);
 	  else
-	    fprintf (out, current_class);
+	    fprintf (out, "%s", current_class);
 	  previous_output = 1;
 	}
     }
diff -rup orig/egcs-CVS19991010/gcc/java/parse.h egcs-CVS19991010/gcc/java/parse.h
--- orig/egcs-CVS19991010/gcc/java/parse.h	Sun Oct 10 09:02:41 1999
+++ egcs-CVS19991010/gcc/java/parse.h	Mon Oct 11 11:44:26 1999
@@ -222,12 +222,19 @@ extern tree stabilize_reference PROTO ((
      "numeric type", operator_string ((NODE)), lang_printable_name ((TYPE), 0))
 
 #define ERROR_CAST_NEEDED_TO_INTEGRAL(OPERATOR, NODE, TYPE)		\
-  parse_error_context							\
-    ((OPERATOR), (JPRIMITIVE_TYPE_P (TYPE) ?				\
-     "Incompatible type for `%s'. Explicit cast needed to convert "	\
-      "`%s' to integral" : "Incompatible type for `%s'. Can't convert "	\
-      "`%s' to integral"), operator_string ((NODE)),			\
-      lang_printable_name ((TYPE), 0))
+do {									\
+  tree _operator = (OPERATOR), _node = (NODE), _type = (TYPE);		\
+  if (JPRIMITIVE_TYPE_P (_type))					\
+    parse_error_context (_operator, "Incompatible type for `%s'. Explicit" \
+                         " cast needed to convert `%s' to integral",	\
+			 operator_string(_node),			\
+			 lang_printable_name (_type, 0));		\
+  else									\
+    parse_error_context (_operator, "Incompatible type for `%s'. Can't" \
+                         " convert `%s' to integral",			\
+			 operator_string(_node),			\
+			 lang_printable_name (_type, 0));		\
+} while (0)
 
 #define ERROR_VARIABLE_NOT_INITIALIZED(WFL, V)			\
   parse_error_context						\
diff -rup orig/egcs-CVS19991010/gcc/java/parse.y egcs-CVS19991010/gcc/java/parse.y
--- orig/egcs-CVS19991010/gcc/java/parse.y	Tue Sep 21 11:53:23 1999
+++ egcs-CVS19991010/gcc/java/parse.y	Mon Oct 11 11:47:38 1999
@@ -5324,11 +5324,9 @@ read_import_dir (wfl)
       static int first = 1;
       if (first)
 	{
-	  char buffer [256];
-	  sprintf (buffer, "Can't find default package `%s'. Check "
-		   "the CLASSPATH environment variable and the access to the "
-		   "archives.", package_name);
-	  error (buffer);
+	  error ("Can't find default package `%s'. Check "
+		 "the CLASSPATH environment variable and the access to the "
+		 "archives.", package_name);
 	  java_error_count++;
 	  first = 0;
 	}
@@ -9130,11 +9128,14 @@ patch_assignment (node, wfl_op1, wfl_op2
 	    strcpy (operation, "`='");
 	}
 
-      parse_error_context 
-	(wfl, (!valid_cast_to_p (rhs_type, lhs_type) ?
-	       "Incompatible type for %s. Can't convert `%s' to `%s'" :
-	       "Incompatible type for %s. Explicit cast "
-	       "needed to convert `%s' to `%s'"), operation, t1, t2);
+      if (!valid_cast_to_p (rhs_type, lhs_type))
+	parse_error_context (wfl, "Incompatible type for %s. "
+			     "Can't convert `%s' to `%s'",
+			     operation, t1, t2);
+      else
+	parse_error_context (wfl, "Incompatible type for %s. "
+			     "Explicit cast needed to convert `%s' to `%s'",
+			     operation, t1, t2);
       free (t1); free (t2);
       error_found = 1;
     }
@@ -9738,13 +9739,21 @@ patch_binop (node, wfl_op1, wfl_op2)
 	  if (!JINTEGRAL_TYPE_P (op1_type))
 	    ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op1_type);
 	  else
-	    parse_error_context 
-	      (wfl_operator, (JPRIMITIVE_TYPE_P (op2_type) ? 
-	       "Incompatible type for `%s'. Explicit cast needed to convert "
-	       "shift distance from `%s' to integral" : 
-	       "Incompatible type for `%s'. Can't convert shift distance from "
-	       "`%s' to integral"), 
-	       operator_string (node), lang_printable_name (op2_type, 0));
+	    {
+	      if (JPRIMITIVE_TYPE_P (op2_type))
+		parse_error_context (wfl_operator,
+				     "Incompatible type for `%s'. "
+				     "Explicit cast needed to convert "
+				     "shift distance from `%s' to integral",
+				     operator_string (node),
+				     lang_printable_name (op2_type, 0));
+	      else
+		parse_error_context (wfl_operator, "Incompatible type for `%s'."
+				     " Can't convert shift distance from "
+				     "`%s' to integral", 
+				     operator_string (node),
+				     lang_printable_name (op2_type, 0));
+	    }
 	  TREE_TYPE (node) = error_mark_node;
 	  error_found = 1;
 	  break;
@@ -10604,13 +10613,14 @@ patch_array_ref (node)
   index = do_unary_numeric_promotion (index);
   if (TREE_TYPE (index) != int_type_node)
     {
-      int could_cast = valid_cast_to_p (index_type, int_type_node);
-      parse_error_context 
-	(wfl_operator, 
-	 (could_cast ? "Incompatible type for `[]'. Explicit cast needed to "
-	  "convert `%s' to `int'" : "Incompatible type for `[]'. "
-	  "Can't convert `%s' to `int'"),
-	 lang_printable_name (index_type, 0));
+      if (valid_cast_to_p (index_type, int_type_node))
+	parse_error_context (wfl_operator, "Incompatible type for `[]'. "
+			     "Explicit cast needed to convert `%s' to `int'",
+			     lang_printable_name (index_type, 0));
+      else
+	parse_error_context (wfl_operator, "Incompatible type for `[]'. "
+			     "Can't convert `%s' to `int'",
+			     lang_printable_name (index_type, 0));
       TREE_TYPE (node) = error_mark_node;
       error_found = 1;
     }
diff -rup orig/egcs-CVS19991010/gcc/java/typeck.c egcs-CVS19991010/gcc/java/typeck.c
--- orig/egcs-CVS19991010/gcc/java/typeck.c	Tue Aug 10 12:58:13 1999
+++ egcs-CVS19991010/gcc/java/typeck.c	Mon Oct 11 11:51:52 1999
@@ -374,7 +374,9 @@ build_java_array_type (element_type, len
   char buf[12];
   tree elsig = build_java_signature (element_type);
   tree el_name = element_type;
-  sprintf (buf, length >= 0 ? "[%d" : "[", length);
+  buf[0] = '[';
+  if (length >= 0)
+    sprintf (buf+1, HOST_WIDE_INT_PRINT_DEC, length);
   sig = ident_subst (IDENTIFIER_POINTER (elsig), IDENTIFIER_LENGTH (elsig),
 		     buf, 0, 0, "");
   t = IDENTIFIER_SIGNATURE_TYPE (sig);
diff -rup orig/egcs-CVS19991010/gcc/java/verify.c egcs-CVS19991010/gcc/java/verify.c
--- orig/egcs-CVS19991010/gcc/java/verify.c	Thu Sep  2 17:57:09 1999
+++ egcs-CVS19991010/gcc/java/verify.c	Mon Oct 11 11:52:20 1999
@@ -1344,6 +1344,6 @@ verify_jvm_instructions (jcf, byte_ops, 
   goto verify_error;
  verify_error:
   error ("verification error at PC=%d", oldpc);
-  error (message);
+  error ("%s", message);
   return 0;
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]