From d240e44f078badbaff23b7dc73c17f82c3b791d0 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss <creatorsmithmdt@gmail.com>
Date: Fri, 18 Nov 2022 14:36:52 +1100
Subject: [PATCH 33/56] java: Fix -Wformat-diag warnings.

gcc/java/ChangeLog:

	* decl.cc (force_poplevels): Fix -Wformat-diag warning.
	* except.cc (doing_eh): Likewise.
	* jcf-parse.cc (handle_constant): Likewise.
	(jcf_parse): Likewise.
	(java_parse_file): Likewise.
	* jvspec.cc (lang_specific_driver): Likewise.
	* lang.cc (java_post_options): Likewise.
	* verify-glue.cc (verify_jvm_instructions_new): Likewise.
---
 gcc/java/decl.cc        |  2 +-
 gcc/java/except.cc      |  2 +-
 gcc/java/jcf-parse.cc   | 14 +++++++-------
 gcc/java/jvspec.cc      |  8 ++++----
 gcc/java/lang.cc        | 10 +++++-----
 gcc/java/verify-glue.cc |  2 +-
 6 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/gcc/java/decl.cc b/gcc/java/decl.cc
index 4fdfaaaf8c1..6319d1ce18a 100644
--- a/gcc/java/decl.cc
+++ b/gcc/java/decl.cc
@@ -1617,7 +1617,7 @@ force_poplevels (int start_pc)
   while (current_binding_level->start_pc > start_pc)
     {
       if (pedantic && current_binding_level->start_pc > start_pc)
-	warning (0, "In %+D: overlapped variable and exception ranges at %d",
+	warning (0, "In %<%+D:%> overlapped variable and exception ranges at %d",
                  current_function_decl,
 		 current_binding_level->start_pc);
       poplevel (1, 0, 0);
diff --git a/gcc/java/except.cc b/gcc/java/except.cc
index c5ecccc2326..7d936d379bd 100644
--- a/gcc/java/except.cc
+++ b/gcc/java/except.cc
@@ -577,7 +577,7 @@ doing_eh (void)
       static int warned = 0;
       if (! warned)
 	{
-	  error ("exception handling disabled, use -fexceptions to enable");
+	  error ("exception handling disabled, use %<-fexceptions%> to enable");
 	  warned = 1;
 	}
       return 0;
diff --git a/gcc/java/jcf-parse.cc b/gcc/java/jcf-parse.cc
index b5e39fd5a5c..683f7211085 100644
--- a/gcc/java/jcf-parse.cc
+++ b/gcc/java/jcf-parse.cc
@@ -499,7 +499,7 @@ handle_constant (JCF *jcf, int index, enum cpool_tag purpose)
     return 0;
 
   if (! CPOOL_INDEX_IN_RANGE (&jcf->cpool, index))
-    error ("<constant pool index %d not in range>", index);
+    error ("constant pool index %d not in range", index);
   
   kind = JPOOL_TAG (jcf, index);
 
@@ -509,7 +509,7 @@ handle_constant (JCF *jcf, int index, enum cpool_tag purpose)
 	  && kind == CONSTANT_Utf8)
 	;
       else
-	error ("<constant pool index %d unexpected type", index);
+	error ("constant pool index %d unexpected type", index);
     }
 
   switch (kind)
@@ -1420,13 +1420,13 @@ jcf_parse (JCF* jcf)
   bitmap_clear (field_offsets);
 
   if (jcf_parse_preamble (jcf) != 0)
-    fatal_error (input_location, "not a valid Java .class file");
+    fatal_error (input_location, "not a valid Java %<.class%> file");
   code = jcf_parse_constant_pool (jcf);
   if (code != 0)
     fatal_error (input_location, "error while parsing constant pool");
   code = verify_constant_pool (jcf);
   if (code > 0)
-    fatal_error (input_location, "error in constant pool entry #%d\n", code);
+    fatal_error (input_location, "error in constant pool entry %d", code);
 
   jcf_parse_class (jcf);
   if (main_class == NULL_TREE)
@@ -1749,7 +1749,7 @@ java_parse_file (void)
       finput = fopen (main_input_filename, "r");
       if (finput == NULL)
 	fatal_error (input_location,
-		     "can%'t open %s: %m", LOCATION_FILE (input_location));
+		     "cannot open %s: %m", LOCATION_FILE (input_location));
       list = XNEWVEC (char, avail);
       next = list;
       for (;;)
@@ -1884,11 +1884,11 @@ java_parse_file (void)
       /* Close previous descriptor, if any */
       if (finput && fclose (finput))
 	fatal_error (input_location,
-		     "can%'t close input file %s: %m", main_input_filename);
+		     "cannot close input file %s: %m", main_input_filename);
       
       finput = fopen (filename, "rb");
       if (finput == NULL)
-	fatal_error (input_location, "can%'t open %s: %m", filename);
+	fatal_error (input_location, "cannot open %s: %m", filename);
 
 #ifdef IO_BUFFER_SIZE
       setvbuf (finput, xmalloc (IO_BUFFER_SIZE),
diff --git a/gcc/java/jvspec.cc b/gcc/java/jvspec.cc
index 73985751c86..a2010db4c97 100644
--- a/gcc/java/jvspec.cc
+++ b/gcc/java/jvspec.cc
@@ -392,7 +392,7 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
     }
 
   if (saw_D && ! main_class_name)
-    fatal_error (input_location, "can%'t specify %<-D%> without %<--main%>");
+    fatal_error (input_location, "cannot specify %<-D%> without %<--main%>");
 
   if (main_class_name && ! verify_class_name (main_class_name))
     fatal_error (input_location,
@@ -402,21 +402,21 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
   if (saw_resource)
     {
       if (! saw_o)
-	fatal_error (input_location, "--resource requires -o");
+	fatal_error (input_location, "%<--resource%> requires %<-o%>");
     }
   if (saw_C)
     {
       num_args += 3;
       if (class_files_count + zip_files_count > 0)
 	{
-	  warning (0, "already-compiled .class files ignored with -C"); 
+	  warning (0, "already-compiled %<.class%> files ignored with %<-C%>"); 
 	  num_args -= class_files_count + zip_files_count;
 	  class_files_count = 0;
 	  zip_files_count = 0;
 	}
       num_args += 2;  /* For -o NONE. */
       if (saw_o)
-	fatal_error (input_location, "cannot specify both -C and -o");
+	fatal_error (input_location, "cannot specify both %<-C%> and %<-o%>");
     }
   if ((saw_o && java_files_count + class_files_count + zip_files_count > 1)
       || (saw_C && java_files_count > 1)
diff --git a/gcc/java/lang.cc b/gcc/java/lang.cc
index ab204f9531f..742a772bae1 100644
--- a/gcc/java/lang.cc
+++ b/gcc/java/lang.cc
@@ -571,7 +571,7 @@ java_post_options (const char **pfilename)
   /* Excess precision other than "fast" requires front-end
      support.  */
   if (flag_excess_precision_cmdline == EXCESS_PRECISION_STANDARD)
-    sorry ("-fexcess-precision=standard for Java");
+    sorry ("%<-fexcess-precision=standard%> for Java");
   flag_excess_precision_cmdline = EXCESS_PRECISION_FAST;
 
   /* An absolute requirement: if we're not using indirect dispatch, we
@@ -582,10 +582,10 @@ java_post_options (const char **pfilename)
   if (flag_reduced_reflection)
     {
       if (flag_indirect_dispatch)
-        error ("-findirect-dispatch is incompatible "
-               "with -freduced-reflection");
+        error ("%<-findirect-dispatch%> is incompatible "
+               "with %<-freduced-reflection%>");
       if (flag_jni)
-        error ("-fjni is incompatible with -freduced-reflection");
+        error ("%<-fjni%> is incompatible with %<-freduced-reflection%>");
     }
 
   /* Open input file.  */
@@ -596,7 +596,7 @@ java_post_options (const char **pfilename)
       filename = "stdin";
 
       if (dependency_tracking)
-	error ("can%'t do dependency tracking with input from stdin");
+	error ("cannot do dependency tracking with input from stdin");
     }
   else
     {
diff --git a/gcc/java/verify-glue.cc b/gcc/java/verify-glue.cc
index 5921ac7cbb3..37ac971d904 100644
--- a/gcc/java/verify-glue.cc
+++ b/gcc/java/verify-glue.cc
@@ -464,7 +464,7 @@ verify_jvm_instructions_new (JCF *jcf, const unsigned char *byte_ops,
 	  || end_pc < 0 || end_pc > length || start_pc >= end_pc
 	  || handler_pc < 0 || handler_pc >= length)
 	{
-	  error ("bad pc in exception_table");
+	  error ("bad pc in %<exception_table%>");
 	  free (exceptions);
 	  return 0;
 	}
-- 
2.38.1

Reply via email to