Use PROTO for varargs functions.

If __STDC__, include gstdarg and use ANSI form of varargs.

From-SVN: r6517
This commit is contained in:
Richard Kenner 1994-02-10 08:11:46 -05:00
parent 81a1533366
commit e0e2a8dafa
2 changed files with 177 additions and 86 deletions

View File

@ -2,9 +2,9 @@
contain debugging information specified by the GNU compiler contain debugging information specified by the GNU compiler
in the form of comments (the mips assembler does not support in the form of comments (the mips assembler does not support
assembly access to debug information). assembly access to debug information).
Contributed by: Michael Meissner, meissner@osf.org Copyright (C) 1991, 1993, 1994 Free Software Foundation, Inc.
Copyright (C) 1991, 1993 Free Software Foundation, Inc. Contributed by Michael Meissner, meissner@osf.org
This file is part of GNU CC. This file is part of GNU CC.
GNU CC is free software; you can redistribute it and/or modify GNU CC is free software; you can redistribute it and/or modify
@ -598,7 +598,11 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
*/ */
#ifdef __STDC__
#include "gstdarg.h"
#else
#include "gvarargs.h" #include "gvarargs.h"
#endif
#include "config.h" #include "config.h"
#include <stdio.h> #include <stdio.h>
@ -614,6 +618,8 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
typedef void *PTR_T; typedef void *PTR_T;
typedef const void *CPTR_T; typedef const void *CPTR_T;
#define __proto(x) x #define __proto(x) x
#define VPROTO(ARGS) ARGS
#define VA_START(va_list,var) va_start(va_list,var)
#else #else
#if defined(_STDIO_H_) || defined(__STDIO_H__) /* Ultrix 4.0, SGI */ #if defined(_STDIO_H_) || defined(__STDIO_H__) /* Ultrix 4.0, SGI */
@ -627,6 +633,8 @@ typedef char *CPTR_T;
#define __proto(x) () #define __proto(x) ()
#define const #define const
#define VPROTO(ARGS) (va_alist) va_dcl
#define VA_START(va_list,var) va_start(va_list)
#endif #endif
/* Do to size_t being defined in sys/types.h and different /* Do to size_t being defined in sys/types.h and different
@ -656,8 +664,8 @@ extern PTR_T xcalloc __proto((Size_t, Size_t));
extern PTR_T xrealloc __proto((PTR_T, Size_t)); extern PTR_T xrealloc __proto((PTR_T, Size_t));
extern void xfree __proto((PTR_T)); extern void xfree __proto((PTR_T));
extern void fatal(); /* can't use prototypes here */ extern void fatal __proto((char *format, ...));
extern void error(); extern void error __proto((char *format, ...));
#ifndef MIPS_DEBUGGING_INFO #ifndef MIPS_DEBUGGING_INFO
@ -5533,19 +5541,24 @@ free_thead (ptr)
/*VARARGS*/ /*VARARGS*/
void void
fatal (va_alist) fatal VPROTO((char *format, ...))
va_dcl
{ {
va_list ap; #ifndef __STDC__
char *format; char *format;
#endif
va_list ap;
VA_START (ap, format);
#ifndef __STDC__
format = va_arg (ap, char*);
#endif
if (line_number > 0) if (line_number > 0)
fprintf (stderr, "%s, %s:%ld ", progname, input_name, line_number); fprintf (stderr, "%s, %s:%ld ", progname, input_name, line_number);
else else
fprintf (stderr, "%s:", progname); fprintf (stderr, "%s:", progname);
va_start(ap);
format = va_arg (ap, char *);
vfprintf (stderr, format, ap); vfprintf (stderr, format, ap);
va_end (ap); va_end (ap);
fprintf (stderr, "\n"); fprintf (stderr, "\n");
@ -5558,19 +5571,24 @@ fatal (va_alist)
/*VARARGS*/ /*VARARGS*/
void void
error (va_alist) error VPROTO((char *format, ...))
va_dcl
{ {
va_list ap; #ifndef __STDC__
char *format; char *format;
#endif
va_list ap;
VA_START (ap, format);
#ifndef __STDC__
format = va_arg (ap, char*);
#endif
if (line_number > 0) if (line_number > 0)
fprintf (stderr, "%s, %s:%ld ", progname, input_name, line_number); fprintf (stderr, "%s, %s:%ld ", progname, input_name, line_number);
else else
fprintf (stderr, "%s:", progname); fprintf (stderr, "%s:", progname);
va_start(ap);
format = va_arg (ap, char *);
vfprintf (stderr, format, ap); vfprintf (stderr, format, ap);
fprintf (stderr, "\n"); fprintf (stderr, "\n");
if (line_number > 0) if (line_number > 0)

View File

@ -24,7 +24,11 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
Error messages and low-level interface to malloc also handled here. */ Error messages and low-level interface to malloc also handled here. */
#include "config.h" #include "config.h"
#ifdef __STDC__
#include "gstdarg.h"
#else
#include "gvarargs.h" #include "gvarargs.h"
#endif
#include <stdio.h> #include <stdio.h>
#include <signal.h> #include <signal.h>
#include <setjmp.h> #include <setjmp.h>
@ -106,8 +110,20 @@ extern void dump_sched_info ();
extern void dump_local_alloc (); extern void dump_local_alloc ();
void rest_of_decl_compilation (); void rest_of_decl_compilation ();
void error (); void error_with_file_and_line PROTO((char *file, int line, char *s, ...));
void error_with_file_and_line (); void error_with_decl PROTO((tree decl, char *s, ...));
void error_for_asm PROTO((rtx insn, char *s, ...));
void error PROTO((char *s, ...));
void fatal PROTO((char *s, ...));
void warning_with_file_and_line PROTO((char *file, int line, char *s, ...));
void warning_with_decl PROTO((tree decl, char *s, ...));
void warning_for_asm PROTO((rtx insn, char *s, ...));
void warning PROTO((char *s, ...));
void pedwarn PROTO((char *s, ...));
void pedwarn_with_decl PROTO((tree decl, char *s, ...));
void pedwarn_with_file_and_line PROTO((char *file, int line, char *s, ...));
void sorry PROTO((char *s, ...));
void really_sorry PROTO((char *s, ...));
void fancy_abort (); void fancy_abort ();
#ifndef abort #ifndef abort
void abort (); void abort ();
@ -1182,19 +1198,23 @@ v_error_with_file_and_line (file, line, s, ap)
} }
void void
error_with_file_and_line (va_alist) error_with_file_and_line VPROTO((char *file, int line, char *s, ...))
va_dcl
/* (char *file, int line, char *s, ...) */
{ {
va_list ap; #ifndef __STDC__
char *file; char *file;
int line; int line;
char *s; char *s;
#endif
va_list ap;
va_start (ap); VA_START (ap, s);
#ifndef __STDC__
file = va_arg (ap, char *); file = va_arg (ap, char *);
line = va_arg (ap, int); line = va_arg (ap, int);
s = va_arg (ap, char *); s = va_arg (ap, char *);
#endif
v_error_with_file_and_line (file, line, s, ap); v_error_with_file_and_line (file, line, s, ap);
va_end (ap); va_end (ap);
} }
@ -1215,17 +1235,21 @@ v_error_with_decl (decl, s, ap)
} }
void void
error_with_decl (va_alist) error_with_decl VPROTO((tree decl, char *s, ...))
va_dcl
/* (tree decl, char *s, ...) */
{ {
va_list ap; #ifndef __STDC__
tree decl; tree decl;
char *s; char *s;
#endif
va_list ap;
va_start (ap); VA_START (ap, s);
#ifndef __STDC__
decl = va_arg (ap, tree); decl = va_arg (ap, tree);
s = va_arg (ap, char *); s = va_arg (ap, char *);
#endif
v_error_with_decl (decl, s, ap); v_error_with_decl (decl, s, ap);
va_end (ap); va_end (ap);
} }
@ -1250,17 +1274,21 @@ v_error_for_asm (insn, s, ap)
} }
void void
error_for_asm (va_alist) error_for_asm VPROTO((rtx insn, char *s, ...))
va_dcl
/* (rtx insn, char *s, ...) */
{ {
va_list ap; #ifndef __STDC__
rtx insn; rtx insn;
char *s; char *s;
#endif
va_list ap;
va_start (ap); VA_START (ap, s);
#ifndef __STDC__
insn = va_arg (ap, rtx); insn = va_arg (ap, rtx);
s = va_arg (ap, char *); s = va_arg (ap, char *);
#endif
v_error_for_asm (insn, s, ap); v_error_for_asm (insn, s, ap);
va_end (ap); va_end (ap);
} }
@ -1276,15 +1304,19 @@ verror (s, ap)
} }
void void
error (va_alist) error VPROTO((char *s, ...))
va_dcl
/* (char *s, ...) */
{ {
va_list ap; #ifndef __STDC__
char *s; char *s;
#endif
va_list ap;
va_start (ap); VA_START (ap, s);
#ifndef __STDC__
s = va_arg (ap, char *); s = va_arg (ap, char *);
#endif
verror (s, ap); verror (s, ap);
va_end (ap); va_end (ap);
} }
@ -1301,15 +1333,19 @@ vfatal (s, ap)
} }
void void
fatal (va_alist) fatal VPROTO((char *s, ...))
va_dcl
/* (char *s, ...) */
{ {
va_list ap; #ifndef __STDC__
char *s; char *s;
#endif
va_list ap;
va_start (ap); VA_START (ap, s);
#ifndef __STDC__
s = va_arg (ap, char *); s = va_arg (ap, char *);
#endif
vfatal (s, ap); vfatal (s, ap);
va_end (ap); va_end (ap);
} }
@ -1331,19 +1367,23 @@ v_warning_with_file_and_line (file, line, s, ap)
} }
void void
warning_with_file_and_line (va_alist) warning_with_file_and_line VPROTO((char *file, int line, char *s, ...))
va_dcl
/* (char *file, int line, char *s, ...) */
{ {
va_list ap; #ifndef __STDC__
char *file; char *file;
int line; int line;
char *s; char *s;
#endif
va_list ap;
va_start (ap); VA_START (ap, s);
#ifndef __STDC__
file = va_arg (ap, char *); file = va_arg (ap, char *);
line = va_arg (ap, int); line = va_arg (ap, int);
s = va_arg (ap, char *); s = va_arg (ap, char *);
#endif
v_warning_with_file_and_line (file, line, s, ap); v_warning_with_file_and_line (file, line, s, ap);
va_end (ap); va_end (ap);
} }
@ -1366,17 +1406,21 @@ v_warning_with_decl (decl, s, ap)
} }
void void
warning_with_decl (va_alist) warning_with_decl VPROTO((tree decl, char *s, ...))
va_dcl
/* (tree decl, char *s, ...) */
{ {
va_list ap; #ifndef __STDC__
tree decl; tree decl;
char *s; char *s;
#endif
va_list ap;
va_start (ap); VA_START (ap, s);
#ifndef __STDC__
decl = va_arg (ap, tree); decl = va_arg (ap, tree);
s = va_arg (ap, char *); s = va_arg (ap, char *);
#endif
v_warning_with_decl (decl, s, ap); v_warning_with_decl (decl, s, ap);
va_end (ap); va_end (ap);
} }
@ -1403,17 +1447,21 @@ v_warning_for_asm (insn, s, ap)
} }
void void
warning_for_asm (va_alist) warning_for_asm VPROTO((rtx insn, char *s, ...))
va_dcl
/* (rtx insn, char *s, ...) */
{ {
va_list ap; #ifndef __STDC__
rtx insn; rtx insn;
char *s; char *s;
#endif
va_list ap;
va_start (ap); VA_START (ap, s);
#ifndef __STDC__
insn = va_arg (ap, rtx); insn = va_arg (ap, rtx);
s = va_arg (ap, char *); s = va_arg (ap, char *);
#endif
v_warning_for_asm (insn, s, ap); v_warning_for_asm (insn, s, ap);
va_end (ap); va_end (ap);
} }
@ -1429,14 +1477,19 @@ vwarning (s, ap)
} }
void void
warning (va_alist) warning VPROTO((char *s, ...))
va_dcl
{ {
va_list ap; #ifndef __STDC__
char *s; char *s;
#endif
va_list ap;
va_start (ap); VA_START (ap, s);
#ifndef __STDC__
s = va_arg (ap, char *); s = va_arg (ap, char *);
#endif
vwarning (s, ap); vwarning (s, ap);
va_end (ap); va_end (ap);
} }
@ -1456,15 +1509,19 @@ vpedwarn (s, ap)
} }
void void
pedwarn (va_alist) pedwarn VPROTO((char *s, ...))
va_dcl
/* (char *s, ...) */
{ {
va_list ap; #ifndef __STDC__
char *s; char *s;
#endif
va_list ap;
va_start (ap); VA_START (ap, s);
#ifndef __STDC__
s = va_arg (ap, char *); s = va_arg (ap, char *);
#endif
vpedwarn (s, ap); vpedwarn (s, ap);
va_end (ap); va_end (ap);
} }
@ -1482,17 +1539,21 @@ v_pedwarn_with_decl (decl, s, ap)
} }
void void
pedwarn_with_decl (va_alist) pedwarn_with_decl VPROTO((tree decl, char *s, ...))
va_dcl
/* (tree decl, char *s, ...) */
{ {
va_list ap; #ifndef __STDC__
tree decl; tree decl;
char *s; char *s;
#endif
va_list ap;
va_start (ap); VA_START (ap, s);
#ifndef __STDC__
decl = va_arg (ap, tree); decl = va_arg (ap, tree);
s = va_arg (ap, char *); s = va_arg (ap, char *);
#endif
v_pedwarn_with_decl (decl, s, ap); v_pedwarn_with_decl (decl, s, ap);
va_end (ap); va_end (ap);
} }
@ -1511,19 +1572,23 @@ v_pedwarn_with_file_and_line (file, line, s, ap)
} }
void void
pedwarn_with_file_and_line (va_alist) pedwarn_with_file_and_line VPROTO((char *file, int line, char *s, ...))
va_dcl
/* (char *file, int line, char *s, ...) */
{ {
va_list ap; #ifndef __STDC__
char *file; char *file;
int line; int line;
char *s; char *s;
#endif
va_list ap;
va_start (ap); VA_START (ap, s);
#ifndef __STDC__
file = va_arg (ap, char *); file = va_arg (ap, char *);
line = va_arg (ap, int); line = va_arg (ap, int);
s = va_arg (ap, char *); s = va_arg (ap, char *);
#endif
v_pedwarn_with_file_and_line (file, line, s, ap); v_pedwarn_with_file_and_line (file, line, s, ap);
va_end (ap); va_end (ap);
} }
@ -1545,15 +1610,19 @@ vsorry (s, ap)
} }
void void
sorry (va_alist) sorry VPROTO((char *s, ...))
va_dcl
/* (char *s, ...) */
{ {
va_list ap; #ifndef __STDC__
char *s; char *s;
#endif
va_list ap;
va_start (ap); VA_START (ap, s);
#ifndef __STDC__
s = va_arg (ap, char *); s = va_arg (ap, char *);
#endif
vsorry (s, ap); vsorry (s, ap);
va_end (ap); va_end (ap);
} }
@ -1575,15 +1644,19 @@ v_really_sorry (s, ap)
} }
void void
really_sorry (va_alist) really_sorry VPROTO((char *s, ...))
va_dcl
/* (char *s, ...) */
{ {
va_list ap; #ifndef __STDC__
char *s; char *s;
#endif
va_list ap;
va_start (ap); VA_START (ap, s);
#ifndef __STDC__
s = va_arg (ap, char *); s = va_arg (ap, char *);
#endif
v_really_sorry (s, ap); v_really_sorry (s, ap);
va_end (ap); va_end (ap);
} }