1999-10-12 22:44:18 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
Test to see if a particular fix should be applied to a header file.
|
|
|
|
|
2000-02-27 04:02:01 +08:00
|
|
|
Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
|
1999-10-12 22:44:18 +08:00
|
|
|
|
|
|
|
= = = = = = = = = = = = = = = = = = = = = = = = =
|
|
|
|
|
|
|
|
NOTE TO DEVELOPERS
|
|
|
|
|
2000-05-12 03:30:47 +08:00
|
|
|
The routines you write here must work closely with fixincl.c.
|
1999-10-12 22:44:18 +08:00
|
|
|
|
|
|
|
Here are the rules:
|
|
|
|
|
|
|
|
1. Every test procedure name must be suffixed with "_test".
|
|
|
|
These routines will be referenced from inclhack.def, sans the suffix.
|
|
|
|
|
|
|
|
2. Use the "TEST_FOR_FIX_PROC_HEAD()" macro _with_ the "_test" suffix
|
|
|
|
(I cannot use the ## magic from ANSI C) for defining your entry point.
|
|
|
|
|
|
|
|
3. Put your test name into the FIX_TEST_TABLE
|
|
|
|
|
|
|
|
4. Do not write anything to stdout. It may be closed.
|
|
|
|
|
|
|
|
5. Write to stderr only in the event of a reportable error
|
|
|
|
In such an event, call "exit(1)".
|
|
|
|
|
|
|
|
= = = = = = = = = = = = = = = = = = = = = = = = =
|
|
|
|
|
2003-05-24 04:48:48 +08:00
|
|
|
This file is part of GCC.
|
1999-10-12 22:44:18 +08:00
|
|
|
|
2003-05-24 04:48:48 +08:00
|
|
|
GCC is free software; you can redistribute it and/or modify
|
1999-10-12 22:44:18 +08:00
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
any later version.
|
|
|
|
|
2003-05-24 04:48:48 +08:00
|
|
|
GCC is distributed in the hope that it will be useful,
|
1999-10-12 22:44:18 +08:00
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2003-05-24 04:48:48 +08:00
|
|
|
along with GCC; see the file COPYING. If not, write to
|
1999-10-12 22:44:18 +08:00
|
|
|
the Free Software Foundation, 59 Temple Place - Suite 330,
|
|
|
|
Boston, MA 02111-1307, USA. */
|
|
|
|
|
|
|
|
#include "fixlib.h"
|
|
|
|
|
2001-05-28 02:21:04 +08:00
|
|
|
#define _ENV_(v,m,n,t) extern tCC* v;
|
|
|
|
ENV_TABLE
|
|
|
|
#undef _ENV_
|
|
|
|
|
2003-08-02 07:07:04 +08:00
|
|
|
typedef apply_fix_p_t t_test_proc ( tCC* file, tCC* text );
|
2000-09-12 22:28:55 +08:00
|
|
|
|
1999-10-12 22:44:18 +08:00
|
|
|
typedef struct {
|
2000-09-12 22:28:55 +08:00
|
|
|
tCC* test_name;
|
|
|
|
t_test_proc* test_proc;
|
1999-10-12 22:44:18 +08:00
|
|
|
} test_entry_t;
|
|
|
|
|
2003-01-22 09:02:51 +08:00
|
|
|
#define FIX_TEST_TABLE \
|
|
|
|
_FT_( "machine_name", machine_name_test ) \
|
2001-05-26 05:36:08 +08:00
|
|
|
_FT_( "stdc_0_in_system_headers", stdc_0_in_system_headers_test )
|
1999-10-12 22:44:18 +08:00
|
|
|
|
2003-08-02 07:07:04 +08:00
|
|
|
#define TEST_FOR_FIX_PROC_HEAD( test ) \
|
|
|
|
static apply_fix_p_t test ( tCC* fname ATTRIBUTE_UNUSED, \
|
|
|
|
tCC* text ATTRIBUTE_UNUSED )
|
1999-10-22 21:23:43 +08:00
|
|
|
|
2000-01-21 02:25:12 +08:00
|
|
|
TEST_FOR_FIX_PROC_HEAD( machine_name_test )
|
|
|
|
{
|
|
|
|
regex_t *label_re, *name_re;
|
|
|
|
regmatch_t match[2];
|
|
|
|
tCC *base, *limit;
|
2000-12-14 04:07:46 +08:00
|
|
|
IGNORE_ARG(fname);
|
2000-01-21 02:25:12 +08:00
|
|
|
|
2004-08-30 21:32:57 +08:00
|
|
|
if (!mn_get_regexps (&label_re, &name_re, "machine_name_test"))
|
|
|
|
return SKIP_FIX;
|
2000-01-21 02:25:12 +08:00
|
|
|
|
|
|
|
for (base = text;
|
2003-07-09 04:42:19 +08:00
|
|
|
xregexec (label_re, base, 2, match, 0) == 0;
|
2000-01-21 02:25:12 +08:00
|
|
|
base = limit)
|
|
|
|
{
|
|
|
|
base += match[0].rm_eo;
|
|
|
|
/* We're looking at an #if or #ifdef. Scan forward for the
|
|
|
|
next non-escaped newline. */
|
|
|
|
limit = base;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
limit++;
|
|
|
|
limit = strchr (limit, '\n');
|
|
|
|
if (!limit)
|
|
|
|
return SKIP_FIX;
|
|
|
|
}
|
|
|
|
while (limit[-1] == '\\');
|
|
|
|
|
|
|
|
/* If the 'name_pat' matches in between base and limit, we have
|
|
|
|
a bogon. It is not worth the hassle of excluding comments,
|
|
|
|
because comments on #if/#ifdef/#ifndef lines are rare,
|
|
|
|
and strings on such lines are illegal.
|
|
|
|
|
|
|
|
REG_NOTBOL means 'base' is not at the beginning of a line, which
|
|
|
|
shouldn't matter since the name_re has no ^ anchor, but let's
|
|
|
|
be accurate anyway. */
|
|
|
|
|
2003-07-09 04:42:19 +08:00
|
|
|
if (xregexec (name_re, base, 1, match, REG_NOTBOL))
|
2000-01-21 02:25:12 +08:00
|
|
|
return SKIP_FIX; /* No match in file - no fix needed */
|
|
|
|
|
|
|
|
/* Match; is it on the line? */
|
2000-01-26 15:37:30 +08:00
|
|
|
if (match[0].rm_eo <= limit - base)
|
2000-01-21 02:25:12 +08:00
|
|
|
return APPLY_FIX; /* Yup */
|
|
|
|
|
|
|
|
/* Otherwise, keep looking... */
|
|
|
|
}
|
|
|
|
return SKIP_FIX;
|
|
|
|
}
|
|
|
|
|
Makefile.in: Correct dependencies of fixincl and fixincl.o.
* fixinc/Makefile.in: Correct dependencies of fixincl and fixincl.o.
* fixinc/fixfixes.c (IO_use, CTRL_use, IO_defn, CTRL_defn): New fixes.
(fix_char_macro_defines, fix_char_macro_uses): New functions.
* fixinc/fixlib.c (is_cxx_header): Do the text scan with a regexp.
Recognize Emacs mode markers also.
* fixinc/fixtests.c (else_endif_label): Fix bug in recognition of
C++ comments in C++ headers. Call is_cxx_header only if
necessary.
* fixinc/inclhack.def (avoid_bool): Add select for the problem and
bypass for ncurses.
(bsd43_io_macros, io_def_quotes, ioctl_fix_ctrl): Replace with...
(io_def_quotes, io_use_quotes, ctrl_def_quotes, ctrl_use_quotes):
... these, which use the new C fixes.
(math_exception): Escape literal '+' in bypass expression.
* fixinc/fixincl.x, fixinc/fixincl.sh, fixinc/inclhack.sh:
Regenerate.
From-SVN: r31512
2000-01-20 05:41:04 +08:00
|
|
|
|
2001-05-26 05:36:08 +08:00
|
|
|
TEST_FOR_FIX_PROC_HEAD( stdc_0_in_system_headers_test )
|
|
|
|
{
|
|
|
|
#ifdef STDC_0_IN_SYSTEM_HEADERS
|
2001-05-27 01:27:10 +08:00
|
|
|
return (pz_machine == NULL) ? APPLY_FIX : SKIP_FIX;
|
2001-05-26 05:36:08 +08:00
|
|
|
#else
|
|
|
|
return APPLY_FIX;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-12 22:44:18 +08:00
|
|
|
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
|
|
|
|
|
|
|
|
test for fix selector
|
|
|
|
|
|
|
|
THIS IS THE ONLY EXPORTED ROUTINE
|
|
|
|
|
|
|
|
*/
|
|
|
|
apply_fix_p_t
|
2003-08-02 07:07:04 +08:00
|
|
|
run_test( tCC* tname, tCC* fname, tCC* text )
|
1999-10-12 22:44:18 +08:00
|
|
|
{
|
1999-11-02 02:14:50 +08:00
|
|
|
#define _FT_(n,p) { n, p },
|
1999-10-12 22:44:18 +08:00
|
|
|
static test_entry_t test_table[] = { FIX_TEST_TABLE { NULL, NULL }};
|
1999-11-02 02:14:50 +08:00
|
|
|
#undef _FT_
|
optabs.c (init_optabs): Initialize fixtab...
* optabs.c (init_optabs): Initialize fixtab, fixtrunctab, floattab,
and extendtab within their proper array boundaries.
* emit-rtl.c (init_emit_once): Pass `const_tiny_rtx' with bounds
for the entire array.
* config/arm/arm.c (arm_override_options): Use ARRAY_SIZE.
* config/alpha/alpha.c (alpha_lookup_xfloating_lib_func): Likewise.
* config/avr/avr.c (order_regs_for_local_alloc): Likewise.
* config/fr30/fr30.c (fr30_print_operand): Likewise.
* config/i386/dgux.c (output_options): Likewise.
* config/i386/dgux.h (ASM_FILE_START): Likewise.
* config/m88k/m88k.c (output_options): Likewise.
* config/m88k/m88k.h (ASM_FILE_START): Likewise.
* config/mcore/mcore.c (mcore_output_inline_const_forced,
layout_mcore_frame, handle_structs_in_regs): Likewise.
* config/mips/mips.c (output_block_move): Likewise.
* config/rs6000/rs6000.c (rs6000_override_options,
rs6000_file_start): Likewise.
* config/sparc/sparc.c (sparc_add_gc_roots): Likewise.
* fixinc/fixfixes.c (FIX_TABLE_CT): Likewise.
* fixinc/fixtests.c (TEST_TABLE_CT): Likewise.
* builtins.c (expand_builtin_setjmp): Likewise.
* expr.c (safe_from_p): Likewise.
* flow.c (life_analysis): Likewise.
* fold-const.c (size_int_type_wide): Likewise.
* gcc.c (translate_options, init_spec, set_spec, main): Likewise.
* genattrtab.c (make_length_attrs): Likewise.
* genopinit.c (gen_insn): Likewise.
* genrecog.c (NUM_KNOWN_PREDS, NUM_SPECIAL_MODE_PREDS): Likewise.
* global.c (global_alloc): Likewise.
* local-alloc.c (find_free_reg): Likewise.
* mips-tdump.c (print_symbol): Likewise.
* mips-tfile.c (parse_def, parse_input): Likewise.
* reload1.c (NUM_ELIMINABLE_REGS): Likewise.
* stmt.c (expand_nl_goto_receiver): Likewise.
* stor-layout.c (set_sizetype): Likewise.
* varasm.c (decode_reg_name): Likewise.
* toplev.c (decode_f_option, decode_W_option,
set_target_switch, print_switch_values): Likewise.
(NUM_ELEM): Remove macro.
(display_help, main): s/NUM_ELEM/ARRAY_SIZE/
From-SVN: r35949
2000-08-25 04:31:35 +08:00
|
|
|
#define TEST_TABLE_CT (ARRAY_SIZE (test_table)-1)
|
1999-10-12 22:44:18 +08:00
|
|
|
|
|
|
|
int ct = TEST_TABLE_CT;
|
|
|
|
test_entry_t* pte = test_table;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (strcmp( pte->test_name, tname ) == 0)
|
|
|
|
return (*pte->test_proc)( fname, text );
|
1999-10-22 21:23:43 +08:00
|
|
|
pte++;
|
1999-10-12 22:44:18 +08:00
|
|
|
} while (--ct > 0);
|
|
|
|
fprintf( stderr, "fixincludes error: the `%s' fix test is unknown\n",
|
|
|
|
tname );
|
|
|
|
exit( 3 );
|
|
|
|
}
|