From a3dd1d43955e262a43f0bef0c52e88081f04ff70 Mon Sep 17 00:00:00 2001 From: "Kaveh R. Ghazi" Date: Tue, 23 Nov 1999 15:53:22 +0000 Subject: [PATCH] expr.c (build_chill_function_call): Don't call a variadic function with a non-literal format string. * expr.c (build_chill_function_call): Don't call a variadic function with a non-literal format string. * grant.c (write_spec_module): Likewise. * parse.c (require, expect): Likewise. * tasking.c (get_struct_type_name, get_struct_debug_type_name, get_tasking_code_name, get_struct_variable_name, get_process_wrapper_name, build_start_process): Likewise. * typeck.c (valid_array_index_p): Likewise. From-SVN: r30640 --- gcc/ch/ChangeLog | 15 +++++++++++++++ gcc/ch/expr.c | 12 ++++++------ gcc/ch/grant.c | 9 ++++----- gcc/ch/parse.c | 8 ++------ gcc/ch/tasking.c | 50 ++++++++++++++++++++++++------------------------ gcc/ch/typeck.c | 2 +- 6 files changed, 53 insertions(+), 43 deletions(-) diff --git a/gcc/ch/ChangeLog b/gcc/ch/ChangeLog index 5044fe1ad1c..f7688a1be2d 100644 --- a/gcc/ch/ChangeLog +++ b/gcc/ch/ChangeLog @@ -1,3 +1,18 @@ +1999-11-23 Kaveh R. Ghazi + + * expr.c (build_chill_function_call): Don't call a variadic + function with a non-literal format string. + + * grant.c (write_spec_module): Likewise. + + * parse.c (require, expect): Likewise. + + * tasking.c (get_struct_type_name, get_struct_debug_type_name, + get_tasking_code_name, get_struct_variable_name, + get_process_wrapper_name, build_start_process): Likewise. + + * typeck.c (valid_array_index_p): Likewise. + Sun Oct 31 22:33:33 1999 Jeffrey A Law (law@cygnus.com) * Makefile.in (convert.o, typeck.o): Depend on output.h diff --git a/gcc/ch/expr.c b/gcc/ch/expr.c index b919fde8ddb..e68f3a0b421 100644 --- a/gcc/ch/expr.c +++ b/gcc/ch/expr.c @@ -2512,20 +2512,20 @@ build_chill_function_call (function, expr) if (valtail != 0 && TREE_VALUE (valtail) != void_type_node) { - const char *errstr = "too many arguments to procedure"; if (name) - error ("%s `%s'", errstr, IDENTIFIER_POINTER (name)); + error ("too many arguments to procedure `%s'", + IDENTIFIER_POINTER (name)); else - error (errstr); + error ("too many arguments to procedure"); return error_mark_node; } else if (typetail != 0 && TREE_VALUE (typetail) != void_type_node) { - const char *errstr = "too few arguments to procedure"; if (name) - error ("%s `%s'", errstr, IDENTIFIER_POINTER (name)); + error ("too few arguments to procedure `%s'", + IDENTIFIER_POINTER (name)); else - error (errstr); + error ("too few arguments to procedure"); return error_mark_node; } diff --git a/gcc/ch/grant.c b/gcc/ch/grant.c index 095080f50c7..6fc357d9382 100644 --- a/gcc/ch/grant.c +++ b/gcc/ch/grant.c @@ -2829,9 +2829,8 @@ really_grant_this (decl, granted_decls) /* Write a SPEC MODULE using the declarations in the list DECLS. */ static int header_written = 0; -static const char *header_template = -"--\n-- WARNING: this file was generated by\n\ --- GNUCHILL version %s\n-- based on gcc version %s\n--\n"; +#define HEADER_TEMPLATE "--\n-- WARNING: this file was generated by\n\ +-- GNUCHILL version %s\n-- based on gcc version %s\n--\n" void write_spec_module (decls, granted_decls) @@ -2850,8 +2849,8 @@ write_spec_module (decls, granted_decls) { hdr = (char*) alloca (strlen (gnuchill_version) + strlen (version_string) - + strlen (header_template) + 1); - sprintf (hdr, header_template, gnuchill_version, version_string); + + sizeof (HEADER_TEMPLATE) /* includes \0 */); + sprintf (hdr, HEADER_TEMPLATE, gnuchill_version, version_string); APPEND (gstring, hdr); header_written = 1; } diff --git a/gcc/ch/parse.c b/gcc/ch/parse.c index 36913ce7e4b..e3593df559c 100644 --- a/gcc/ch/parse.c +++ b/gcc/ch/parse.c @@ -332,11 +332,7 @@ require(token) enum terminal token; { if (PEEK_TOKEN() != token) - { - char buf[80]; - sprintf (buf, "internal parser error - expected token %d", (int)token); - fatal(buf); - } + fatal ("internal parser error - expected token %d", (int)token); FORWARD_TOKEN(); } @@ -361,7 +357,7 @@ expect(token, message) if (PEEK_TOKEN() != token) { if (pass == 1) - error(message ? message : "syntax error"); + error("%s", message ? message : "syntax error"); return 0; } else diff --git a/gcc/ch/tasking.c b/gcc/ch/tasking.c index 3b03dea0056..265572fd5e9 100644 --- a/gcc/ch/tasking.c +++ b/gcc/ch/tasking.c @@ -69,18 +69,19 @@ tree tasking_list = NULL_TREE; #define TASK_INFO_STUFF_TYPE(NODE) TREE_VEC_ELT(NODE,4) /* name template for process argument type */ -static const char * struct_name = "__tmp_%s_arg_type"; +#define STRUCT_NAME "__tmp_%s_arg_type" /* name template for process arguments for debugging type */ -static const char * struct_debug_name = "__tmp_%s_debug_type"; +#define STRUCT_DEBUG_NAME "__tmp_%s_debug_type" -#if 0 /* name template for process argument variable */ -static const char * data_name = "__tmp_%s_arg_variable"; -#endif +#define DATA_NAME "__tmp_%s_arg_variable" /* name template for process wrapper */ -static const char * wrapper_name = "__tmp_%s_wrapper"; +#define WRAPPER_NAME "__tmp_%s_wrapper" + +/* name template for process code */ +#define SKELNAME "__tmp_%s_code" extern int ignoring; static tree void_ftype_void; @@ -92,9 +93,9 @@ get_struct_type_name (name) tree name; { const char *idp = IDENTIFIER_POINTER (name); /* process name */ - char *tmpname = xmalloc (strlen (idp) + strlen (struct_name) + 1); + char *tmpname = xmalloc (strlen (idp) + sizeof (STRUCT_NAME)); - sprintf (tmpname, struct_name, idp); + sprintf (tmpname, STRUCT_NAME, idp); return get_identifier (tmpname); } @@ -103,9 +104,9 @@ get_struct_debug_type_name (name) tree name; { const char *idp = IDENTIFIER_POINTER (name); /* process name */ - char *tmpname = xmalloc (strlen (idp) + strlen (struct_debug_name) + 1); + char *tmpname = xmalloc (strlen (idp) + sizeof (STRUCT_DEBUG_NAME)); - sprintf (tmpname, struct_debug_name, idp); + sprintf (tmpname, STRUCT_DEBUG_NAME, idp); return get_identifier (tmpname); } @@ -114,12 +115,11 @@ tree get_tasking_code_name (name) tree name; { - const char *skelname = "__tmp_%s_code"; const char *name_str = IDENTIFIER_POINTER (name); - char *tmpname = (char *)alloca (IDENTIFIER_LENGTH (name) + - strlen (skelname) + 1); - - sprintf (tmpname, skelname, name_str); + char *tmpname = (char *) alloca (IDENTIFIER_LENGTH (name) + + sizeof (SKELNAME)); + + sprintf (tmpname, SKELNAME, name_str); return get_identifier (tmpname); } @@ -129,9 +129,9 @@ get_struct_variable_name (name) tree name; { const char *idp = IDENTIFIER_POINTER (name); /* process name */ - char *tmpname = xmalloc (strlen (idp) + strlen (data_name) + 1); + char *tmpname = xmalloc (strlen (idp) + sizeof (DATA_NAME)); - sprintf (tmpname, data_name, idp); + sprintf (tmpname, DATA_NAME, idp); return get_identifier (tmpname); } #endif @@ -141,9 +141,9 @@ get_process_wrapper_name (name) tree name; { const char *idp = IDENTIFIER_POINTER (name); - char *tmpname = xmalloc (strlen (idp) + strlen (wrapper_name) + 1); + char *tmpname = xmalloc (strlen (idp) + sizeof (WRAPPER_NAME)); - sprintf (tmpname, wrapper_name, idp); + sprintf (tmpname, WRAPPER_NAME, idp); return get_identifier (tmpname); } @@ -627,19 +627,19 @@ build_start_process (process_name, copynum, if (valtail != 0 && TREE_VALUE (valtail) != void_type_node) { - const char *errstr = "too many arguments to process"; if (process_name) - error ("%s `%s'", errstr, IDENTIFIER_POINTER (process_name)); + error ("too many arguments to process `%s'", + IDENTIFIER_POINTER (process_name)); else - error (errstr); + error ("too many arguments to process"); } else if (typetail != 0 && TREE_VALUE (typetail) != void_type_node) { - const char *errstr = "too few arguments to process"; if (process_name) - error ("%s `%s'", errstr, IDENTIFIER_POINTER (process_name)); + error ("too few arguments to process `%s'", + IDENTIFIER_POINTER (process_name)); else - error (errstr); + error ("too few arguments to process"); } else { diff --git a/gcc/ch/typeck.c b/gcc/ch/typeck.c index 8628c952802..d6eeb2a66f1 100644 --- a/gcc/ch/typeck.c +++ b/gcc/ch/typeck.c @@ -155,7 +155,7 @@ valid_array_index_p (array, idx, error_message, is_varying_lhs) { if (tree_int_cst_equal (cond, boolean_false_node)) return idx; /* condition met at compile time */ - error (error_message); /* condition failed at compile time */ + error ("%s", error_message); /* condition failed at compile time */ return error_mark_node; } else if (range_checking) -- 2.30.2