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: new gcj option -Wout-of-date


This patch adds `-Wout-of-date' to gcj.  This option controls whether
gcj warns when a .class file is older than a .java file.

It also cleans up warning processing a bit so that the `-Wno-' forms
of warning options are handled.

I needed this patch so that I could tell Jacks to disable the
out-of-date warning.  This eliminates a number of Jacks failures -- I
believe we now do better than jikes on the test suite.

Ok to commit?

2000-11-03  Tom Tromey  <tromey@cygnus.com>

	* lang-options.h: Mention -Wout-of-date.
	* jcf-dump.c (flag_newer): New global.
	* gjavah.c (flag_newer): New global.
	* jcf-io.c (find_class): Only warn when flag_newer set.
	* lang.c (flag_newer): New global.
	(struct string_option): New declaration.
	(lang_W_options): New global.
	(process_option_with_no): New function.
	(lang_decode_option): Use it.


Tom

Index: gjavah.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/gjavah.c,v
retrieving revision 1.63
diff -u -r1.63 gjavah.c
--- gjavah.c	2000/10/21 15:10:38	1.63
+++ gjavah.c	2000/11/04 01:23:30
@@ -47,6 +47,10 @@
 /* Nonzero if we're generating JNI output.  */
 static int flag_jni = 0;
 
+/* When non zero, warn when source file is newer than matching class
+   file.  */
+int flag_newer = 1;
+
 /* Directory to place resulting files in. Set by -d option. */
 const char *output_directory = "";
 
Index: java-tree.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/java-tree.h,v
retrieving revision 1.87
diff -u -r1.87 java-tree.h
--- java-tree.h	2000/10/19 04:19:09	1.87
+++ java-tree.h	2000/11/04 01:23:32
@@ -162,6 +162,10 @@
 extern int flag_not_overriding;
 extern int flag_static_local_jdk1_1;
 
+/* When non zero, warn when source file is newer than matching class
+   file.  */
+extern int flag_newer;
+
 /* When non zero, call a library routine to do integer divisions. */
 extern int flag_use_divide_subroutine;
 
Index: jcf-dump.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/jcf-dump.c,v
retrieving revision 1.33
diff -u -r1.33 jcf-dump.c
--- jcf-dump.c	2000/05/04 18:30:09	1.33
+++ jcf-dump.c	2000/11/04 01:23:33
@@ -71,6 +71,10 @@
 int flag_print_methods = 1;
 int flag_print_attributes = 1;
 
+/* When non zero, warn when source file is newer than matching class
+   file.  */
+int flag_newer = 1;
+
 /* Print names of classes that have a "main" method. */
 int flag_print_main = 0;
 
Index: jcf-io.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/jcf-io.c,v
retrieving revision 1.24
diff -u -r1.24 jcf-io.c
--- jcf-io.c	2000/09/06 02:13:28	1.24
+++ jcf-io.c	2000/11/04 01:23:33
@@ -403,7 +403,8 @@
 	i--;
       
       stripped_class_name [i] = '\0';
-      warning ("Source file for class `%s' is newer than its matching class file. Source file used instead", stripped_class_name);
+      if (flag_newer)
+	warning ("Source file for class `%s' is newer than its matching class file. Source file used instead", stripped_class_name);
       free (stripped_class_name);
       class = -1;
     }
Index: lang-options.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/lang-options.h,v
retrieving revision 1.18
diff -u -r1.18 lang-options.h
--- lang-options.h	2000/10/20 21:19:29	1.18
+++ lang-options.h	2000/11/04 01:23:34
@@ -57,3 +57,4 @@
     "Warn if modifiers are specified when not necessary"},
   { "-Wunsupported-jdk11", "Warn if `final' local variables are specified"},
   { "-Wextraneous-semicolon", "Warn if deprecated empty statements are found"},
+  { "-Wout-of-date", "Warn if .class files are out of date" },
Index: lang.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/lang.c,v
retrieving revision 1.51
diff -u -r1.51 lang.c
--- lang.c	2000/10/20 21:19:29	1.51
+++ lang.c	2000/11/04 01:23:34
@@ -37,10 +37,20 @@
 #include "xref.h"
 #include "ggc.h"
 
+struct string_option
+{
+  const char *string;
+  int *variable;
+  int on_value;
+};
+
 static void put_decl_string PARAMS ((const char *, int));
 static void put_decl_node PARAMS ((tree));
 static void java_dummy_print PARAMS ((const char *));
 static void lang_print_error PARAMS ((const char *));
+static int process_option_with_no PARAMS ((char *,
+					   struct string_option *,
+					   int));
 
 #ifndef OBJECT_SUFFIX
 # define OBJECT_SUFFIX ".o"
@@ -122,6 +132,10 @@
    JNI, not CNI.  */
 int flag_jni = 0;
 
+/* When non zero, warn when source file is newer than matching class
+   file.  */
+int flag_newer = 1;
+
 /* The encoding of the source file.  */
 const char *current_encoding = NULL;
 
@@ -139,7 +153,7 @@
     if `-fSTRING' is seen as an option.
    (If `-fno-STRING' is seen as an option, the opposite value is stored.)  */
 
-static struct { const char *string; int *variable; int on_value;}
+static struct string_option
 lang_f_options[] =
 {
   {"emit-class-file", &flag_emit_class_files, 1},
@@ -150,6 +164,15 @@
   {"jni", &flag_jni, 1}
 };
 
+static struct string_option
+lang_W_options[] =
+{
+  { "unsupported-jdk11", &flag_static_local_jdk1_1, 1 },
+  { "redundant-modifiers", &flag_redundant, 1 },
+  { "extraneous-semicolon", &flag_extraneous_semicolon, 1 },
+  { "out-of-date", &flag_newer, 1 }
+};
+
 JCF *current_jcf;
 
 /* Variable controlling how dependency tracking is enabled in
@@ -162,6 +185,34 @@
 #define DEPEND_TARGET_SET 4
 #define DEPEND_FILE_ALREADY_SET 8
 
+/* Process an option that can accept a `no-' form.
+   Return 1 if option found, 0 otherwise.  */
+static int
+process_option_with_no (p, table, table_size)
+     char *p;
+     struct string_option *table;
+     int table_size;
+{
+  int j;
+
+  for (j = 0; j < table_size; j++)
+    {
+      if (!strcmp (p, table[j].string))
+	{
+	  *table[j].variable = table[j].on_value;
+	  return 1;
+	}
+      if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
+	  && ! strcmp (p+3, table[j].string))
+	{
+	  *table[j].variable = ! table[j].on_value;
+	  return 1;
+	}
+    }
+
+  return 0;
+}
+
 /*
  * process java-specific compiler command-line options
  * return 0, but do not complain if the option is not recognised.
@@ -241,28 +292,9 @@
       /* Some kind of -f option.
 	 P's value is the option sans `-f'.
 	 Search for it in the table of options.  */
-      int found = 0, j;
-
       p += 2;
-
-      for (j = 0; !found && j < (int) ARRAY_SIZE (lang_f_options); j++)
-	{
-	  if (!strcmp (p, lang_f_options[j].string))
-	    {
-	      *lang_f_options[j].variable = lang_f_options[j].on_value;
-	      /* A goto here would be cleaner,
-		 but breaks the vax pcc.  */
-	      found = 1;
-	    }
-	  if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
-	      && ! strcmp (p+3, lang_f_options[j].string))
-	    {
-	      *lang_f_options[j].variable = ! lang_f_options[j].on_value;
-	      found = 1;
-	    }
-	}
-
-      return found;
+      return process_option_with_no (p, lang_f_options,
+				     ARRAY_SIZE (lang_f_options));
     }
 
   if (strcmp (p, "-Wall") == 0)
@@ -275,23 +307,13 @@
       set_Wunused (1);
       return 1;
     }
-
-  if (strcmp (p, "-Wunsupported-jdk11") == 0)
-    {
-      flag_static_local_jdk1_1 = 1;
-      return 1;
-    }
 
-  if (strcmp (p, "-Wredundant-modifiers") == 0)
+  if (p[0] == '-' && p[1] == 'W')
     {
-      flag_redundant = 1;
-      return 1;
-    }
-
-  if (strcmp (p, "-Wextraneous-semicolon") == 0)
-    {
-      flag_extraneous_semicolon = 1;
-      return 1;
+      /* Skip `-W' and see if we accept the option or its `no-' form.  */
+      p += 2;
+      return process_option_with_no (p, lang_W_options,
+				     ARRAY_SIZE (lang_W_options));
     }
 
   if (strcmp (p, "-MD") == 0)

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