C++ dir warning patch part 5/5

Kaveh R. Ghazi ghazi@caip.rutgers.edu
Thu Mar 25 10:18:00 GMT 1999


	These patches mainly address warnings in the cp/ directory
exposed by using extra warning flags: -Wstrict-prototypes
-Wmissing-prototypes -Wmissing-declarations and -Wwrite-strings.
 
	This is part 5/5, okay to install?
 
		Thanks,
		--Kaveh



Wed Mar 24 18:54:26 1999  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* tree.c (compiler_error): Don't prototype.
	(no_linkage_helper, build_srcloc): Add static prototype.
	(build_vbase_pointer_fields): Const-ify a char*.
	(__eprintf): Don't unnecessarily handle `const' when !__STDC__.

	* typeck.c (compiler_error): Don't prototype.
	(convert_for_assignment): Const-ify a char*.
	(comp_cv_target_types): Add static prototype.
	(build_x_indirect_ref, build_indirect_ref, convert_arguments,
	build_component_addr, build_unary_op, convert_for_initialization):
	Const-ify a char*.

	* typeck2.c (ack): Add static prototype and change from fixed args
	to variable args.
	(readonly_error, check_for_new_type): Const-ify a char*.

	* xref.c (_XREF_FILE, find_file, filename, fctname, declname,
	fixname, open_xref_file, classname, GNU_xref_begin): Likewise.
	(GNU_xref_file): Likewise.  Also use `xmalloc' instead of `malloc'.
	(GNU_xref_end_scope, GNU_xref_ref, GNU_xref_decl, GNU_xref_call,
	gen_assign, GNU_xref_member): Const-ify a char*.



diff -rup orig/egcs-CVS19990323/gcc/cp/tree.c egcs-CVS19990323/gcc/cp/tree.c
--- orig/egcs-CVS19990323/gcc/cp/tree.c	Wed Mar 17 09:19:51 1999
+++ egcs-CVS19990323/gcc/cp/tree.c	Wed Mar 24 14:19:30 1999
@@ -28,8 +28,6 @@ Boston, MA 02111-1307, USA.  */
 #include "rtl.h"
 #include "toplev.h"
 
-extern void compiler_error ();
-
 static tree get_identifier_list PROTO((tree));
 static tree bot_manip PROTO((tree));
 static tree perm_manip PROTO((tree));
@@ -42,6 +40,8 @@ static void propagate_binfo_offsets PROT
 static int avoid_overlap PROTO((tree, tree));
 static int lvalue_p_1 PROTO((tree, int));
 static int equal_functions PROTO((tree, tree));
+static tree no_linkage_helper PROTO((tree));
+static tree build_srcloc PROTO((char *, int));
 
 #define CEIL(x,y) (((x) + (y) - 1) / (y))
 
@@ -881,7 +881,7 @@ build_vbase_pointer_fields (rec)
       if (TREE_VIA_VIRTUAL (base_binfo))
 	{
 	  int j;
-	  char *name;
+	  const char *name;
 
 	  /* The offset for a virtual base class is only used in computing
 	     virtual function tables and for initializing virtual base
@@ -2132,17 +2132,10 @@ print_lang_statistics ()
 
 void
 __eprintf (string, expression, line, filename)
-#ifdef __STDC__
      const char *string;
      const char *expression;
      unsigned line;
      const char *filename;
-#else
-     char *string;
-     char *expression;
-     unsigned line;
-     char *filename;
-#endif
 {
   fprintf (stderr, string, expression, line, filename);
   fflush (stderr);
@@ -2604,7 +2597,7 @@ build_int_wrapper (i)
   return t;
 }
 
-tree
+static tree
 build_srcloc (file, line)
      char *file;
      int line;
diff -rup orig/egcs-CVS19990323/gcc/cp/typeck.c egcs-CVS19990323/gcc/cp/typeck.c
--- orig/egcs-CVS19990323/gcc/cp/typeck.c	Tue Mar 23 09:49:38 1999
+++ egcs-CVS19990323/gcc/cp/typeck.c	Wed Mar 24 13:41:50 1999
@@ -39,9 +39,7 @@ Boston, MA 02111-1307, USA.  */
 #include "expr.h"
 #include "toplev.h"
 
-extern void compiler_error ();
-
-static tree convert_for_assignment PROTO((tree, tree, char*, tree,
+static tree convert_for_assignment PROTO((tree, tree, const char *, tree,
 					  int));
 static tree pointer_int_sum PROTO((enum tree_code, tree, tree));
 static tree rationalize_conditional_expr PROTO((enum tree_code, tree));
@@ -59,6 +57,7 @@ static tree lookup_anon_field PROTO((tre
 static tree pointer_diff PROTO((tree, tree, tree));
 static tree qualify_type PROTO((tree, tree));
 static tree get_delta_difference PROTO((tree, tree, int));
+static int comp_cv_target_types PROTO((tree, tree, int));
 
 /* Return the target type of TYPE, which meas return T for:
    T*, T&, T[], T (...), and otherwise, just T.  */
@@ -2302,7 +2301,7 @@ build_x_component_ref (datum, component,
 tree
 build_x_indirect_ref (ptr, errorstring)
      tree ptr;
-     char *errorstring;
+     const char *errorstring;
 {
   tree rval;
 
@@ -2319,7 +2318,7 @@ build_x_indirect_ref (ptr, errorstring)
 tree
 build_indirect_ref (ptr, errorstring)
      tree ptr;
-     char *errorstring;
+     const char *errorstring;
 {
   register tree pointer, type;
 
@@ -3064,7 +3063,7 @@ convert_arguments (typelist, values, fnd
 {
   register tree typetail, valtail;
   register tree result = NULL_TREE;
-  char *called_thing = 0;
+  const char *called_thing = 0;
   int i = 0;
 
   /* Argument passing is always copy-initialization.  */
@@ -4227,7 +4226,7 @@ pointer_diff (op0, op1, ptrtype)
 tree
 build_component_addr (arg, argtype, msg)
      tree arg, argtype;
-     char *msg;
+     const char *msg;
 {
   tree field = TREE_OPERAND (arg, 1);
   tree basetype = decl_type_context (field);
@@ -4339,7 +4338,7 @@ build_unary_op (code, xarg, noconvert)
   /* No default_conversion here.  It causes trouble for ADDR_EXPR.  */
   register tree arg = xarg;
   register tree argtype = 0;
-  char *errstring = NULL;
+  const char *errstring = NULL;
   tree val;
 
   if (arg == error_mark_node)
@@ -6623,7 +6622,7 @@ pfn_from_ptrmemfunc (t)
 static tree
 convert_for_assignment (type, rhs, errtype, fndecl, parmnum)
      tree type, rhs;
-     char *errtype;
+     const char *errtype;
      tree fndecl;
      int parmnum;
 {
@@ -7058,7 +7057,7 @@ tree
 convert_for_initialization (exp, type, rhs, flags, errtype, fndecl, parmnum)
      tree exp, type, rhs;
      int flags;
-     char *errtype;
+     const char *errtype;
      tree fndecl;
      int parmnum;
 {
diff -rup orig/egcs-CVS19990323/gcc/cp/typeck2.c egcs-CVS19990323/gcc/cp/typeck2.c
--- orig/egcs-CVS19990323/gcc/cp/typeck2.c	Sat Mar 13 11:54:21 1999
+++ egcs-CVS19990323/gcc/cp/typeck2.c	Wed Mar 24 13:48:21 1999
@@ -38,6 +38,7 @@ Boston, MA 02111-1307, USA.  */
 #include "toplev.h"
 
 static tree process_init_constructor PROTO((tree, tree, tree *));
+static void ack PVPROTO ((const char *, ...)) ATTRIBUTE_PRINTF_1;
 
 extern int errorcount;
 extern int sorrycount;
@@ -80,11 +81,11 @@ binfo_or_else (parent_or_type, type)
 void
 readonly_error (arg, string, soft)
      tree arg;
-     char *string;
+     const char *string;
      int soft;
 {
-  char *fmt;
-  void (*fn)();
+  const char *fmt;
+  void (*fn) PVPROTO ((const char *, ...));
 
   if (soft)
     fn = cp_pedwarn;
@@ -274,19 +275,28 @@ retry:
 /* Like error(), but don't call report_error_function().  */
 
 static void
-ack (s, v, v2)
-     char *s;
-     HOST_WIDE_INT v;
-     HOST_WIDE_INT v2;
+ack VPROTO ((const char *msg, ...))
 {
+#ifndef ANSI_PROTOTYPES
+  const char *msg;
+#endif
+  va_list ap;
   extern char * progname;
   
+  VA_START (ap, msg);
+
+#ifndef ANSI_PROTOTYPES
+  msg = va_arg (ap, const char *);
+#endif
+  
   if (input_filename)
     fprintf (stderr, "%s:%d: ", input_filename, lineno);
   else
     fprintf (stderr, "%s: ", progname);
 
-  fprintf (stderr, s, v, v2);
+  vfprintf (stderr, msg, ap);
+  va_end (ap);
+  
   fprintf (stderr, "\n");
 }
   
@@ -1640,7 +1650,7 @@ report_case_error (code, type, new_value
 
 void
 check_for_new_type (string, inptree)
-     char *string;
+     const char *string;
      flagged_type_tree inptree;
 {
   if (inptree.new_type_flag
diff -rup orig/egcs-CVS19990323/gcc/cp/xref.c egcs-CVS19990323/gcc/cp/xref.c
--- orig/egcs-CVS19990323/gcc/cp/xref.c	Wed Dec 16 16:16:20 1998
+++ egcs-CVS19990323/gcc/cp/xref.c	Wed Mar 24 14:40:17 1999
@@ -86,8 +86,8 @@ typedef struct _XREF_SCOPE *	XREF_SCOPE;
 
 typedef struct _XREF_FILE
 {
-  char *name;
-  char *outname;
+  const char *name;
+  const char *outname;
   XREF_FILE next;
 } XREF_FILE_INFO;
 
@@ -122,19 +122,20 @@ static	tree		last_fndecl = NULL;
 /*									*/
 /************************************************************************/
 static	void		gen_assign PROTO((XREF_FILE, tree));
-static	XREF_FILE	find_file PROTO((char *));
-static	char *		filename PROTO((XREF_FILE));
-static	char *		fctname PROTO((tree));
-static	char *		declname PROTO((tree));
+static	XREF_FILE	find_file PROTO((const char *));
+static	const char *	filename PROTO((XREF_FILE));
+static	const char *	fctname PROTO((tree));
+static	const char *	declname PROTO((tree));
 static	void		simplify_type PROTO((char *));
-static	char *		fixname PROTO((char *, char *));
-static	void		open_xref_file PROTO((char *));
+static	const char *	fixname PROTO((const char *, char *));
+static	void		open_xref_file PROTO((const char *));
+static  const char *	classname PROTO((tree));
 
 /* Start cross referencing.  FILE is the name of the file we xref.  */
 
 void
 GNU_xref_begin (file)
-   char *file;
+   const char *file;
 {
   doing_xref = 1;
 
@@ -178,7 +179,7 @@ GNU_xref_end (ect)
 
 void
 GNU_xref_file (name)
-   char *name;
+   const char *name;
 {
   XREF_FILE xf;
 
@@ -209,8 +210,8 @@ GNU_xref_file (name)
   else
     {
       char *nmbuf
-	= (char *) malloc (strlen (wd_name) + strlen (FILE_NAME_JOINER)
-			   + strlen (name) + 1);
+	= (char *) xmalloc (strlen (wd_name) + strlen (FILE_NAME_JOINER)
+			    + strlen (name) + 1);
       sprintf (nmbuf, "%s%s%s", wd_name, FILE_NAME_JOINER, name);
       name = nmbuf;
       xf->outname = nmbuf;
@@ -259,7 +260,7 @@ GNU_xref_end_scope (id,inid,prm,keep)
 {
   XREF_FILE xf;
   XREF_SCOPE xs,lxs,oxs;
-  char *stype;
+  const char *stype;
 
   if (!doing_xref) return;
   xf = find_file (input_filename);
@@ -302,7 +303,7 @@ GNU_xref_end_scope (id,inid,prm,keep)
 void
 GNU_xref_ref (fndecl,name)
    tree fndecl;
-   char *name;
+   const char *name;
 {
   XREF_FILE xf;
 
@@ -322,8 +323,8 @@ GNU_xref_decl (fndecl,decl)
    tree decl;
 {
   XREF_FILE xf,xf1;
-  char *cls = 0;
-  char *name;
+  const char *cls = 0;
+  const char *name;
   char buf[10240];
   int uselin;
 
@@ -432,11 +433,11 @@ GNU_xref_decl (fndecl,decl)
 void
 GNU_xref_call (fndecl, name)
    tree fndecl;
-   char *name;
+   const char *name;
 {
   XREF_FILE xf;
   char buf[1024];
-  char *s;
+  const char *s;
 
   if (!doing_xref) return;
   xf = find_file (input_filename);
@@ -508,7 +509,7 @@ gen_assign(xf, name)
    XREF_FILE xf;
    tree name;
 {
-  char *s;
+  const char *s;
 
   s = NULL;
 
@@ -541,7 +542,7 @@ gen_assign(xf, name)
     fprintf(xref_file, "ASG %s %d %s\n", filename(xf), lineno, s);
 }
 
-static char*
+static const char *
 classname (cls)
      tree cls;
 {
@@ -590,9 +591,9 @@ GNU_xref_member(cls, fld)
    tree fld;
 {
   XREF_FILE xf;
-  char *prot;
+  const char *prot;
   int confg, pure;
-  char *d;
+  const char *d;
 #ifdef XREF_SHORT_MEMBER_NAMES
   int i;
 #endif
@@ -651,7 +652,7 @@ GNU_xref_member(cls, fld)
 
 static XREF_FILE
 find_file(name)
-   char *name;
+   const char *name;
 {
   XREF_FILE xf;
 
@@ -664,7 +665,7 @@ find_file(name)
 
 /* Return filename for output purposes.  */
 
-static char *
+static const char *
 filename(xf)
    XREF_FILE xf;
 {
@@ -682,12 +683,12 @@ filename(xf)
 
 /* Return function name for output purposes.  */
 
-static char *
+static const char *
 fctname(fndecl)
    tree fndecl;
 {
   static char fctbuf[1024];
-  char *s;
+  const char *s;
 
   if (fndecl == NULL && last_fndecl == NULL) return "*";
 
@@ -709,7 +710,7 @@ fctname(fndecl)
 
 /* Return decl name for output purposes.  */
 
-static char *
+static const char *
 declname(dcl)
    tree dcl;
 {
@@ -773,12 +774,13 @@ simplify_type(typ)
 
 /* Fixup a function name (take care of embedded spaces).  */
 
-static char *
+static const char *
 fixname(nam, buf)
-   char *nam;
+   const char *nam;
    char *buf;
 {
-  char *s, *t;
+  const char *s;
+  char *t;
   int fg;
 
   s = nam;
@@ -806,9 +808,10 @@ fixname(nam, buf)
 
 static void
 open_xref_file(file)
-   char *file;
+   const char *file;
 {
-  char *s, *t;
+  const char *s;
+  char *t;
 
 #ifdef XREF_FILE_NAME
   XREF_FILE_NAME (xref_name, file);


More information about the Gcc-patches mailing list