Patch for g77/fortran "format not a string literal" warnings

Jeffrey A Law law@cygnus.com
Tue Nov 30 23:59:00 GMT 1999


  In message < 199911280108.UAA04260@caip.rutgers.edu >you write:
  > 	This patch zaps the "format not a string literal" warnings in
  > the fortran directory.  It does so by making various functions which
  > took a format and fixed args and passed it to sprintf into real
  > variadic functions which call vasprintf (from libiberty.)
  > 
  > Bootstrapped on Irix6, no fortran regressions.  Okay to install?
  > 
  > 		--Kaveh
  > 
  > 
  > 1999-11-27  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
  > 
  > 	* com.c (ffecom_end_transition): Rewrite to take an ellipses.
  > 	
  > 	(ffecom_char_enhance_arg_, ffecom_do_entry_,
  > 	ffecom_f2c_make_type_, ffecom_gen_sfuncdef_,
  > 	ffecom_start_progunit_, ffecom_start_progunit_,
  > 	ffecom_start_progunit_, ffecom_sym_transform_assign_,
  > 	ffecom_transform_equiv_, ffecom_transform_namelist_,
  > 	ffecom_vardesc_, ffecom_vardesc_array_, ffecom_vardesc_dims_,
  > 	ffecom_end_transition, ffecom_lookup_label, ffecom_temp_label):
  > 	Adjust accordingly.
  > 
  > 	* com.h (ffecom_get_invented_identifier): Likewise.
  > 
  > 	* sts.c (ffests_printf): New function taking ellipses.
  > 	(ffests_printf_1D, ffests_printf_1U, ffests_printf_1s,
  > 	ffests_printf_2Us): Delete.
  > 
  > 	* sts.h: Likewise.
  > 
  > 	* std.c (ffestd_R1001dump_, ffestd_R1001dump_1005_1_,
  > 	ffestd_R1001dump_1005_2_, ffestd_R1001dump_1005_3_,
  > 	ffestd_R1001dump_1005_4_, ffestd_R1001dump_1005_5_,
  > 	ffestd_R1001dump_1010_2_, ffestd_R1001dump_1010_3_,
  > 	ffestd_R1001dump_1010_4_, ffestd_R1001dump_1010_5_,
  > 	ffestd_R1001rtexpr_): Call `ffests_printf', not `ffests_printf_*'.
  > 
  > 	* ste.c (ffeste_io_ialist_, ffeste_io_cilist_, ffeste_io_cllist_,
  > 	ffeste_io_icilist_, ffeste_io_inlist_, ffeste_io_olist_): Likewise.
Basically Ok.  Though you got a little sloppy with white space and
formatting issues.

  >  #if BUILT_FOR_270
Offtopic, but anyone/everyone should feel free to kill the BUILT_FOR_270
stuff.  It's obsolete, no longer serves a useful purpose and just
makes the code more difficult to understand.  Similarly for BUILT_FOR_280.

  > -/* Wrapper for get_identifier.  pattern is sprintf-like, assumed to contai
  > n
  > -   one %s if text is not NULL, assumed to contain one %d if number is
  > -   not -1.  If both are assumed, the %s is assumed to precede the %d.  */
  > +
  > +extern int vasprintf (char **, const char *, va_list) ATTRIBUTE_PRINTF(2,0
Err, shouldn't we get this from an include file?  Like libiberty.h?!?

  > +  va_start (ap, pattern);
  > +  if (vasprintf (&nam, pattern, ap) == 0)
  > +    abort();
  > +  va_end(ap);

You need a space before the open paren in those last two lines.

  > diff -rup orig/egcs-CVS19991126/gcc/f/sts.c egcs-CVS19991126/gcc/f/sts.c
  > --- orig/egcs-CVS19991126/gcc/f/sts.c	Tue Mar 30 04:23:44 1999
  > +++ egcs-CVS19991126/gcc/f/sts.c	Sat Nov 27 13:59:01 1999
  > @@ -96,119 +96,27 @@ ffests_new (ffests s, mallocPool pool, f
  >      s->text_ = malloc_new_ksr (pool, "ffests", size);
  >  }
  >  
  > -/* ffests_printf_1D -- printf("...%ld...",(long)) to a string
  > +extern int vasprintf (char **, const char *, va_list) ATTRIBUTE_PRINTF(2,0
Similarly, we should be getting this from an include file somewhere.

  > +  char *string;
  > +  va_list ap;
  > +  
  > +  va_start (ap, ctl);
  > +  if (vasprintf(&string, ctl, ap) == 0)
  > +    abort();
Space before the open paren after vasprintf and abort in the lines
above.

Otherwise it looks good and does cleam up on ugly code in the
g77 front end.  Consider it approved once you clean up the include
file stuff and the minor whitespace nits.
jeff



More information about the Gcc-patches mailing list