merge netbsd changes for gcc. pmax still missing.

This commit is contained in:
mrg 1998-03-29 11:36:52 +00:00
parent ab327e89e2
commit 5e78440996
9 changed files with 181 additions and 66 deletions

View File

@ -51,6 +51,14 @@ static void add_attribute PROTO((enum attrs, char *,
static void init_attributes PROTO((void));
static void record_international_format PROTO((tree, tree, int));
/* Format kinds */
#define F_USER 0x1 /* Format used in user-land printf/scanf */
#define F_KERN 0x2 /* Format used in kprintf/scanf etc. */
#define F_SCAN 0x80000000 /* Format is scan* instead of print* */
#define FORMAT_IS_SCAN(p) (((p)->format_kind & F_SCAN) == F_SCAN)
#define FORMAT_CONTEXT(p) (((p)->format_kind & (F_USER|F_KERN)))
/* Make bindings for __FUNCTION__ and __PRETTY_FUNCTION__. */
void
@ -564,7 +572,7 @@ decl_attributes (node, attributes, prefix_attributes)
= TREE_VALUE (TREE_CHAIN (TREE_CHAIN (args)));
int format_num;
int first_arg_num;
int is_scan;
int format_kind;
tree argument;
int arg_num;
@ -579,15 +587,20 @@ decl_attributes (node, attributes, prefix_attributes)
&& (!strcmp (IDENTIFIER_POINTER (format_type), "printf")
|| !strcmp (IDENTIFIER_POINTER (format_type),
"__printf__")))
is_scan = 0;
format_kind = F_USER;
else if (TREE_CODE (format_type) == IDENTIFIER_NODE
&& (!strcmp (IDENTIFIER_POINTER (format_type), "kprintf")
|| !strcmp (IDENTIFIER_POINTER (format_type),
"__kprintf__")))
format_kind = F_KERN;
else if (TREE_CODE (format_type) == IDENTIFIER_NODE
&& (!strcmp (IDENTIFIER_POINTER (format_type), "scanf")
|| !strcmp (IDENTIFIER_POINTER (format_type),
"__scanf__")))
is_scan = 1;
format_kind = F_USER|F_SCAN;
else if (TREE_CODE (format_type) == IDENTIFIER_NODE)
{
error ("`%s' is an unrecognized format function type",
error_with_decl (decl, "`%s' is an unrecognized format function type",
IDENTIFIER_POINTER (format_type));
continue;
}
@ -660,7 +673,7 @@ decl_attributes (node, attributes, prefix_attributes)
record_function_format (DECL_NAME (decl),
DECL_ASSEMBLER_NAME (decl),
is_scan, format_num, first_arg_num);
format_kind, format_num, first_arg_num);
break;
}
@ -845,6 +858,7 @@ split_specs_attrs (specs_attrs, declspecs, prefix_attributes)
typedef struct {
char *format_chars;
int format_kind;
int pointer_count;
/* Type of argument if no length modifier is used. */
tree *nolen;
@ -865,32 +879,38 @@ typedef struct {
} format_char_info;
static format_char_info print_char_table[] = {
{ "di", 0, T_I, T_I, T_L, T_LL, T_LL, "-wp0 +" },
{ "oxX", 0, T_UI, T_UI, T_UL, T_ULL, T_ULL, "-wp0#" },
{ "u", 0, T_UI, T_UI, T_UL, T_ULL, T_ULL, "-wp0" },
{ "di", F_USER|F_KERN, 0, T_I, T_I, T_L, T_LL, T_LL, "-wp0 +" },
{ "oxX", F_USER|F_KERN, 0, T_UI, T_UI, T_UL, T_ULL, T_ULL, "-wp0#" },
{ "u", F_USER|F_KERN, 0, T_UI, T_UI, T_UL, T_ULL, T_ULL, "-wp0" },
/* Two GNU extensions. */
{ "Z", 0, T_ST, NULL, NULL, NULL, NULL, "-wp0" },
{ "m", 0, T_V, NULL, NULL, NULL, NULL, "-wp" },
{ "feEgG", 0, T_D, NULL, NULL, NULL, T_LD, "-wp0 +#" },
{ "c", 0, T_I, NULL, T_W, NULL, NULL, "-w" },
{ "C", 0, T_W, NULL, NULL, NULL, NULL, "-w" },
{ "s", 1, T_C, NULL, T_W, NULL, NULL, "-wp" },
{ "S", 1, T_W, NULL, NULL, NULL, NULL, "-wp" },
{ "p", 1, T_V, NULL, NULL, NULL, NULL, "-w" },
{ "n", 1, T_I, T_S, T_L, T_LL, NULL, "" },
{ "Z", F_USER, 0, T_ST, NULL, NULL, NULL, NULL, "-wp0" },
{ "m", F_USER, 0, T_V, NULL, NULL, NULL, NULL, "-wp" },
{ "feEgG", F_USER, 0, T_D, NULL, NULL, NULL, T_LD, "-wp0 +#" },
{ "c", F_USER|F_KERN, 0, T_I, NULL, T_W, NULL, NULL, "-w" },
{ "C", F_USER, 0, T_W, NULL, NULL, NULL, NULL, "-w" },
{ "s", F_USER|F_KERN, 1, T_C, NULL, T_W, NULL, NULL, "-wp" },
{ "S", F_USER, 1, T_W, NULL, NULL, NULL, NULL, "-wp" },
{ "p", F_USER|F_KERN, 1, T_V, NULL, NULL, NULL, NULL, "-w" },
{ "n", F_USER, 1, T_I, T_S, T_L, T_LL, NULL, "" },
/* Kernel bitmap formatting */
{ "b", F_KERN, 1, T_C, NULL, NULL, NULL, NULL, "" },
/* Kernel recursive format */
{ ":", F_KERN, 1, T_V, NULL, NULL, NULL, NULL, "" },
/* Kernel debugger auto-radix printing */
{ "nrz", F_KERN, 0, T_I, T_I, T_L, T_LL, T_LL, "-wp0# +" },
{ NULL }
};
static format_char_info scan_char_table[] = {
{ "di", 1, T_I, T_S, T_L, T_LL, T_LL, "*" },
{ "ouxX", 1, T_UI, T_US, T_UL, T_ULL, T_ULL, "*" },
{ "efgEG", 1, T_F, NULL, T_D, NULL, T_LD, "*" },
{ "sc", 1, T_C, NULL, T_W, NULL, NULL, "*a" },
{ "[", 1, T_C, NULL, NULL, NULL, NULL, "*a" },
{ "C", 1, T_W, NULL, NULL, NULL, NULL, "*" },
{ "S", 1, T_W, NULL, NULL, NULL, NULL, "*" },
{ "p", 2, T_V, NULL, NULL, NULL, NULL, "*" },
{ "n", 1, T_I, T_S, T_L, T_LL, NULL, "" },
{ "di", F_SCAN|F_USER, 1, T_I, T_S, T_L, T_LL, T_LL, "*" },
{ "ouxX", F_SCAN|F_USER, 1, T_UI, T_US, T_UL, T_ULL, T_ULL, "*" },
{ "efgEG", F_SCAN|F_USER, 1, T_F, NULL, T_D, NULL, T_LD, "*" },
{ "sc", F_SCAN|F_USER, 1, T_C, NULL, T_W, NULL, NULL, "*a" },
{ "[", F_SCAN|F_USER, 1, T_C, NULL, NULL, NULL, NULL, "*a" },
{ "C", F_SCAN|F_USER, 1, T_W, NULL, NULL, NULL, NULL, "*" },
{ "S", F_SCAN|F_USER, 1, T_W, NULL, NULL, NULL, NULL, "*" },
{ "p", F_SCAN|F_USER, 2, T_V, NULL, NULL, NULL, NULL, "*" },
{ "n", F_SCAN|F_USER, 1, T_I, T_S, T_L, T_LL, NULL, "" },
{ NULL }
};
@ -899,7 +919,7 @@ typedef struct function_format_info
struct function_format_info *next; /* next structure on the list */
tree name; /* identifier such as "printf" */
tree assembler_name; /* optional mangled identifier (for C++) */
int is_scan; /* TRUE if *scanf */
int format_kind; /* user/kernel/print/scan */
int format_num; /* number of format argument */
int first_arg_num; /* number of first arg (zero for varargs) */
} function_format_info;
@ -931,15 +951,15 @@ static void check_format_info PROTO((function_format_info *, tree));
void
init_function_format_info ()
{
record_function_format (get_identifier ("printf"), NULL_TREE, 0, 1, 2);
record_function_format (get_identifier ("fprintf"), NULL_TREE, 0, 2, 3);
record_function_format (get_identifier ("sprintf"), NULL_TREE, 0, 2, 3);
record_function_format (get_identifier ("scanf"), NULL_TREE, 1, 1, 2);
record_function_format (get_identifier ("fscanf"), NULL_TREE, 1, 2, 3);
record_function_format (get_identifier ("sscanf"), NULL_TREE, 1, 2, 3);
record_function_format (get_identifier ("vprintf"), NULL_TREE, 0, 1, 0);
record_function_format (get_identifier ("vfprintf"), NULL_TREE, 0, 2, 0);
record_function_format (get_identifier ("vsprintf"), NULL_TREE, 0, 2, 0);
record_function_format (get_identifier ("printf"), NULL_TREE, F_USER, 1, 2);
record_function_format (get_identifier ("fprintf"), NULL_TREE, F_USER, 2, 3);
record_function_format (get_identifier ("sprintf"), NULL_TREE, F_USER, 2, 3);
record_function_format (get_identifier ("scanf"), NULL_TREE, F_SCAN|F_USER, 1, 2);
record_function_format (get_identifier ("fscanf"), NULL_TREE, F_SCAN|F_USER, 2, 3);
record_function_format (get_identifier ("sscanf"), NULL_TREE, F_SCAN|F_USER, 2, 3);
record_function_format (get_identifier ("vprintf"), NULL_TREE, F_USER, 1, 0);
record_function_format (get_identifier ("vfprintf"), NULL_TREE, F_USER, 2, 0);
record_function_format (get_identifier ("vsprintf"), NULL_TREE, F_USER, 2, 0);
record_international_format (get_identifier ("gettext"), NULL_TREE, 1);
record_international_format (get_identifier ("dgettext"), NULL_TREE, 2);
@ -948,19 +968,19 @@ init_function_format_info ()
/* Record information for argument format checking. FUNCTION_IDENT is
the identifier node for the name of the function to check (its decl
need not exist yet). IS_SCAN is true for scanf-type format checking;
false indicates printf-style format checking. FORMAT_NUM is the number
of the argument which is the format control string (starting from 1).
FIRST_ARG_NUM is the number of the first actual argument to check
against the format string, or zero if no checking is not be done
(e.g. for varargs such as vfprintf). */
need not exist yet). FORMAT_KIND specifies if the it is a user or
kernel printing function or a user scanning function. FORMAT_NUM
is the number of the argument which is the format control string
(starting from 1). FIRST_ARG_NUM is the number of the first
actual argument to check against the format string, or zero if
no checking is not be done (e.g. for varargs such as vfprintf). */
void
record_function_format (name, assembler_name, is_scan,
record_function_format (name, assembler_name, format_kind,
format_num, first_arg_num)
tree name;
tree assembler_name;
int is_scan;
int format_kind;
int format_num;
int first_arg_num;
{
@ -983,7 +1003,7 @@ record_function_format (name, assembler_name, is_scan,
info->assembler_name = assembler_name;
}
info->is_scan = is_scan;
info->format_kind = format_kind;
info->format_num = format_num;
info->first_arg_num = first_arg_num;
}
@ -1186,7 +1206,7 @@ check_format_info (info, params)
}
flag_chars[0] = 0;
suppressed = wide = precise = FALSE;
if (info->is_scan)
if (FORMAT_IS_SCAN(info))
{
suppressed = *format_chars == '*';
if (suppressed)
@ -1279,6 +1299,82 @@ check_format_info (info, params)
}
}
}
else if ((FORMAT_CONTEXT(info) & F_KERN) != 0)
{
switch (*format_chars)
{
case 'b':
if (params == 0)
{
warning (tfaff);
return;
}
if (info->first_arg_num != 0)
{
cur_param = TREE_VALUE (params);
cur_type = TREE_TYPE (cur_param);
params = TREE_CHAIN (params);
++arg_num;
/*
* `%b' takes two arguments:
* an integer type (the bits), type-checked here
* a string (the bit names), checked for in mainstream
* code below (see `%b' entry in print_char_table[])
*/
if (TREE_CODE (TYPE_MAIN_VARIANT (cur_type)) != INTEGER_TYPE)
{
sprintf (message,
"bitfield is not an integer type (arg %d)",
arg_num);
warning (message);
}
}
break;
case ':':
if (params == 0)
{
warning (tfaff);
return;
}
if (info->first_arg_num != 0)
{
cur_param = TREE_VALUE (params);
cur_type = TREE_TYPE (cur_param);
params = TREE_CHAIN (params);
++arg_num;
/*
* `%r' takes two arguments:
* a string (the recursive format), type-checked here
* a pointer (va_list of format arguments), checked for
* in mainstream code below (see `%r' entry in
* print_char_table[])
*/
if (TREE_CODE (cur_type) == POINTER_TYPE)
{
cur_type = TREE_TYPE (cur_type);
if (TYPE_MAIN_VARIANT (cur_type) == char_type_node)
{
break;
}
}
sprintf (message,
"format argument is not a string (arg %d)",
arg_num);
warning (message);
}
break;
default:
while (isdigit (*format_chars))
{
wide = TRUE;
++format_chars;
}
break;
}
}
else
{
while (isdigit (*format_chars))
@ -1362,9 +1458,10 @@ check_format_info (info, params)
continue;
}
format_chars++;
fci = info->is_scan ? scan_char_table : print_char_table;
fci = FORMAT_IS_SCAN(info) ? scan_char_table : print_char_table;
while (fci->format_chars != 0
&& index (fci->format_chars, format_char) == 0)
&& ((FORMAT_CONTEXT(fci) & FORMAT_CONTEXT(info)) == 0
|| index (fci->format_chars, format_char) == 0))
++fci;
if (fci->format_chars == 0)
{
@ -1399,7 +1496,7 @@ check_format_info (info, params)
/* To simplify the following code. */
aflag = 0;
}
if (info->is_scan && format_char == '[')
if (FORMAT_IS_SCAN(info) && format_char == '[')
{
/* Skip over scan set, in case it happens to have '%' in it. */
if (*format_chars == '^')

View File

@ -50,15 +50,16 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
arm32 is the NetBSD port name, so we always define arm32 and __arm32__. */
#undef CPP_PREDEFINES
#define CPP_PREDEFINES "\
-Dunix -Driscbsd -Darm32 -D__arm32__ -D__NetBSD__ \
-Dunix -Driscbsd -Darm32 -D__arm32__ -D__arm6__
-D__NetBSD__ -D__KPRINTF_ATTRIBUTE__ \
-Asystem(unix) -Asystem(NetBSD) -Acpu(arm) -Amachine(arm)"
/* Define _POSIX_SOURCE if necessary. */
#undef CPP_SPEC
#define CPP_SPEC "\
%(cpp_cpu_arch) %(cpp_apcs_pc) %(cpp_float) %(cpp_endian) \
%{posix:-D_POSIX_SOURCE} \
"
#define CPP_SPEC "%{m2:-D__arm2__} %{m3:-D__arm3__} %{m2:-U__arm6__} \
%{m3:-U__arm6__} %{m2:-U__arm32__} %{m3:-U__arm32__} \
%{m2:-Uarm32} %{m3:-Uarm32} \
%{posix:-D_POSIX_SOURCE}"
/* Because TARGET_DEFAULT sets ARM_FLAG_APCS_32 */
#undef CPP_APCS_PC_DEFAULT_SPEC

View File

@ -13,7 +13,7 @@
#include <netbsd.h>
#undef CPP_PREDEFINES
#define CPP_PREDEFINES "-Dunix -Di386 -D__NetBSD__ -Asystem(unix) -Asystem(NetBSD) -Acpu(i386) -Amachine(i386)"
#define CPP_PREDEFINES "-Dunix -Di386 -D__NetBSD__ -D__KPRINTF_ATTRIBUTE__ -Asystem(unix) -Asystem(NetBSD) -Acpu(i386) -Amachine(i386)"
#undef SIZE_TYPE
#define SIZE_TYPE "unsigned int"

View File

@ -35,6 +35,13 @@
#endif
/* Provide a STARTFILE_SPEC appropriate for NetBSD. Here we provide
support for the special GCC option -static. */
#undef STARTFILE_SPEC
#define STARTFILE_SPEC \
"%{!shared:%{pg:gcrt0%O%s}%{!pg:%{p:mcrt0%O%s}%{!p:%{!static:crt0%O%s}%{static:scrt0%O%s}}}}"
/* Provide a CPP_SPEC appropriate for NetBSD. Current we just deal with
the GCC option `-posix'. */
@ -48,17 +55,20 @@
#define ASM_SPEC " %| %{fpic:-k} %{fPIC:-k -K}"
/* Provide a LIB_SPEC appropriate for NetBSD. Just select the appropriate
libc, depending on whether we're doing profiling. */
libc, depending on whether we're doing profiling; if `-posix' is specified,
link against the appropriate libposix first. */
#undef LIB_SPEC
#define LIB_SPEC "%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}"
#define LIB_SPEC \
"%{posix:%{!p:%{!pg:-lposix}}%{p:-lposix_p}%{pg:-lposix_p}} \
%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}"
/* Provide a LINK_SPEC appropriate for NetBSD. Here we provide support
for the special GCC options -static, -assert, and -nostdlib. */
#undef LINK_SPEC
#define LINK_SPEC \
"%{!nostdlib:%{!r*:%{!e*:-e start}}} -dc -dp %{R*} %{static:-Bstatic} %{assert*}"
"%{nostdlib:-nostdlib} %{!nostdlib:%{!r*:%{!e*:-e start}}} -dc -dp %{R*} %{static:-Bstatic} %{assert*}"
/* This defines which switch letters take arguments. */
#undef SWITCH_TAKES_ARG

View File

@ -7,7 +7,7 @@
/* Names to predefine in the preprocessor for this target machine. */
#undef CPP_PREDEFINES
#define CPP_PREDEFINES "-Dunix -Dsparc -D__NetBSD__ -Asystem(unix) -Asystem(NetBSD) -Acpu(sparc) -Amachine(sparc)"
#define CPP_PREDEFINES "-Dunix -Dsparc -D__NetBSD__ -D__KPRINTF_ATTRIBUTE__ -Asystem(unix) -Asystem(NetBSD) -Acpu(sparc) -Amachine(sparc)"
/* Make gcc agree with <machine/ansi.h> */
@ -43,3 +43,8 @@
and initialization stuff better. */
#define DWARF2_UNWIND_INFO 0
/* Name the port */
#define TARGET_NAME "sparc-netbsd"
/* Name the default cpu target */
#define TARGET_CPU_DEFAULT TARGET_CPU_sparc

View File

@ -1,5 +1,5 @@
#undef CPP_PREDEFINES
#define CPP_PREDEFINES "-Dunix -Dvax -D__NetBSD__ -Asystem(unix) -Asystem(NetBSD) -Acpu(vax) -Amachine(vax)"
#define CPP_PREDEFINES "-Dunix -Dvax -D__NetBSD__ -D__KPRINTF_ATTRIBUTE__ -Asystem(unix) -Asystem(NetBSD) -Acpu(vax) -Amachine(vax)"
/* Make gcc agree with <machine/ansi.h> */

View File

@ -619,7 +619,7 @@ is usually
comes from the environment variable
.B TMPDIR
(default
.B /usr/tmp
.B /var/tmp
if available, else
.B /tmp\c
\&).

10
gnu/dist/gcc/gcc.1 vendored
View File

@ -20,7 +20,7 @@
.if n .sp
.if t .sp 0.4
..
.Id $Id: gcc.1,v 1.1.1.1 1998/03/29 08:14:37 mrg Exp $
.Id $Id: gcc.1,v 1.2 1998/03/29 11:36:53 mrg Exp $
.TH GCC 1 "\*(Dt" "GNU Tools" "GNU Tools"
.SH NAME
gcc, g++ \- GNU project C and C++ Compiler (egcs-1.0.2)
@ -688,7 +688,7 @@ undesirable and rarely used ANSI trigraph feature, and disallows `\|\c
.B $\c
\&\|' as part of identifiers.
.Sp
The alternate keywords \c
The alternative keywords \c
.B _\|_asm_\|_\c
\&, \c
.B _\|_extension_\|_\c
@ -703,7 +703,7 @@ The alternate keywords \c
course, but it is useful to put them in header files that might be included
in compilations done with `\|\c
.B \-ansi\c
\&\|'. Alternate predefined macros
\&\|'. Alternative predefined macros
such as \c
.B _\|_unix_\|_\c
\& and \c
@ -1641,7 +1641,7 @@ no reason to \c
`\|\c
.B \-pedantic\c
\&\|' does not cause warning messages for use of the
alternate keywords whose names begin and end with `\|\c
alternative keywords whose names begin and end with `\|\c
.B _\|_\c
\&\|'. Pedantic
warnings are also disabled in the expression that follows
@ -4112,7 +4112,7 @@ is usually
comes from the environment variable
.B TMPDIR
(default
.B /usr/tmp
.B /var/tmp
if available, else
.B /tmp\c
\&).

View File

@ -1406,6 +1406,8 @@ __eprintf (const char *string, const char *expression,
#ifdef L_bb
#include <sys/time.h>
/* Structure emitted by -a */
struct bb
{