1999-10-12 16:44:18 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
Test to see if a particular fix should be applied to a header file.
|
|
|
|
|
2013-01-04 13:49:55 +01:00
|
|
|
Copyright (C) 1997, 1998, 1999, 2000, 2009, 2012
|
|
|
|
Free Software Foundation, Inc.
|
1999-10-12 16:44:18 +02:00
|
|
|
|
|
|
|
= = = = = = = = = = = = = = = = = = = = = = = = =
|
|
|
|
|
|
|
|
NOTE TO DEVELOPERS
|
|
|
|
|
2000-05-11 21:30:47 +02:00
|
|
|
The routines you write here must work closely with fixincl.c.
|
1999-10-12 16:44:18 +02: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-23 22:48:48 +02:00
|
|
|
This file is part of GCC.
|
1999-10-12 16:44:18 +02:00
|
|
|
|
2003-05-23 22:48:48 +02:00
|
|
|
GCC is free software; you can redistribute it and/or modify
|
1999-10-12 16:44:18 +02:00
|
|
|
it under the terms of the GNU General Public License as published by
|
2009-04-09 17:00:19 +02:00
|
|
|
the Free Software Foundation; either version 3, or (at your option)
|
1999-10-12 16:44:18 +02:00
|
|
|
any later version.
|
|
|
|
|
2003-05-23 22:48:48 +02:00
|
|
|
GCC is distributed in the hope that it will be useful,
|
1999-10-12 16:44:18 +02: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
|
2009-04-09 17:00:19 +02:00
|
|
|
along with GCC; see the file COPYING3. If not see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
1999-10-12 16:44:18 +02:00
|
|
|
|
|
|
|
#include "fixlib.h"
|
|
|
|
|
2012-10-29 17:44:34 +01:00
|
|
|
#define _ENV_(v,m,n,t) extern char const * v;
|
2001-05-27 20:21:04 +02:00
|
|
|
ENV_TABLE
|
|
|
|
#undef _ENV_
|
|
|
|
|
2003-08-02 01:07:04 +02:00
|
|
|
typedef apply_fix_p_t t_test_proc ( tCC* file, tCC* text );
|
2000-09-12 16:28:55 +02:00
|
|
|
|
1999-10-12 16:44:18 +02:00
|
|
|
typedef struct {
|
2000-09-12 16:28:55 +02:00
|
|
|
tCC* test_name;
|
|
|
|
t_test_proc* test_proc;
|
1999-10-12 16:44:18 +02:00
|
|
|
} test_entry_t;
|
|
|
|
|
2003-01-22 02:02:51 +01:00
|
|
|
#define FIX_TEST_TABLE \
|
|
|
|
_FT_( "machine_name", machine_name_test ) \
|
2001-05-25 23:36:08 +02:00
|
|
|
_FT_( "stdc_0_in_system_headers", stdc_0_in_system_headers_test )
|
1999-10-12 16:44:18 +02:00
|
|
|
|
2003-08-02 01:07:04 +02: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 15:23:43 +02:00
|
|
|
|
2000-01-20 19:25:12 +01:00
|
|
|
TEST_FOR_FIX_PROC_HEAD( machine_name_test )
|
|
|
|
{
|
|
|
|
regex_t *label_re, *name_re;
|
|
|
|
regmatch_t match[2];
|
|
|
|
tCC *base, *limit;
|
2000-12-13 21:07:46 +01:00
|
|
|
IGNORE_ARG(fname);
|
2000-01-20 19:25:12 +01:00
|
|
|
|
2004-08-30 15:32:57 +02:00
|
|
|
if (!mn_get_regexps (&label_re, &name_re, "machine_name_test"))
|
|
|
|
return SKIP_FIX;
|
2000-01-20 19:25:12 +01:00
|
|
|
|
|
|
|
for (base = text;
|
2003-07-08 22:42:19 +02:00
|
|
|
xregexec (label_re, base, 2, match, 0) == 0;
|
2000-01-20 19:25:12 +01: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-08 22:42:19 +02:00
|
|
|
if (xregexec (name_re, base, 1, match, REG_NOTBOL))
|
2000-01-20 19:25:12 +01:00
|
|
|
return SKIP_FIX; /* No match in file - no fix needed */
|
|
|
|
|
|
|
|
/* Match; is it on the line? */
|
2000-01-26 08:37:30 +01:00
|
|
|
if (match[0].rm_eo <= limit - base)
|
2000-01-20 19:25:12 +01: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-19 22:41:04 +01:00
|
|
|
|
2001-05-25 23:36:08 +02:00
|
|
|
TEST_FOR_FIX_PROC_HEAD( stdc_0_in_system_headers_test )
|
|
|
|
{
|
|
|
|
#ifdef STDC_0_IN_SYSTEM_HEADERS
|
2001-05-26 19:27:10 +02:00
|
|
|
return (pz_machine == NULL) ? APPLY_FIX : SKIP_FIX;
|
2001-05-25 23:36:08 +02:00
|
|
|
#else
|
|
|
|
return APPLY_FIX;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-12 16:44:18 +02:00
|
|
|
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
|
|
|
|
|
|
|
|
test for fix selector
|
|
|
|
|
|
|
|
THIS IS THE ONLY EXPORTED ROUTINE
|
|
|
|
|
|
|
|
*/
|
|
|
|
apply_fix_p_t
|
2003-08-02 01:07:04 +02:00
|
|
|
run_test( tCC* tname, tCC* fname, tCC* text )
|
1999-10-12 16:44:18 +02:00
|
|
|
{
|
1999-11-01 19:14:50 +01:00
|
|
|
#define _FT_(n,p) { n, p },
|
1999-10-12 16:44:18 +02:00
|
|
|
static test_entry_t test_table[] = { FIX_TEST_TABLE { NULL, NULL }};
|
1999-11-01 19:14:50 +01: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-24 22:31:35 +02:00
|
|
|
#define TEST_TABLE_CT (ARRAY_SIZE (test_table)-1)
|
1999-10-12 16:44:18 +02: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 15:23:43 +02:00
|
|
|
pte++;
|
1999-10-12 16:44:18 +02:00
|
|
|
} while (--ct > 0);
|
|
|
|
fprintf( stderr, "fixincludes error: the `%s' fix test is unknown\n",
|
|
|
|
tname );
|
|
|
|
exit( 3 );
|
|
|
|
}
|