OSDN Git Service

* jcf-dump.c (print_constant, disassemble_method): Don't call a
authorghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 14 Oct 1999 17:13:57 +0000 (17:13 +0000)
committerghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 14 Oct 1999 17:13:57 +0000 (17:13 +0000)
variadic function with a non-literal format string.

* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@29981 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/java/ChangeLog
gcc/java/jcf-dump.c
gcc/java/parse-scan.c
gcc/java/parse-scan.y
gcc/java/parse.c
gcc/java/parse.h
gcc/java/parse.y
gcc/java/typeck.c
gcc/java/verify.c

index 1daf2ce..81b8834 100644 (file)
@@ -1,3 +1,19 @@
+1999-10-14  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
+
+       * jcf-dump.c (print_constant, disassemble_method): Don't call a
+       variadic function with a non-literal format string.
+
+       * 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.
+
 Tue Oct 12 22:28:10 1999  Alexandre Petit-Bianco  <apbianco@cygnus.com>
 
        * jcf-write.c (RELOCATION_VALUE_1): Fixed integer value from 0 to 1.
index 2f20e30..becf747 100644 (file)
@@ -386,7 +386,12 @@ DEFUN(print_constant, (out, jcf, index, verbosity),
     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, verbosity),
        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, verbosity),
     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, verbosity),
        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, len),
 #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);
index 6d1b9a4..e69996f 100644 (file)
@@ -2406,7 +2406,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;
        }
     }
index 662323a..f5da6f9 100644 (file)
@@ -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;
        }
     }
index d19a78c..9cc96f8 100644 (file)
@@ -2388,10 +2388,8 @@ int yydebug;                     /*  nonzero means print parse trace     */
 
 /* Prevent warning if -Wstrict-prototypes.  */
 #ifdef __GNUC__
-#ifndef YYPARSE_PARAM
 int yyparse (void);
 #endif
-#endif
 \f
 #if __GNUC__ > 1               /* GNU C and GNU C++ define this.  */
 #define __yy_memcpy(TO,FROM,COUNT)     __builtin_memcpy(TO,FROM,COUNT)
@@ -7911,11 +7909,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;
        }
@@ -11717,11 +11713,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;
     }
@@ -12325,13 +12324,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;
@@ -13191,13 +13198,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;
     }
index cf29219..f4c05e9 100644 (file)
@@ -222,12 +222,19 @@ extern tree stabilize_reference PROTO ((tree));
      "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                                          \
index 3d76576..0459ed3 100644 (file)
@@ -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;
     }
index c6c1708..924265f 100644 (file)
@@ -374,7 +374,11 @@ build_java_array_type (element_type, length)
   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);
+  else
+    buf[1] = '\0';
   sig = ident_subst (IDENTIFIER_POINTER (elsig), IDENTIFIER_LENGTH (elsig),
                     buf, 0, 0, "");
   t = IDENTIFIER_SIGNATURE_TYPE (sig);
index 41eba10..41ad823 100644 (file)
@@ -1344,6 +1344,6 @@ verify_jvm_instructions (jcf, byte_ops, length)
   goto verify_error;
  verify_error:
   error ("verification error at PC=%d", oldpc);
-  error (message);
+  error ("%s", message);
   return 0;
 }