Commit 1ebadc60 by Kaveh R. Ghazi Committed by Kaveh Ghazi

jcf-dump.c (print_constant, [...]): Don't call a variadic function with a…

jcf-dump.c (print_constant, [...]): Don't call a variadic function with a non-literal format string.

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

From-SVN: r29981
parent fe50c0eb
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> 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. * jcf-write.c (RELOCATION_VALUE_1): Fixed integer value from 0 to 1.
......
...@@ -386,7 +386,12 @@ DEFUN(print_constant, (out, jcf, index, verbosity), ...@@ -386,7 +386,12 @@ DEFUN(print_constant, (out, jcf, index, verbosity),
case CONSTANT_Class: case CONSTANT_Class:
n = JPOOL_USHORT1 (jcf, index); n = JPOOL_USHORT1 (jcf, index);
if (verbosity > 0) 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)) if (! CPOOL_INDEX_IN_RANGE (&jcf->cpool, n))
fprintf (out, "<out of range>"); fprintf (out, "<out of range>");
else if (verbosity < 2 && JPOOL_TAG (jcf, n) == CONSTANT_Utf8) else if (verbosity < 2 && JPOOL_TAG (jcf, n) == CONSTANT_Utf8)
...@@ -412,8 +417,10 @@ DEFUN(print_constant, (out, jcf, index, verbosity), ...@@ -412,8 +417,10 @@ DEFUN(print_constant, (out, jcf, index, verbosity),
else if (verbosity > 0) else if (verbosity > 0)
fprintf (out, "%s ", str); fprintf (out, "%s ", str);
print_constant_terse (out, jcf, tclass, CONSTANT_Class); print_constant_terse (out, jcf, tclass, CONSTANT_Class);
fprintf (out, verbosity < 2 ? "." : " name_and_type: %d=<", if (verbosity < 2)
name_and_type); fprintf (out, ".");
else
fprintf (out, " name_and_type: %d=<", name_and_type);
print_constant_terse (out, jcf, name_and_type, CONSTANT_NameAndType); print_constant_terse (out, jcf, name_and_type, CONSTANT_NameAndType);
if (verbosity == 2) if (verbosity == 2)
fputc ('>', out); fputc ('>', out);
...@@ -422,7 +429,12 @@ DEFUN(print_constant, (out, jcf, index, verbosity), ...@@ -422,7 +429,12 @@ DEFUN(print_constant, (out, jcf, index, verbosity),
case CONSTANT_String: case CONSTANT_String:
j = JPOOL_USHORT1 (jcf, index); j = JPOOL_USHORT1 (jcf, index);
if (verbosity > 0) 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); print_constant_terse (out, jcf, j, CONSTANT_Utf8);
break; break;
case CONSTANT_Integer: case CONSTANT_Integer:
...@@ -473,8 +485,12 @@ DEFUN(print_constant, (out, jcf, index, verbosity), ...@@ -473,8 +485,12 @@ DEFUN(print_constant, (out, jcf, index, verbosity),
uint16 name = JPOOL_USHORT1 (jcf, index); uint16 name = JPOOL_USHORT1 (jcf, index);
uint16 sig = JPOOL_USHORT2 (jcf, index); uint16 sig = JPOOL_USHORT2 (jcf, index);
if (verbosity > 0) 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); print_name (out, jcf, name);
if (verbosity <= 1) if (verbosity <= 1)
fputc (' ', out); fputc (' ', out);
...@@ -1002,19 +1018,17 @@ DEFUN(disassemble_method, (jcf, byte_ops, len), ...@@ -1002,19 +1018,17 @@ DEFUN(disassemble_method, (jcf, byte_ops, len),
#define ARRAY_NEW(TYPE) ARRAY_NEW_##TYPE #define ARRAY_NEW(TYPE) ARRAY_NEW_##TYPE
#define ARRAY_NEW_NUM \ #define ARRAY_NEW_NUM \
INT_temp = IMMEDIATE_u1; \ INT_temp = IMMEDIATE_u1; \
{ const char *str; \ { switch (INT_temp) { \
switch (INT_temp) { \ case 4: fputs (" boolean", out); break; \
case 4: str = "boolean"; break; \ case 5: fputs (" char", out); break; \
case 5: str = "char"; break; \ case 6: fputs (" float", out); break; \
case 6: str = "float"; break; \ case 7: fputs (" double", out); break; \
case 7: str = "double"; break; \ case 8: fputs (" byte", out); break; \
case 8: str = "byte"; break; \ case 9: fputs (" short", out); break; \
case 9: str = "short"; break; \ case 10: fputs (" int", out); break; \
case 10: str = "int"; break; \ case 11: fputs (" long", out); break; \
case 11: str = "long"; break; \ default: fprintf (out, " <unknown type code %ld>", (long)INT_temp); break;\
default: str = "<unknown type code %d>"; break; \ } }
} \
fputc (' ', out); fprintf (out, str, INT_temp); }
#define ARRAY_NEW_PTR \ #define ARRAY_NEW_PTR \
fputc (' ', out); print_constant_ref (out, jcf, IMMEDIATE_u2); fputc (' ', out); print_constant_ref (out, jcf, IMMEDIATE_u2);
......
...@@ -2406,7 +2406,7 @@ report_main_declaration (declarator) ...@@ -2406,7 +2406,7 @@ report_main_declaration (declarator)
if (package_name) if (package_name)
fprintf (out, "%s.%s ", package_name, current_class); fprintf (out, "%s.%s ", package_name, current_class);
else else
fprintf (out, current_class); fprintf (out, "%s", current_class);
previous_output = 1; previous_output = 1;
} }
} }
......
...@@ -1156,7 +1156,7 @@ report_main_declaration (declarator) ...@@ -1156,7 +1156,7 @@ report_main_declaration (declarator)
if (package_name) if (package_name)
fprintf (out, "%s.%s ", package_name, current_class); fprintf (out, "%s.%s ", package_name, current_class);
else else
fprintf (out, current_class); fprintf (out, "%s", current_class);
previous_output = 1; previous_output = 1;
} }
} }
......
...@@ -2388,10 +2388,8 @@ int yydebug; /* nonzero means print parse trace */ ...@@ -2388,10 +2388,8 @@ int yydebug; /* nonzero means print parse trace */
/* Prevent warning if -Wstrict-prototypes. */ /* Prevent warning if -Wstrict-prototypes. */
#ifdef __GNUC__ #ifdef __GNUC__
#ifndef YYPARSE_PARAM
int yyparse (void); int yyparse (void);
#endif #endif
#endif
#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
...@@ -7911,11 +7909,9 @@ read_import_dir (wfl) ...@@ -7911,11 +7909,9 @@ read_import_dir (wfl)
static int first = 1; static int first = 1;
if (first) if (first)
{ {
char buffer [256]; error ("Can't find default package `%s'. Check "
sprintf (buffer, "Can't find default package `%s'. Check "
"the CLASSPATH environment variable and the access to the " "the CLASSPATH environment variable and the access to the "
"archives.", package_name); "archives.", package_name);
error (buffer);
java_error_count++; java_error_count++;
first = 0; first = 0;
} }
...@@ -11717,11 +11713,14 @@ patch_assignment (node, wfl_op1, wfl_op2) ...@@ -11717,11 +11713,14 @@ patch_assignment (node, wfl_op1, wfl_op2)
strcpy (operation, "`='"); strcpy (operation, "`='");
} }
parse_error_context if (!valid_cast_to_p (rhs_type, lhs_type))
(wfl, (!valid_cast_to_p (rhs_type, lhs_type) ? parse_error_context (wfl, "Incompatible type for %s. "
"Incompatible type for %s. Can't convert `%s' to `%s'" : "Can't convert `%s' to `%s'",
"Incompatible type for %s. Explicit cast " operation, t1, t2);
"needed to 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); free (t1); free (t2);
error_found = 1; error_found = 1;
} }
...@@ -12325,13 +12324,21 @@ patch_binop (node, wfl_op1, wfl_op2) ...@@ -12325,13 +12324,21 @@ patch_binop (node, wfl_op1, wfl_op2)
if (!JINTEGRAL_TYPE_P (op1_type)) if (!JINTEGRAL_TYPE_P (op1_type))
ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op1_type); ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op1_type);
else else
parse_error_context {
(wfl_operator, (JPRIMITIVE_TYPE_P (op2_type) ? if (JPRIMITIVE_TYPE_P (op2_type))
"Incompatible type for `%s'. Explicit cast needed to convert " parse_error_context (wfl_operator,
"shift distance from `%s' to integral" : "Incompatible type for `%s'. "
"Incompatible type for `%s'. Can't convert shift distance from " "Explicit cast needed to convert "
"`%s' to integral"), "shift distance from `%s' to integral",
operator_string (node), lang_printable_name (op2_type, 0)); 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; TREE_TYPE (node) = error_mark_node;
error_found = 1; error_found = 1;
break; break;
...@@ -13191,12 +13198,13 @@ patch_array_ref (node) ...@@ -13191,12 +13198,13 @@ patch_array_ref (node)
index = do_unary_numeric_promotion (index); index = do_unary_numeric_promotion (index);
if (TREE_TYPE (index) != int_type_node) if (TREE_TYPE (index) != int_type_node)
{ {
int could_cast = valid_cast_to_p (index_type, int_type_node); if (valid_cast_to_p (index_type, int_type_node))
parse_error_context parse_error_context (wfl_operator, "Incompatible type for `[]'. "
(wfl_operator, "Explicit cast needed to convert `%s' to `int'",
(could_cast ? "Incompatible type for `[]'. Explicit cast needed to " lang_printable_name (index_type, 0));
"convert `%s' to `int'" : "Incompatible type for `[]'. " else
"Can't convert `%s' to `int'"), parse_error_context (wfl_operator, "Incompatible type for `[]'. "
"Can't convert `%s' to `int'",
lang_printable_name (index_type, 0)); lang_printable_name (index_type, 0));
TREE_TYPE (node) = error_mark_node; TREE_TYPE (node) = error_mark_node;
error_found = 1; error_found = 1;
......
...@@ -222,12 +222,19 @@ extern tree stabilize_reference PROTO ((tree)); ...@@ -222,12 +222,19 @@ extern tree stabilize_reference PROTO ((tree));
"numeric type", operator_string ((NODE)), lang_printable_name ((TYPE), 0)) "numeric type", operator_string ((NODE)), lang_printable_name ((TYPE), 0))
#define ERROR_CAST_NEEDED_TO_INTEGRAL(OPERATOR, NODE, TYPE) \ #define ERROR_CAST_NEEDED_TO_INTEGRAL(OPERATOR, NODE, TYPE) \
parse_error_context \ do { \
((OPERATOR), (JPRIMITIVE_TYPE_P (TYPE) ? \ tree _operator = (OPERATOR), _node = (NODE), _type = (TYPE); \
"Incompatible type for `%s'. Explicit cast needed to convert " \ if (JPRIMITIVE_TYPE_P (_type)) \
"`%s' to integral" : "Incompatible type for `%s'. Can't convert " \ parse_error_context (_operator, "Incompatible type for `%s'. Explicit" \
"`%s' to integral"), operator_string ((NODE)), \ " cast needed to convert `%s' to integral", \
lang_printable_name ((TYPE), 0)) 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) \ #define ERROR_VARIABLE_NOT_INITIALIZED(WFL, V) \
parse_error_context \ parse_error_context \
......
...@@ -5324,11 +5324,9 @@ read_import_dir (wfl) ...@@ -5324,11 +5324,9 @@ read_import_dir (wfl)
static int first = 1; static int first = 1;
if (first) if (first)
{ {
char buffer [256]; error ("Can't find default package `%s'. Check "
sprintf (buffer, "Can't find default package `%s'. Check "
"the CLASSPATH environment variable and the access to the " "the CLASSPATH environment variable and the access to the "
"archives.", package_name); "archives.", package_name);
error (buffer);
java_error_count++; java_error_count++;
first = 0; first = 0;
} }
...@@ -9130,11 +9128,14 @@ patch_assignment (node, wfl_op1, wfl_op2) ...@@ -9130,11 +9128,14 @@ patch_assignment (node, wfl_op1, wfl_op2)
strcpy (operation, "`='"); strcpy (operation, "`='");
} }
parse_error_context if (!valid_cast_to_p (rhs_type, lhs_type))
(wfl, (!valid_cast_to_p (rhs_type, lhs_type) ? parse_error_context (wfl, "Incompatible type for %s. "
"Incompatible type for %s. Can't convert `%s' to `%s'" : "Can't convert `%s' to `%s'",
"Incompatible type for %s. Explicit cast " operation, t1, t2);
"needed to 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); free (t1); free (t2);
error_found = 1; error_found = 1;
} }
...@@ -9738,13 +9739,21 @@ patch_binop (node, wfl_op1, wfl_op2) ...@@ -9738,13 +9739,21 @@ patch_binop (node, wfl_op1, wfl_op2)
if (!JINTEGRAL_TYPE_P (op1_type)) if (!JINTEGRAL_TYPE_P (op1_type))
ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op1_type); ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op1_type);
else else
parse_error_context {
(wfl_operator, (JPRIMITIVE_TYPE_P (op2_type) ? if (JPRIMITIVE_TYPE_P (op2_type))
"Incompatible type for `%s'. Explicit cast needed to convert " parse_error_context (wfl_operator,
"shift distance from `%s' to integral" : "Incompatible type for `%s'. "
"Incompatible type for `%s'. Can't convert shift distance from " "Explicit cast needed to convert "
"`%s' to integral"), "shift distance from `%s' to integral",
operator_string (node), lang_printable_name (op2_type, 0)); 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; TREE_TYPE (node) = error_mark_node;
error_found = 1; error_found = 1;
break; break;
...@@ -10604,12 +10613,13 @@ patch_array_ref (node) ...@@ -10604,12 +10613,13 @@ patch_array_ref (node)
index = do_unary_numeric_promotion (index); index = do_unary_numeric_promotion (index);
if (TREE_TYPE (index) != int_type_node) if (TREE_TYPE (index) != int_type_node)
{ {
int could_cast = valid_cast_to_p (index_type, int_type_node); if (valid_cast_to_p (index_type, int_type_node))
parse_error_context parse_error_context (wfl_operator, "Incompatible type for `[]'. "
(wfl_operator, "Explicit cast needed to convert `%s' to `int'",
(could_cast ? "Incompatible type for `[]'. Explicit cast needed to " lang_printable_name (index_type, 0));
"convert `%s' to `int'" : "Incompatible type for `[]'. " else
"Can't convert `%s' to `int'"), parse_error_context (wfl_operator, "Incompatible type for `[]'. "
"Can't convert `%s' to `int'",
lang_printable_name (index_type, 0)); lang_printable_name (index_type, 0));
TREE_TYPE (node) = error_mark_node; TREE_TYPE (node) = error_mark_node;
error_found = 1; error_found = 1;
......
...@@ -374,7 +374,11 @@ build_java_array_type (element_type, length) ...@@ -374,7 +374,11 @@ build_java_array_type (element_type, length)
char buf[12]; char buf[12];
tree elsig = build_java_signature (element_type); tree elsig = build_java_signature (element_type);
tree el_name = 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), sig = ident_subst (IDENTIFIER_POINTER (elsig), IDENTIFIER_LENGTH (elsig),
buf, 0, 0, ""); buf, 0, 0, "");
t = IDENTIFIER_SIGNATURE_TYPE (sig); t = IDENTIFIER_SIGNATURE_TYPE (sig);
......
...@@ -1344,6 +1344,6 @@ verify_jvm_instructions (jcf, byte_ops, length) ...@@ -1344,6 +1344,6 @@ verify_jvm_instructions (jcf, byte_ops, length)
goto verify_error; goto verify_error;
verify_error: verify_error:
error ("verification error at PC=%d", oldpc); error ("verification error at PC=%d", oldpc);
error (message); error ("%s", message);
return 0; return 0;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment