Java Patch for warnings part 2

Kaveh R. Ghazi ghazi@caip.rutgers.edu
Tue Jan 25 07:36:00 GMT 2000


This patch gets rid of the last non-literal format string warning in
the java dir.  It does so by making `check_modifiers' a macro so that
the call to `parse_error_context' is passed a literal string rather
than a function parameter char*.  In the process, one new case was
exposed which I fixed too.

Okay to install?

		--Kaveh



2000-01-25  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* parse.y (check_modifiers): Change function into a macro.
	(check_class_interface_creation): Pass a literal format string.

diff -rup orig/egcs-CVS20000124/gcc/java/parse.y egcs-CVS20000124/gcc/java/parse.y
--- orig/egcs-CVS20000124/gcc/java/parse.y	Tue Jan 25 04:20:22 2000
+++ egcs-CVS20000124/gcc/java/parse.y	Tue Jan 25 04:32:27 2000
@@ -70,7 +70,6 @@ definitions and other extensions.  */
 static char *java_accstring_lookup PARAMS ((int));
 static void  classitf_redefinition_error PARAMS ((const char *,tree, tree, tree));
 static void  variable_redefinition_error PARAMS ((tree, tree, tree, int));
-static void  check_modifiers PARAMS ((const char *, int, int));
 static tree  create_class PARAMS ((int, tree, tree, tree));
 static tree  create_interface PARAMS ((int, tree, tree));
 static tree  find_field PARAMS ((tree, tree));
@@ -325,6 +324,22 @@ static tree current_static_block = NULL_
 
 /* The list of all packages we've seen so far */
 static tree package_list = NULL_TREE;
+ 
+/* Check modifiers. If one doesn't fit, retrieve it in its declaration
+   line and point it out.  */
+/* Should point out the one that don't fit. ASCII/unicode, going
+   backward. FIXME */
+
+#define check_modifiers(__message, __value, __mask) do {	\
+  if ((__value) & ~(__mask))					\
+    {								\
+      int i, remainder = (__value) & ~(__mask);			\
+      for (i = 0; i <= 10; i++)					\
+        if ((1 << i) & remainder)				\
+	  parse_error_context (ctxp->modifier_ctx [i], (__message), \
+			       java_accstring_lookup (1 << i)); \
+    }								\
+} while (0)
 
 %}
 
@@ -2882,27 +2897,6 @@ build_unresolved_array_type (type_or_wfl
 			 EXPR_WFL_COLNO (type_or_wfl));
 }
 
-/* Check modifiers. If one doesn't fit, retrieve it in its declaration line
-  and point it out.  */
-
-static void
-check_modifiers (message, value, mask)
-     const char *message;
-     int value;
-     int mask;
-{
-  /* Should point out the one that don't fit. ASCII/unicode,
-     going backward. FIXME */
-  if (value & ~mask)
-    {
-      int i, remainder = value & ~mask;
-      for (i = 0; i <= 10; i++)
-        if ((1 << i) & remainder)
-	  parse_error_context (ctxp->modifier_ctx [i], message, 
-			       java_accstring_lookup (1 << i));
-    }
-}
-
 static void
 parser_add_interface (class_decl, interface_decl, wfl)
      tree class_decl, interface_decl, wfl;
@@ -2967,10 +2961,12 @@ check_class_interface_creation (is_inter
 			     IDENTIFIER_POINTER (raw_name));
     }
 
-  check_modifiers ((is_interface ? 
-		    "Illegal modifier `%s' for interface declaration" :
-		    "Illegal modifier `%s' for class declaration"), flags,
-		   (is_interface ? INTERFACE_MODIFIERS : CLASS_MODIFIERS));
+  if (is_interface)
+    check_modifiers ("Illegal modifier `%s' for interface declaration",
+		     flags, INTERFACE_MODIFIERS);
+  else
+    check_modifiers ("Illegal modifier `%s' for class declaration",
+		     flags, CLASS_MODIFIERS);
   return 0;
 }
 


More information about the Gcc-patches mailing list