prototypes ld/

Alan Modra amodra@bigpond.net.au
Thu Aug 9 17:57:00 GMT 2001


On Fri, Aug 10, 2001 at 12:38:42AM +0930, Alan Modra wrote:
> On Thu, Aug 09, 2001 at 04:51:17PM +0200, Andreas Jaeger wrote:
> > 
> > Shouldn't we add -Wstrict-prototypes to WARN_CFLAGS to catch these?

-Wmissing-prototypes too

> > Here's an untested patch for gas.  If this is ok, I can send similar
> > patches for binutils, bfd and ld.
> 
> Hmm, gas/as.h will generate complaints about it's alloca declaration.
> I'm not sure it's a good idea.

Actually, it probably is a good idea for bfd, opcodes, binutils and ld,
just not gas with the current as.h.  Please test it first though; I can
throw together a patch to do this about as quickly as I can apply one of
your patches, but testing can take a little time.  Make sure to run the
testsuite too.  ld testsuite fails with -Wstrict-prototypes in CFLAGS,
but should be OK in WARN_CFLAGS.

The following should fix gas/as.h.  I'll make a similar change to
macro.c  Any reason why we shouldn't do this?  Ian?

	* as.h (alloca): Test HAVE_ALLOCA_H before __GNUC__.
	Comment indentation of #pragma.

Index: as.h
===================================================================
RCS file: /cvs/src/src/gas/as.h,v
retrieving revision 1.23
diff -c -p -r1.23 as.h
*** as.h	2001/03/08 23:24:21	1.23
--- as.h	2001/08/10 00:47:51
***************
*** 51,70 ****
     --KR 1995.08.08 */
  /* Force void* decl for hpux.  This is what Bison uses.  --KR 1995.08.16 */
  
! /* AIX requires this to be the first thing in the file.  */
! #ifdef __GNUC__
! # ifndef alloca
! #  ifdef __STDC__
  extern void *alloca ();
! #  else
  extern char *alloca ();
  #  endif
- # endif
- #else
- # if HAVE_ALLOCA_H
- #  include <alloca.h>
  # else
  #  ifdef _AIX
   #pragma alloca
  #  else
  #   ifndef alloca /* predefined by HP cc +Olibcalls */
--- 51,72 ----
     --KR 1995.08.08 */
  /* Force void* decl for hpux.  This is what Bison uses.  --KR 1995.08.16 */
  
! #if HAVE_ALLOCA_H
! # include <alloca.h>
! #else
! # ifdef __GNUC__
! #  ifndef alloca
! #   ifdef __STDC__
  extern void *alloca ();
! #   else
  extern char *alloca ();
+ #   endif
  #  endif
  # else
  #  ifdef _AIX
+ /* Indented so that pre-ansi C compilers will ignore it, rather than
+    choke on it.  Some versions of AIX require this to be the first
+    thing in the file.  */
   #pragma alloca
  #  else
  #   ifndef alloca /* predefined by HP cc +Olibcalls */
*************** extern void *alloca ();
*** 75,82 ****
  #    endif /* __STDC__, __hpux */
  #   endif /* alloca */
  #  endif /* _AIX */
! # endif /* HAVE_ALLOCA_H */
! #endif
  
  /* Now, tend to the rest of the configuration.  */
  
--- 77,84 ----
  #    endif /* __STDC__, __hpux */
  #   endif /* alloca */
  #  endif /* _AIX */
! # endif /* __GNUC__ */
! #endif /* HAVE_ALLOCA_H */
  
  /* Now, tend to the rest of the configuration.  */
  
-- 
Alan Modra



More information about the Binutils mailing list