This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Fix implicit declaration warnings for alloca in target files
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 16 Sep 2004 08:55:50 -0400 (EDT)
- Subject: Fix implicit declaration warnings for alloca in target files
As suggested by rth here:
http://gcc.gnu.org/ml/gcc-patches/2004-09/msg01630.html
for target files we may as well simply define alloca to
__builtin_alloca globally. Doing so eliminates some potential
problems on solaris2:
> libgcov.c:617: warning: implicit declaration of function 'alloca'
> libgcov.c:617: warning: incompatible implicit declaration of built-in function 'alloca'
> libgcov.c:648: warning: implicit declaration of function 'alloca'
> libgcov.c:648: warning: incompatible implicit declaration of built-in function 'alloca'
> libgcov.c:680: warning: implicit declaration of function 'alloca'
> libgcov.c:680: warning: incompatible implicit declaration of built-in function 'alloca'
I also reverted a local fix I made for this same problem in another
target file.
Bootstrapped on sparc-sun-solaris2.9, on c,c++,objc (cause that's all
that works right now), no regressions.
Ok for mainline?
Thanks,
--Kaveh
2004-09-15 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* tsystem.h (alloca): Provide a default definition.
Revert:
2001-08-31 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* unwind-dw2.c: Call __builtin_alloca, not alloca.
diff -rup orig/egcc-CVS20040915/gcc/tsystem.h egcc-CVS20040915/gcc/tsystem.h
--- orig/egcc-CVS20040915/gcc/tsystem.h 2004-09-03 13:44:36.000000000 -0400
+++ egcc-CVS20040915/gcc/tsystem.h 2004-09-15 21:22:09.170793015 -0400
@@ -117,4 +117,9 @@ extern int errno;
#define NULL 0
#endif
+/* GCC always provides __builtin_alloca(x). */
+#ifndef alloca
+#define alloca(x) __builtin_alloca(x)
+#endif
+
#endif /* ! GCC_TSYSTEM_H */
diff -rup orig/egcc-CVS20040915/gcc/unwind-dw2.c egcc-CVS20040915/gcc/unwind-dw2.c
--- orig/egcc-CVS20040915/gcc/unwind-dw2.c 2004-09-07 21:32:54.000000000 -0400
+++ egcc-CVS20040915/gcc/unwind-dw2.c 2004-09-15 21:20:50.588368991 -0400
@@ -840,7 +840,7 @@ execute_cfa_program (const unsigned char
unused_rs = unused_rs->prev;
}
else
- new_rs = __builtin_alloca (sizeof (struct frame_state_reg_info));
+ new_rs = alloca (sizeof (struct frame_state_reg_info));
*new_rs = fs->regs;
fs->regs.prev = new_rs;