This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
egcs-980315, gen*.c system.h and fatal() using stdarg/varargs
- To: egcs at cygnus dot com
- Subject: egcs-980315, gen*.c system.h and fatal() using stdarg/varargs
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Date: Thu, 19 Mar 1998 21:08:43 -0500 (EST)
- Cc: ghazi at caip dot rutgers dot edu, law at cygnus dot com, wilson at cygnus dot com
Here is my patch to add system.h to gen*.c. It also fixes the
static function `fatal' to use real variable argument parameter lists.
Is so doing, I uncovered some format specifier problems in
genattrtab.c:
> ./genattrtab.c:979: warning: char format, rtx_def arg (arg 2)
> ./genattrtab.c:984: warning: char format, rtx_def arg (arg 2)
> ./genattrtab.c:1001: warning: char format, rtx_def arg (arg 2)
> ./genattrtab.c:1012: warning: char format, rtx_def arg (arg 2)
> ./genattrtab.c:1012: warning: char format, rtx_def arg (arg 3)
All of these cases appear to be using a %s to print a XEXP(rtx,N).
Should these instead be changed to %s and XSTR(rtx,N) ?
One other thing, I defined a PRINTF_ATTRIBUTE macro in
system.h along the lines of a similar trick in cccp.c. However I'm
not sure that system.h is the right place for this.
I envision system.h as handling system header files, functions,
macros and related issues. It seems like __attribute__, being a
compiler characteristic, is something for which gansidecl.h is to be
used for. (Also along these lines, the bcopy/index stuff should be
removed from gansidecl.h now that system.h handles that. But that's for
another day.)
Anyway, which header file should define PRINTF_ATTRIBUTE,
system.h or gansidecl.h?
--Kaveh
Thu Mar 19 20:31:59 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* Makefile.in (genconfig.o, genflags.o, gencodes.o, genemit.o,
genopinit.o, genrecog.o, genextract.o, genpeep.o, genattr.o,
genattrtab.o, genoutput.o): Depend on system.h.
* system.h: Define macro PRINTF_ATTRIBUTE to use __attribute__
format __printf__ when using gcc >= v2.7, otherwise define it
to nothing. Define PRINTF_ATTRIBUTE_1, PRINTF_ATTRIBUTE_2 and
PRINTF_ATTRIBUTE_3 in terms of PRINTF_ATTRIBUTE.
* genattr.c: Include stdarg.h/varargs.h and system.h. Change
function `fatal' to use variable arguments instead of faking it
with unnamed integer parameters. Provide a prototype which also
checks the format specifiers using PRINTF_ATTRIBUTE_1.
* genattrtab.c: Likewise.
* gencodes.c: Likewise.
* genconfig.c: Likewise.
* genemit.c: Likewise.
* genextract.c: Likewise.
* genflags.c: Likewise.
* genopinit.c: Likewise.
* genpeep.c: Likewise.
* genrecog.c: Likewise.
* genoutput.c: Likewise. Similarly for function `error'.
diff -rup orig/egcs-980315/gcc/Makefile.in egcs-980315/gcc/Makefile.in
--- orig/egcs-980315/gcc/Makefile.in Thu Feb 19 14:12:33 1998
+++ egcs-980315/gcc/Makefile.in Thu Mar 19 11:54:47 1998
@@ -1611,77 +1611,77 @@ genconfig : genconfig.o $(HOST_RTL) $(HO
$(HOST_CC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ \
genconfig.o $(HOST_RTL) $(HOST_LIBS)
-genconfig.o : genconfig.c $(RTL_H) $(build_xm_file)
+genconfig.o : genconfig.c $(RTL_H) $(build_xm_file) system.h
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/genconfig.c
genflags : genflags.o $(HOST_RTL) $(HOST_LIBDEPS)
$(HOST_CC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ \
genflags.o $(HOST_RTL) $(HOST_LIBS)
-genflags.o : genflags.c $(RTL_H) $(build_xm_file)
+genflags.o : genflags.c $(RTL_H) $(build_xm_file) system.h
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/genflags.c
gencodes : gencodes.o $(HOST_RTL) $(HOST_LIBDEPS)
$(HOST_CC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ \
gencodes.o $(HOST_RTL) $(HOST_LIBS)
-gencodes.o : gencodes.c $(RTL_H) $(build_xm_file)
+gencodes.o : gencodes.c $(RTL_H) $(build_xm_file) system.h
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/gencodes.c
genemit : genemit.o $(HOST_RTL) $(HOST_LIBDEPS)
$(HOST_CC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ \
genemit.o $(HOST_RTL) $(HOST_LIBS)
-genemit.o : genemit.c $(RTL_H) $(build_xm_file)
+genemit.o : genemit.c $(RTL_H) $(build_xm_file) system.h
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/genemit.c
genopinit : genopinit.o $(HOST_RTL) $(HOST_LIBDEPS)
$(HOST_CC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ \
genopinit.o $(HOST_RTL) $(HOST_LIBS)
-genopinit.o : genopinit.c $(RTL_H) $(build_xm_file)
+genopinit.o : genopinit.c $(RTL_H) $(build_xm_file) system.h
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/genopinit.c
genrecog : genrecog.o $(HOST_RTL) $(HOST_LIBDEPS)
$(HOST_CC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ \
genrecog.o $(HOST_RTL) $(HOST_LIBS)
-genrecog.o : genrecog.c $(RTL_H) $(build_xm_file)
+genrecog.o : genrecog.c $(RTL_H) $(build_xm_file) system.h
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/genrecog.c
genextract : genextract.o $(HOST_RTL) $(HOST_LIBDEPS)
$(HOST_CC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ \
genextract.o $(HOST_RTL) $(HOST_LIBS)
-genextract.o : genextract.c $(RTL_H) $(build_xm_file) insn-config.h
+genextract.o : genextract.c $(RTL_H) $(build_xm_file) system.h insn-config.h
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/genextract.c
genpeep : genpeep.o $(HOST_RTL) $(HOST_LIBDEPS)
$(HOST_CC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ \
genpeep.o $(HOST_RTL) $(HOST_LIBS)
-genpeep.o : genpeep.c $(RTL_H) $(build_xm_file)
+genpeep.o : genpeep.c $(RTL_H) $(build_xm_file) system.h
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/genpeep.c
genattr : genattr.o $(HOST_RTL) $(HOST_LIBDEPS)
$(HOST_CC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ \
genattr.o $(HOST_RTL) $(HOST_LIBS)
-genattr.o : genattr.c $(RTL_H) $(build_xm_file)
+genattr.o : genattr.c $(RTL_H) $(build_xm_file) system.h
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/genattr.c
genattrtab : genattrtab.o $(HOST_RTL) $(HOST_PRINT) $(HOST_RTLANAL) $(HOST_LIBDEPS)
$(HOST_CC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ \
genattrtab.o $(HOST_RTL) $(HOST_PRINT) $(HOST_RTLANAL) $(HOST_LIBS)
-genattrtab.o : genattrtab.c $(RTL_H) $(build_xm_file) insn-config.h
+genattrtab.o : genattrtab.c $(RTL_H) $(build_xm_file) system.h insn-config.h
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/genattrtab.c
genoutput : genoutput.o $(HOST_RTL) $(HOST_LIBDEPS)
$(HOST_CC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ \
genoutput.o $(HOST_RTL) $(HOST_LIBS)
-genoutput.o : genoutput.c $(RTL_H) $(build_xm_file)
+genoutput.o : genoutput.c $(RTL_H) $(build_xm_file) system.h
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/genoutput.c
gengenrtl : gengenrtl.o $(HOST_LIBDEPS)
diff -rup orig/egcs-980315/gcc/genattr.c egcs-980315/gcc/genattr.c
--- orig/egcs-980315/gcc/genattr.c Fri Feb 27 03:23:36 1998
+++ egcs-980315/gcc/genattr.c Thu Mar 19 11:22:32 1998
@@ -20,28 +20,27 @@ the Free Software Foundation, 59 Temple
Boston, MA 02111-1307, USA. */
-#include <stdio.h>
#include "hconfig.h"
+#ifdef __STDC__
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#include "system.h"
+
#include "rtl.h"
#include "obstack.h"
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-
static struct obstack obstack;
struct obstack *rtl_obstack = &obstack;
#define obstack_chunk_alloc xmalloc
#define obstack_chunk_free free
-#ifdef NEED_DECLARATION_FREE
-extern void free PROTO((void *));
-#endif
extern rtx read_rtx PROTO((FILE *));
char *xmalloc PROTO((unsigned));
-static void fatal ();
+static void fatal PVPROTO ((char *, ...)) PRINTF_ATTRIBUTE_1;
void fancy_abort PROTO((void));
/* A range of values. */
@@ -220,11 +219,22 @@ xrealloc (ptr, size)
}
static void
-fatal (s, a1, a2)
- char *s;
+fatal VPROTO ((char *format, ...))
{
+#ifndef __STDC__
+ char *format;
+#endif
+ va_list ap;
+
+ VA_START (ap, format);
+
+#ifndef __STDC__
+ format = va_arg (ap, char *);
+#endif
+
fprintf (stderr, "genattr: ");
- fprintf (stderr, s, a1, a2);
+ vfprintf (stderr, format, ap);
+ va_end (ap);
fprintf (stderr, "\n");
exit (FATAL_EXIT_CODE);
}
diff -rup orig/egcs-980315/gcc/genattrtab.c egcs-980315/gcc/genattrtab.c
--- orig/egcs-980315/gcc/genattrtab.c Mon Mar 2 06:54:13 1998
+++ egcs-980315/gcc/genattrtab.c Thu Mar 19 11:54:40 1998
@@ -96,35 +96,21 @@ Boston, MA 02111-1307, USA. */
#include "hconfig.h"
-/* varargs must always be included after *config.h. */
+/* varargs must always be included after *config.h, but before stdio.h. */
#ifdef __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
-#include <stdio.h>
+#include "system.h"
+
#include "rtl.h"
#include "insn-config.h" /* For REGISTER_CONSTRAINTS */
-#ifdef TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# if HAVE_SYS_TIME_H
-# include <sys/time.h>
-# else
-# include <time.h>
-#endif
-#endif
-
#ifdef HAVE_SYS_RESOURCE_H
# include <sys/resource.h>
#endif
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-
/* We must include obstack.h after <sys/time.h>, to avoid lossage with
/usr/include/sys/stdtypes.h on Sun OS 4.x. */
#include "obstack.h"
@@ -140,13 +126,10 @@ struct obstack *temp_obstack = &obstack2
/* Define this so we can link with print-rtl.o to get debug_rtx function. */
char **insn_name_ptr = 0;
-#ifdef NEED_DECLARATION_FREE
-extern void free ();
-#endif
extern rtx read_rtx ();
-static void fatal ();
-void fancy_abort ();
+static void fatal PVPROTO ((char *, ...)) PRINTF_ATTRIBUTE_1;
+void fancy_abort PROTO((void));
/* enough space to reserve for printing out ints */
#define MAX_DIGITS (HOST_BITS_PER_INT * 3 / 10 + 3)
@@ -5801,12 +5784,22 @@ copy_rtx_unchanging (orig)
}
static void
-fatal (s, a1, a2)
- char *s;
- char *a1, *a2;
+fatal VPROTO ((char *format, ...))
{
+#ifndef __STDC__
+ char *format;
+#endif
+ va_list ap;
+
+ VA_START (ap, format);
+
+#ifndef __STDC__
+ format = va_arg (ap, char *);
+#endif
+
fprintf (stderr, "genattrtab: ");
- fprintf (stderr, s, a1, a2);
+ vfprintf (stderr, format, ap);
+ va_end (ap);
fprintf (stderr, "\n");
exit (FATAL_EXIT_CODE);
}
diff -rup orig/egcs-980315/gcc/gencodes.c egcs-980315/gcc/gencodes.c
--- orig/egcs-980315/gcc/gencodes.c Mon Aug 11 11:57:09 1997
+++ egcs-980315/gcc/gencodes.c Thu Mar 19 11:26:26 1998
@@ -22,8 +22,14 @@ the Free Software Foundation, 59 Temple
Boston, MA 02111-1307, USA. */
-#include <stdio.h>
#include "hconfig.h"
+#ifdef __STDC__
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#include "system.h"
+
#include "rtl.h"
#include "obstack.h"
@@ -33,12 +39,11 @@ struct obstack *rtl_obstack = &obstack;
#define obstack_chunk_alloc xmalloc
#define obstack_chunk_free free
-extern void free ();
extern rtx read_rtx ();
-char *xmalloc ();
-static void fatal ();
-void fancy_abort ();
+char *xmalloc PROTO((unsigned));
+static void fatal PVPROTO ((char *, ...)) PRINTF_ATTRIBUTE_1;
+void fancy_abort PROTO((void));
static int insn_code_number;
@@ -77,11 +82,22 @@ xrealloc (ptr, size)
}
static void
-fatal (s, a1, a2)
- char *s;
+fatal VPROTO ((char *format, ...))
{
+#ifndef __STDC__
+ char *format;
+#endif
+ va_list ap;
+
+ VA_START (ap, format);
+
+#ifndef __STDC__
+ format = va_arg (ap, char *);
+#endif
+
fprintf (stderr, "gencodes: ");
- fprintf (stderr, s, a1, a2);
+ vfprintf (stderr, format, ap);
+ va_end (ap);
fprintf (stderr, "\n");
exit (FATAL_EXIT_CODE);
}
diff -rup orig/egcs-980315/gcc/genconfig.c egcs-980315/gcc/genconfig.c
--- orig/egcs-980315/gcc/genconfig.c Fri Feb 27 03:23:39 1998
+++ egcs-980315/gcc/genconfig.c Thu Mar 19 11:29:33 1998
@@ -20,24 +20,23 @@ the Free Software Foundation, 59 Temple
Boston, MA 02111-1307, USA. */
-#include <stdio.h>
#include "hconfig.h"
+#ifdef __STDC__
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#include "system.h"
+
#include "rtl.h"
#include "obstack.h"
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-
static struct obstack obstack;
struct obstack *rtl_obstack = &obstack;
#define obstack_chunk_alloc xmalloc
#define obstack_chunk_free free
-#ifdef NEED_DECLARATION_FREE
-extern void free ();
-#endif
extern rtx read_rtx ();
/* flags to determine output of machine description dependent #define's. */
@@ -55,9 +54,9 @@ static int max_insns_per_split = 1;
static int clobbers_seen_this_insn;
static int dup_operands_seen_this_insn;
-char *xmalloc ();
-static void fatal ();
-void fancy_abort ();
+char *xmalloc PROTO((unsigned));
+static void fatal PVPROTO ((char *, ...)) PRINTF_ATTRIBUTE_1;
+void fancy_abort PROTO((void));
/* RECOG_P will be non-zero if this pattern was seen in a context where it will
be used to recognize, rather than just generate an insn.
@@ -268,11 +267,22 @@ xrealloc (ptr, size)
}
static void
-fatal (s, a1, a2)
- char *s;
+fatal VPROTO ((char *format, ...))
{
+#ifndef __STDC__
+ char *format;
+#endif
+ va_list ap;
+
+ VA_START (ap, format);
+
+#ifndef __STDC__
+ format = va_arg (ap, char *);
+#endif
+
fprintf (stderr, "genconfig: ");
- fprintf (stderr, s, a1, a2);
+ vfprintf (stderr, format, ap);
+ va_end (ap);
fprintf (stderr, "\n");
exit (FATAL_EXIT_CODE);
}
diff -rup orig/egcs-980315/gcc/genemit.c egcs-980315/gcc/genemit.c
--- orig/egcs-980315/gcc/genemit.c Wed Mar 11 19:02:44 1998
+++ egcs-980315/gcc/genemit.c Thu Mar 19 11:42:59 1998
@@ -19,29 +19,28 @@ the Free Software Foundation, 59 Temple
Boston, MA 02111-1307, USA. */
-#include <stdio.h>
#include "hconfig.h"
+#ifdef __STDC__
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#include "system.h"
+
#include "rtl.h"
#include "obstack.h"
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-
static struct obstack obstack;
struct obstack *rtl_obstack = &obstack;
#define obstack_chunk_alloc xmalloc
#define obstack_chunk_free free
-#ifdef NEED_DECLARATION_FREE
-extern void free ();
-#endif
extern rtx read_rtx ();
-char *xmalloc ();
-static void fatal ();
-void fancy_abort ();
+char *xmalloc PROTO((unsigned));
+static void fatal PVPROTO ((char *, ...)) PRINTF_ATTRIBUTE_1;
+void fancy_abort PROTO((void));
static int max_opno;
static int max_dup_opno;
@@ -699,11 +698,22 @@ xrealloc (ptr, size)
}
static void
-fatal (s, a1, a2)
- char *s;
+fatal VPROTO ((char *format, ...))
{
+#ifndef __STDC__
+ char *format;
+#endif
+ va_list ap;
+
+ VA_START (ap, format);
+
+#ifndef __STDC__
+ format = va_arg (ap, char *);
+#endif
+
fprintf (stderr, "genemit: ");
- fprintf (stderr, s, a1, a2);
+ vfprintf (stderr, format, ap);
+ va_end (ap);
fprintf (stderr, "\n");
exit (FATAL_EXIT_CODE);
}
diff -rup orig/egcs-980315/gcc/genextract.c egcs-980315/gcc/genextract.c
--- orig/egcs-980315/gcc/genextract.c Fri Feb 27 03:23:41 1998
+++ egcs-980315/gcc/genextract.c Thu Mar 19 11:37:27 1998
@@ -19,25 +19,24 @@ the Free Software Foundation, 59 Temple
Boston, MA 02111-1307, USA. */
-#include <stdio.h>
#include "hconfig.h"
+#ifdef __STDC__
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#include "system.h"
+
#include "rtl.h"
#include "obstack.h"
#include "insn-config.h"
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-
static struct obstack obstack;
struct obstack *rtl_obstack = &obstack;
#define obstack_chunk_alloc xmalloc
#define obstack_chunk_free free
-#ifdef NEED_DECLARATION_FREE
-extern void free ();
-#endif
extern rtx read_rtx ();
/* Names for patterns. Need to allow linking with print-rtl. */
@@ -106,12 +105,12 @@ static struct code_ptr *peepholes;
static void walk_rtx ();
static void print_path ();
-char *xmalloc ();
+char *xmalloc PROTO((unsigned));
+static void fatal PVPROTO ((char *, ...)) PRINTF_ATTRIBUTE_1;
+void fancy_abort PROTO((void));
char *xrealloc ();
-static void fatal ();
static char *copystr ();
static void mybzero ();
-void fancy_abort ();
static void
gen_insn (insn)
@@ -370,11 +369,22 @@ xrealloc (ptr, size)
}
static void
-fatal (s, a1, a2)
- char *s;
+fatal VPROTO ((char *format, ...))
{
+#ifndef __STDC__
+ char *format;
+#endif
+ va_list ap;
+
+ VA_START (ap, format);
+
+#ifndef __STDC__
+ format = va_arg (ap, char *);
+#endif
+
fprintf (stderr, "genextract: ");
- fprintf (stderr, s, a1, a2);
+ vfprintf (stderr, format, ap);
+ va_end (ap);
fprintf (stderr, "\n");
exit (FATAL_EXIT_CODE);
}
diff -rup orig/egcs-980315/gcc/genflags.c egcs-980315/gcc/genflags.c
--- orig/egcs-980315/gcc/genflags.c Fri Feb 27 03:23:42 1998
+++ egcs-980315/gcc/genflags.c Thu Mar 19 11:24:29 1998
@@ -22,29 +22,28 @@ the Free Software Foundation, 59 Temple
Boston, MA 02111-1307, USA. */
-#include <stdio.h>
#include "hconfig.h"
+#ifdef __STDC__
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#include "system.h"
+
#include "rtl.h"
#include "obstack.h"
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-
static struct obstack obstack;
struct obstack *rtl_obstack = &obstack;
#define obstack_chunk_alloc xmalloc
#define obstack_chunk_free free
-#ifdef NEED_DECLARATION_FREE
-extern void free ();
-#endif
extern rtx read_rtx ();
-char *xmalloc ();
-static void fatal ();
-void fancy_abort ();
+char *xmalloc PROTO((unsigned));
+static void fatal PVPROTO ((char *, ...)) PRINTF_ATTRIBUTE_1;
+void fancy_abort PROTO((void));
/* Names for patterns. Need to allow linking with print-rtl. */
char **insn_name_ptr;
@@ -202,11 +201,22 @@ xrealloc (ptr, size)
}
static void
-fatal (s, a1, a2)
- char *s;
+fatal VPROTO ((char *format, ...))
{
+#ifndef __STDC__
+ char *format;
+#endif
+ va_list ap;
+
+ VA_START (ap, format);
+
+#ifndef __STDC__
+ format = va_arg (ap, char *);
+#endif
+
fprintf (stderr, "genflags: ");
- fprintf (stderr, s, a1, a2);
+ vfprintf (stderr, format, ap);
+ va_end (ap);
fprintf (stderr, "\n");
exit (FATAL_EXIT_CODE);
}
diff -rup orig/egcs-980315/gcc/genopinit.c egcs-980315/gcc/genopinit.c
--- orig/egcs-980315/gcc/genopinit.c Wed Mar 11 19:02:45 1998
+++ egcs-980315/gcc/genopinit.c Thu Mar 19 11:33:48 1998
@@ -19,16 +19,16 @@ the Free Software Foundation, 59 Temple
Boston, MA 02111-1307, USA. */
-#include <stdio.h>
#include "hconfig.h"
-#include "rtl.h"
-#include "obstack.h"
-#include <ctype.h>
-
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
+#ifdef __STDC__
+#include <stdarg.h>
+#else
+#include <varargs.h>
#endif
+#include "system.h"
+#include "rtl.h"
+#include "obstack.h"
static struct obstack obstack;
struct obstack *rtl_obstack = &obstack;
@@ -36,14 +36,11 @@ struct obstack *rtl_obstack = &obstack;
#define obstack_chunk_alloc xmalloc
#define obstack_chunk_free free
-#ifdef NEED_DECLARATION_FREE
-extern void free ();
-#endif
extern rtx read_rtx ();
-char *xmalloc ();
-static void fatal ();
-void fancy_abort ();
+char *xmalloc PROTO((unsigned));
+static void fatal PVPROTO ((char *, ...)) PRINTF_ATTRIBUTE_1;
+void fancy_abort PROTO((void));
/* Many parts of GCC use arrays that are indexed by machine mode and
contain the insn codes for pattern in the MD file that perform a given
@@ -313,11 +310,22 @@ xrealloc (ptr, size)
}
static void
-fatal (s, a1, a2)
- char *s;
+fatal VPROTO ((char *format, ...))
{
+#ifndef __STDC__
+ char *format;
+#endif
+ va_list ap;
+
+ VA_START (ap, format);
+
+#ifndef __STDC__
+ format = va_arg (ap, char *);
+#endif
+
fprintf (stderr, "genopinit: ");
- fprintf (stderr, s, a1, a2);
+ vfprintf (stderr, format, ap);
+ va_end (ap);
fprintf (stderr, "\n");
exit (FATAL_EXIT_CODE);
}
diff -rup orig/egcs-980315/gcc/genoutput.c egcs-980315/gcc/genoutput.c
--- orig/egcs-980315/gcc/genoutput.c Wed Mar 11 19:29:01 1998
+++ egcs-980315/gcc/genoutput.c Thu Mar 19 11:41:15 1998
@@ -90,15 +90,17 @@ insn_template[24] to be "clrd %0", and i
It would not make an case in output_insn_hairy because the template
given in the entry is a constant (it does not start with `*'). */
-#include <stdio.h>
#include "hconfig.h"
+#ifdef __STDC__
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#include "system.h"
+
#include "rtl.h"
#include "obstack.h"
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-
/* No instruction can have more operands than this.
Sorry for this arbitrary limit, but what machine will
have an instruction with this many operands? */
@@ -111,15 +113,12 @@ struct obstack *rtl_obstack = &obstack;
#define obstack_chunk_alloc xmalloc
#define obstack_chunk_free free
-#ifdef NEED_DECLARATION_FREE
-extern void free ();
-#endif
extern rtx read_rtx ();
-char *xmalloc ();
-static void fatal ();
-void fancy_abort ();
-static void error ();
+char *xmalloc PROTO((unsigned));
+static void fatal PVPROTO ((char *, ...)) PRINTF_ATTRIBUTE_1;
+void fancy_abort PROTO((void));
+static void error PVPROTO ((char *, ...)) PRINTF_ATTRIBUTE_1;
static void mybcopy ();
static void mybzero ();
static int n_occurrences ();
@@ -918,11 +917,22 @@ mybcopy (b1, b2, length)
}
static void
-fatal (s, a1, a2, a3, a4)
- char *s;
+fatal VPROTO ((char *format, ...))
{
+#ifndef __STDC__
+ char *format;
+#endif
+ va_list ap;
+
+ VA_START (ap, format);
+
+#ifndef __STDC__
+ format = va_arg (ap, char *);
+#endif
+
fprintf (stderr, "genoutput: ");
- fprintf (stderr, s, a1, a2, a3, a4);
+ vfprintf (stderr, format, ap);
+ va_end (ap);
fprintf (stderr, "\n");
exit (FATAL_EXIT_CODE);
}
@@ -937,11 +947,22 @@ fancy_abort ()
}
static void
-error (s, a1, a2)
- char *s;
+error VPROTO ((char *format, ...))
{
+#ifndef __STDC__
+ char *format;
+#endif
+ va_list ap;
+
+ VA_START (ap, format);
+
+#ifndef __STDC__
+ format = va_arg (ap, char *);
+#endif
+
fprintf (stderr, "genoutput: ");
- fprintf (stderr, s, a1, a2);
+ vfprintf (stderr, format, ap);
+ va_end (ap);
fprintf (stderr, "\n");
have_error = 1;
diff -rup orig/egcs-980315/gcc/genpeep.c egcs-980315/gcc/genpeep.c
--- orig/egcs-980315/gcc/genpeep.c Fri Feb 27 03:23:45 1998
+++ egcs-980315/gcc/genpeep.c Thu Mar 19 11:31:51 1998
@@ -19,24 +19,23 @@ the Free Software Foundation, 59 Temple
Boston, MA 02111-1307, USA. */
-#include <stdio.h>
#include "hconfig.h"
+#ifdef __STDC__
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#include "system.h"
+
#include "rtl.h"
#include "obstack.h"
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-
static struct obstack obstack;
struct obstack *rtl_obstack = &obstack;
#define obstack_chunk_alloc xmalloc
#define obstack_chunk_free free
-#ifdef NEED_DECLARATION_FREE
-extern void free ();
-#endif
extern rtx read_rtx ();
/* While tree-walking an instruction pattern, we keep a chain
@@ -52,10 +51,10 @@ struct link
int vecelt;
};
-char *xmalloc ();
static void match_rtx ();
-static void fatal ();
-void fancy_abort ();
+char *xmalloc PROTO((unsigned));
+static void fatal PVPROTO ((char *, ...)) PRINTF_ATTRIBUTE_1;
+void fancy_abort PROTO((void));
static int max_opno;
@@ -412,11 +411,22 @@ xrealloc (ptr, size)
}
static void
-fatal (s, a1, a2)
- char *s;
+fatal VPROTO ((char *format, ...))
{
+#ifndef __STDC__
+ char *format;
+#endif
+ va_list ap;
+
+ VA_START (ap, format);
+
+#ifndef __STDC__
+ format = va_arg (ap, char *);
+#endif
+
fprintf (stderr, "genpeep: ");
- fprintf (stderr, s, a1, a2);
+ vfprintf (stderr, format, ap);
+ va_end (ap);
fprintf (stderr, "\n");
exit (FATAL_EXIT_CODE);
}
diff -rup orig/egcs-980315/gcc/genrecog.c egcs-980315/gcc/genrecog.c
--- orig/egcs-980315/gcc/genrecog.c Wed Mar 11 19:02:46 1998
+++ egcs-980315/gcc/genrecog.c Thu Mar 19 11:51:12 1998
@@ -46,24 +46,18 @@ Boston, MA 02111-1307, USA. */
which returns 0 if the rtl could not be split, or
it returns the split rtl in a SEQUENCE. */
-#include <stdio.h>
#include "hconfig.h"
+#include "system.h"
+
#include "rtl.h"
#include "obstack.h"
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-
static struct obstack obstack;
struct obstack *rtl_obstack = &obstack;
#define obstack_chunk_alloc xmalloc
#define obstack_chunk_free free
-#ifdef NEED_DECLARATION_FREE
-extern void free ();
-#endif
extern rtx read_rtx ();
/* Data structure for a listhead of decision trees. The alternatives
diff -rup orig/egcs-980315/gcc/system.h egcs-980315/gcc/system.h
--- orig/egcs-980315/gcc/system.h Sat Feb 28 01:11:52 1998
+++ egcs-980315/gcc/system.h Thu Mar 19 11:11:52 1998
@@ -188,4 +188,14 @@ extern void free ();
extern char *getenv ();
#endif
+#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
+# define PRINTF_ATTRIBUTE(m, n)
+#else
+# define PRINTF_ATTRIBUTE(m, n) __attribute__ ((format (__printf__, m, n)))
+#endif
+
+#define PRINTF_ATTRIBUTE_1 PRINTF_ATTRIBUTE(1, 2)
+#define PRINTF_ATTRIBUTE_2 PRINTF_ATTRIBUTE(2, 3)
+#define PRINTF_ATTRIBUTE_3 PRINTF_ATTRIBUTE(3, 4)
+
#endif /* __GCC_SYSTEM_H__ */