Commit 5793b276 by Neil Booth Committed by Neil Booth

Makefile.in (C_AND_OBJC_OBJS, [...]): Update.

	* Makefile.in (C_AND_OBJC_OBJS, c-incpath.o, c-lex.o, LIBCPP_OBJS,
	cppinit.o, cppdefault.o, fix-header): Update.
	* c-incpath.c: New file.
	* c-incpath.h: New file.
	* c-lex.c: Include c-incpath.h.
	(init_c_lex): Register path simplifier.
	* c-opts.c: Include cppdefault.h and c-incpath.h.
	(TARGET_SYSTEM_ROOT, verbose, iprefix, sysroot, std_inc,
	std_cxx_inc, quote_chain_split, add_prefixed_path): New.
	(COMMAND_LINE_OPTIONS): Add more options from cpplib.
	(missing_arg, c_common_decode_option): Handle them.
	(c_common_post_options): Register include chains.
	(print_help): Update.
	* cppdefault.h (struct default include): Update.
	Move some macros to ...
	* cppdefault.c: ... here.
	(cpp_include_defaults): Add extra field add_sysroot.
	* cppfiles.c (include_file, search_from, find_or_create_entry,
	cpp_included, find_include_file, remap_filename): Update for
	renaming of search_path to cpp_path, and of the chain headers.
	(remove_component_p, _cpp_simplify_pathname): Move to c-incpath.c.
	* cpphash.h (struct search_path): Move to cpplib.h.
	(struct cpp_buffer, struct cpp_reader): Update.
	(_cpp_simplify_pathname): Remove.
	* cppinit.c: Don't include prefix.h and cppdefault.h.
	(INO_T_EQ, INO_T_COPY, path_include, append_include_chain,
	remove_dup_dir, remove_dup_nonsys_dirs, remove_dup_dirs,
	init_standard_includes, BRACKET, SYSTEM, AFTER, no_dir,
	no_pth, cpp_handle_options): Remove.
	(struct pending_option): Remove chain members.
	(cpp_destroy, cpp_read_main_file, COMMAND_LINE_OPTIONS,
	cpp_handle_option): Update.
	* cpplib.h (struct cpp_path, cpp_set_include_chains): New.
	(struct cpp_options): Remove quote_include, bracket_include,
	include_prefix, include_prefix_len, verbose, ignore_srcdir,
	no_standard_includes, no_standard_cplusplus_includes.
	(struct cpp_callbacks): Add simplify_path.
	(cpp_handle_options): Remove.
	* fix-header.c: Include c-incpath.h.
	(read_scan_file): Update to use c-incpath functionality.
	* doc/passes.texi: Update.
cp:
	* Make-lang.in (CXX_C_OBJS): Update.

From-SVN: r63612
parent 6620997b
2003-03-01 Neil Booth <neil@daikokuya.co.uk>
* Makefile.in (C_AND_OBJC_OBJS, c-incpath.o, c-lex.o, LIBCPP_OBJS,
cppinit.o, cppdefault.o, fix-header): Update.
* c-incpath.c: New file.
* c-incpath.h: New file.
* c-lex.c: Include c-incpath.h.
(init_c_lex): Register path simplifier.
* c-opts.c: Include cppdefault.h and c-incpath.h.
(TARGET_SYSTEM_ROOT, verbose, iprefix, sysroot, std_inc,
std_cxx_inc, quote_chain_split, add_prefixed_path): New.
(COMMAND_LINE_OPTIONS): Add more options from cpplib.
(missing_arg, c_common_decode_option): Handle them.
(c_common_post_options): Register include chains.
(print_help): Update.
* cppdefault.h (struct default include): Update.
Move some macros to ...
* cppdefault.c: ... here.
(cpp_include_defaults): Add extra field add_sysroot.
* cppfiles.c (include_file, search_from, find_or_create_entry,
cpp_included, find_include_file, remap_filename): Update for
renaming of search_path to cpp_path, and of the chain headers.
(remove_component_p, _cpp_simplify_pathname): Move to c-incpath.c.
* cpphash.h (struct search_path): Move to cpplib.h.
(struct cpp_buffer, struct cpp_reader): Update.
(_cpp_simplify_pathname): Remove.
* cppinit.c: Don't include prefix.h and cppdefault.h.
(INO_T_EQ, INO_T_COPY, path_include, append_include_chain,
remove_dup_dir, remove_dup_nonsys_dirs, remove_dup_dirs,
init_standard_includes, BRACKET, SYSTEM, AFTER, no_dir,
no_pth, cpp_handle_options): Remove.
(struct pending_option): Remove chain members.
(cpp_destroy, cpp_read_main_file, COMMAND_LINE_OPTIONS,
cpp_handle_option): Update.
* cpplib.h (struct cpp_path, cpp_set_include_chains): New.
(struct cpp_options): Remove quote_include, bracket_include,
include_prefix, include_prefix_len, verbose, ignore_srcdir,
no_standard_includes, no_standard_cplusplus_includes.
(struct cpp_callbacks): Add simplify_path.
(cpp_handle_options): Remove.
* fix-header.c: Include c-incpath.h.
(read_scan_file): Update to use c-incpath functionality.
* doc/passes.texi: Update.
2003-03-01 Kazu Hirata <kazu@cs.umass.edu>
* config/h8300/h8300.c (bit_operand): Accept MEM only if it
......
......@@ -759,6 +759,7 @@ CXX_TARGET_OBJS=@cxx_target_objs@
# Language-specific object files for C and Objective C.
C_AND_OBJC_OBJS = attribs.o c-errors.o c-lex.o c-pragma.o c-decl.o c-typeck.o \
c-convert.o c-aux-info.o c-common.o c-opts.o c-format.o c-semantics.o \
c-incpath.o cppdefault.o \
c-objc-common.o c-dump.o c-pch.o libcpp.a $(C_TARGET_OBJS)
# Language-specific object files for C.
......@@ -1218,6 +1219,9 @@ $(parsedir)/c-parse.y: c-parse.in
$(srcdir)/c-parse.in >>tmp-c-parse.y
$(SHELL) $(srcdir)/move-if-change tmp-c-parse.y $(parsedir)/c-parse.y
c-incpath.o: c-incpath.c c-incpath.h $(CONFIG_H) $(SYSTEM_H) $(CPPLIB_H) \
intl.h prefix.h coretypes.h $(TM_H) cppdefault.h
c-decl.o : c-decl.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(RTL_H) \
$(C_TREE_H) $(GGC_H) $(TARGET_H) flags.h function.h output.h $(EXPR_H) \
debug.h toplev.h intl.h $(TM_P_H) tree-inline.h $(TIMEVAR_H) c-pragma.h \
......@@ -1226,8 +1230,8 @@ c-typeck.o : c-typeck.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(
$(TARGET_H) flags.h intl.h output.h $(EXPR_H) $(RTL_H) toplev.h $(TM_P_H)
c-lang.o : c-lang.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(C_TREE_H) \
$(GGC_H) langhooks.h $(LANGHOOKS_DEF_H) c-common.h gtype-c.h
c-lex.o : c-lex.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(RTL_H) \
debug.h $(C_TREE_H) c-common.h real.h \
c-lex.o : c-lex.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
$(RTL_H) debug.h $(C_TREE_H) c-common.h real.h c-incpath.h cppdefault.h \
c-pragma.h input.h intl.h flags.h toplev.h output.h \
mbchar.h $(CPPLIB_H) $(EXPR_H) $(TM_P_H)
c-objc-common.o : c-objc-common.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
......@@ -2271,7 +2275,7 @@ PREPROCESSOR_DEFINES = \
@TARGET_SYSTEM_ROOT_DEFINE@
LIBCPP_OBJS = cpplib.o cpplex.o cppmacro.o cppexp.o cppfiles.o cpptrad.o \
cpphash.o cpperror.o cppinit.o cppdefault.o cppmain.o \
cpphash.o cpperror.o cppinit.o cppmain.o \
hashtable.o line-map.o mkdeps.o prefix.o mbchar.o cpppch.o
LIBCPP_DEPS = $(CPPLIB_H) cpphash.h line-map.h hashtable.h intl.h \
......@@ -2294,11 +2298,11 @@ cpplib.o: cpplib.c $(LIBCPP_DEPS)
cpphash.o: cpphash.c $(LIBCPP_DEPS)
cpptrad.o: cpptrad.c $(LIBCPP_DEPS)
cppfiles.o: cppfiles.c $(LIBCPP_DEPS) $(SPLAY_TREE_H) mkdeps.h
cppinit.o: cppinit.c $(LIBCPP_DEPS) cppdefault.h mkdeps.h prefix.h
cppinit.o: cppinit.c $(LIBCPP_DEPS) mkdeps.h prefix.h
cpppch.o: cpppch.c $(LIBCPP_DEPS) mkdeps.h
cppdefault.o: cppdefault.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) cppdefault.h \
Makefile
cppdefault.o: cppdefault.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
cppdefault.h Makefile
$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
$(PREPROCESSOR_DEFINES) \
-c $(srcdir)/cppdefault.c $(OUTPUT_OPTION)
......@@ -2512,9 +2516,9 @@ xsys-protos.h: $(GCC_PASSES) $(srcdir)/sys-protos.h deduced.h gen-protos$(build_
# This is nominally a 'build' program, but it's run only when host==build,
# so we can (indeed, must) use $(LIBDEPS) and $(LIBS).
fix-header$(build_exeext): fix-header.o scan-decls.o scan.o xsys-protos.h \
$(LIBDEPS) libcpp.a
c-incpath.o cppdefault.o $(LIBDEPS) libcpp.a
$(BUILD_CC) $(BUILD_CFLAGS) $(BUILD_LDFLAGS) -o $@ fix-header.o \
scan-decls.o scan.o libcpp.a $(LIBS)
c-incpath.o cppdefault.o scan-decls.o scan.o libcpp.a $(LIBS)
fix-header.o: fix-header.c $(OBSTACK_H) scan.h \
xsys-protos.h $(BCONFIG_H) $(SYSTEM_H) coretypes.h $(GTM_H) $(CPPLIB_H)
......
This diff is collapsed. Click to expand it.
/* Set up combined include path for the preprocessor.
Copyright (C) 2003 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify 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.
This program is distributed in the hope that it will be useful,
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
along with this program; if not, write to the Free Software
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
extern void split_quote_chain PARAMS ((void));
extern void add_path PARAMS ((char *, int, int));
extern void register_include_chains PARAMS ((cpp_reader *, const char *,
const char *, int, int, int));
extern void simplify_path PARAMS ((char *));
enum { QUOTE = 0, BRACKET, SYSTEM, AFTER };
/* Mainly the interface between cpplib and the C front ends.
Copyright (C) 1987, 1988, 1989, 1992, 1994, 1995, 1996, 1997
1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
This file is part of GCC.
......@@ -41,6 +41,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "tm_p.h"
#include "splay-tree.h"
#include "debug.h"
#include "c-incpath.h"
#ifdef MULTIBYTE_CHARS
#include "mbchar.h"
......@@ -124,6 +125,7 @@ init_c_lex (filename)
cb->ident = cb_ident;
cb->file_change = cb_file_change;
cb->def_pragma = cb_def_pragma;
cb->simplify_path = simplify_path;
cb->valid_pch = c_common_valid_pch;
cb->read_pch = c_common_read_pch;
......
/* C/ObjC/C++ command line option handling.
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Contributed by Neil Booth.
This file is part of GCC.
......@@ -32,6 +32,12 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "tree-inline.h"
#include "diagnostic.h"
#include "intl.h"
#include "cppdefault.h"
#include "c-incpath.h"
#ifndef TARGET_SYSTEM_ROOT
# define TARGET_SYSTEM_ROOT NULL
#endif
/* CPP's options. */
static cpp_options *cpp_opts;
......@@ -49,9 +55,27 @@ static bool deps_append;
/* If dependency switches (-MF etc.) have been given. */
static bool deps_seen;
/* If -v seen. */
static bool verbose;
/* Dependency output file. */
static const char *deps_file;
/* The prefix given by -iprefix, if any. */
static const char *iprefix;
/* The system root, if any. Overridden by -isysroot. */
static const char *sysroot = TARGET_SYSTEM_ROOT;
/* Zero disables all standard directories for headers. */
static bool std_inc = true;
/* Zero disables the C++-specific standard directories for headers. */
static bool std_cxx_inc = true;
/* If the quote chain has been split by -I-. */
static bool quote_chain_split;
/* Number of deferred options, deferred options array size. */
static size_t deferred_count, deferred_size;
......@@ -69,6 +93,7 @@ static void check_deps_environment_vars PARAMS ((void));
static void preprocess_file PARAMS ((void));
static void handle_deferred_opts PARAMS ((void));
static void sanitize_cpp_opts PARAMS ((void));
static void add_prefixed_path PARAMS ((const char *, size_t));
#ifndef STDC_0_IN_SYSTEM_HEADERS
#define STDC_0_IN_SYSTEM_HEADERS 0
......@@ -117,6 +142,7 @@ static void sanitize_cpp_opts PARAMS ((void));
OPT("CC", CL_ALL, OPT_CC) \
OPT("E", CL_ALL, OPT_E) \
OPT("H", CL_ALL, OPT_H) \
OPT("I", CL_ALL | CL_ARG, OPT_I) \
OPT("M", CL_ALL, OPT_M) \
OPT("MD", CL_ALL | CL_SEPARATE, OPT_MD) \
OPT("MF", CL_ALL | CL_ARG, OPT_MF) \
......@@ -260,6 +286,12 @@ static void sanitize_cpp_opts PARAMS ((void));
OPT("fweak", CL_CXX, OPT_fweak) \
OPT("fxref", CL_CXX, OPT_fxref) \
OPT("gen-decls", CL_OBJC, OPT_gen_decls) \
OPT("idirafter", CL_ALL | CL_ARG, OPT_idirafter) \
OPT("iprefix", CL_ALL | CL_ARG, OPT_iprefix) \
OPT("isysroot", CL_ALL | CL_ARG, OPT_isysroot) \
OPT("isystem", CL_ALL | CL_ARG, OPT_isystem) \
OPT("iwithprefix", CL_ALL | CL_ARG, OPT_iwithprefix) \
OPT("iwithprefixbefore", CL_ALL | CL_ARG, OPT_iwithprefixbefore) \
OPT("lang-asm", CL_C_ONLY, OPT_lang_asm) \
OPT("lang-objc", CL_ALL, OPT_lang_objc) \
OPT("nostdinc", CL_ALL, OPT_nostdinc) \
......@@ -357,6 +389,9 @@ missing_arg (opt_index)
case OPT_fname_mangling:
case OPT_ftabstop:
case OPT_ftemplate_depth:
case OPT_iprefix:
case OPT_iwithprefix:
case OPT_iwithprefixbefore:
default:
error ("missing argument to \"-%s\"", opt_text);
break;
......@@ -365,6 +400,13 @@ missing_arg (opt_index)
error ("no class name specified with \"-%s\"", opt_text);
break;
case OPT_I:
case OPT_idirafter:
case OPT_isysroot:
case OPT_isystem:
error ("missing path after \"-%s\"", opt_text);
break;
case OPT_MF:
case OPT_MD:
case OPT_MMD:
......@@ -654,6 +696,18 @@ c_common_decode_option (argc, argv)
cpp_opts->print_include_names = 1;
break;
case OPT_I:
if (strcmp (arg, "-"))
add_path (xstrdup (arg), BRACKET, 0);
else
{
if (quote_chain_split)
error ("-I- specified twice");
quote_chain_split = true;
split_quote_chain ();
}
break;
case OPT_M:
case OPT_MM:
/* When doing dependencies with -M or -MM, suppress normal
......@@ -1264,6 +1318,30 @@ c_common_decode_option (argc, argv)
flag_gen_declaration = 1;
break;
case OPT_idirafter:
add_path (xstrdup (arg), AFTER, 0);
break;
case OPT_iprefix:
iprefix = arg;
break;
case OPT_isysroot:
sysroot = arg;
break;
case OPT_isystem:
add_path (xstrdup (arg), SYSTEM, 0);
break;
case OPT_iwithprefix:
add_prefixed_path (arg, SYSTEM);
break;
case OPT_iwithprefixbefore:
add_prefixed_path (arg, BRACKET);
break;
case OPT_lang_asm:
cpp_set_lang (parse_in, CLK_ASM);
break;
......@@ -1273,14 +1351,11 @@ c_common_decode_option (argc, argv)
break;
case OPT_nostdinc:
/* No default include directories. You must specify all
include-file directories with -I. */
cpp_opts->no_standard_includes = 1;
std_inc = false;
break;
case OPT_nostdincplusplus:
/* No default C++-specific include directories. */
cpp_opts->no_standard_cplusplus_includes = 1;
std_cxx_inc = false;
break;
case OPT_o:
......@@ -1356,7 +1431,7 @@ c_common_decode_option (argc, argv)
break;
case OPT_v:
cpp_opts->verbose = 1;
verbose = true;
break;
}
......@@ -1384,6 +1459,10 @@ c_common_post_options ()
sanitize_cpp_opts ();
register_include_chains (parse_in, sysroot, iprefix,
std_inc, std_cxx_inc && c_language == clk_cplusplus,
verbose);
flag_inline_trees = 1;
/* Use tree inlining if possible. Function instrumentation is only
......@@ -1607,6 +1686,18 @@ sanitize_cpp_opts ()
= warn_long_long && ((!flag_isoc99 && pedantic) || warn_traditional);
}
/* Add include path with a prefix at the front of its name. */
static void
add_prefixed_path (suffix, chain)
const char *suffix;
size_t chain;
{
const char *prefix;
prefix = iprefix ? iprefix: cpp_GCC_INCLUDE_DIR;
add_path (concat (prefix, suffix), chain, 0);
}
/* Set the C 89 standard (with 1994 amendments if C94, without GNU
extensions if ISO). There is no concept of gnu94. */
static void
......@@ -1808,6 +1899,7 @@ Switches:\n\
fputs (_("\
-f[no-]preprocessed Treat the input file as already preprocessed\n\
-ftabstop=<number> Distance between tab stops for column reporting\n\
-isysroot <dir> Set <dir> to be the system root directory\n\
-P Do not generate #line directives\n\
-remap Remap file names when including files\n\
--help Display this information\n\
......
2003-03-01 Neil Booth <neil@daikokuya.co.uk>
* Make-lang.in (CXX_C_OBJS): Update.
2003-02-28 Mark Mitchell <mark@codesourcery.com>
PR c++/9892
......
......@@ -79,7 +79,8 @@ g++-cross$(exeext): g++$(exeext)
# The compiler itself.
# Shared with C front end:
CXX_C_OBJS = attribs.o c-common.o c-format.o c-pragma.o c-semantics.o c-lex.o \
c-dump.o $(CXX_TARGET_OBJS) c-pretty-print.o c-opts.o c-pch.o
c-dump.o $(CXX_TARGET_OBJS) c-pretty-print.o c-opts.o c-pch.o \
c-incpath.o cppdefault.o
# Language-specific object files.
CXX_OBJS = cp/call.o cp/decl.o cp/expr.o cp/pt.o cp/typeck2.o \
......
/* CPP Library.
Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
1999, 2000 Free Software Foundation, Inc.
1999, 2000, 2003 Free Software Foundation, Inc.
Contributed by Per Bothner, 1994-95.
Based on CCCP program by Paul Rubin, June 1986
Adapted to ANSI C, Richard Stallman, Jan 1987
......@@ -19,15 +19,28 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* This file contains data definitions shared between cpplib and
tradcpp. */
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "cppdefault.h"
#ifndef STANDARD_INCLUDE_DIR
#define STANDARD_INCLUDE_DIR "/usr/include"
#endif
#ifndef STANDARD_INCLUDE_COMPONENT
#define STANDARD_INCLUDE_COMPONENT 0
#endif
#if defined (CROSS_COMPILE) && !defined (TARGET_SYSTEM_ROOT)
# undef LOCAL_INCLUDE_DIR
# undef SYSTEM_INCLUDE_DIR
# undef STANDARD_INCLUDE_DIR
#else
# undef CROSS_INCLUDE_DIR
#endif
const struct default_include cpp_include_defaults[]
#ifdef INCLUDE_DEFAULTS
= INCLUDE_DEFAULTS;
......
/* CPP Library.
Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
1999, 2000 Free Software Foundation, Inc.
1999, 2000, 2003 Free Software Foundation, Inc.
Contributed by Per Bothner, 1994-95.
Based on CCCP program by Paul Rubin, June 1986
Adapted to ANSI C, Richard Stallman, Jan 1987
......@@ -22,26 +22,6 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef GCC_CPPDEFAULT_H
#define GCC_CPPDEFAULT_H
/* This header contains declarations and/or #defines for all the
hard-wired defaults in cpp. Note it's used by both cpplib and
tradcpp. */
#ifndef STANDARD_INCLUDE_DIR
#define STANDARD_INCLUDE_DIR "/usr/include"
#endif
#ifndef STANDARD_INCLUDE_COMPONENT
#define STANDARD_INCLUDE_COMPONENT 0
#endif
#if defined (CROSS_COMPILE) && !defined (TARGET_SYSTEM_ROOT)
# undef LOCAL_INCLUDE_DIR
# undef SYSTEM_INCLUDE_DIR
# undef STANDARD_INCLUDE_DIR
#else
# undef CROSS_INCLUDE_DIR
#endif
/* This is the default list of directories to search for include files.
It may be overridden by the various -I and -ixxx options.
......@@ -57,11 +37,11 @@ struct default_include
const char *const fname; /* The name of the directory. */
const char *const component; /* The component containing the directory
(see update_path in prefix.c) */
const int cplusplus; /* Only look here if we're compiling C++. */
const int cxx_aware; /* Includes in this directory don't need to
const char cplusplus; /* Only look here if we're compiling C++. */
const char cxx_aware; /* Includes in this directory don't need to
be wrapped in extern "C" when compiling
C++. */
const int add_sysroot; /* FNAME should be prefixed by
const char add_sysroot; /* FNAME should be prefixed by
cpp_SYSROOT. */
};
......
/* Part of CPP library.
Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
......@@ -130,26 +130,6 @@ extern unsigned char *_cpp_unaligned_alloc PARAMS ((cpp_reader *, size_t));
#define BUFF_FRONT(BUFF) ((BUFF)->cur)
#define BUFF_LIMIT(BUFF) ((BUFF)->limit)
/* List of directories to look for include files in. */
struct search_path
{
struct search_path *next;
/* NOTE: NAME may not be null terminated for the case of the current
file's directory! */
const char *name;
unsigned int len;
/* We use these to tell if the directory mentioned here is a duplicate
of an earlier directory on the search path. */
ino_t ino;
dev_t dev;
/* Nonzero if it is a system include directory. */
int sysp;
/* Mapping of file names for this directory. Only used on MS-DOS
and related platforms. */
struct file_name_map *name_map;
};
/* #include types. */
enum include_type {IT_INCLUDE, IT_INCLUDE_NEXT, IT_IMPORT, IT_CMDLINE};
......@@ -324,7 +304,7 @@ struct cpp_buffer
/* The directory of the this buffer's file. Its NAME member is not
allocated, so we don't need to worry about freeing it. */
struct search_path dir;
struct cpp_path dir;
/* Used for buffer overlays by cpptrad.c. */
const uchar *saved_cur, *saved_rlimit;
......@@ -369,6 +349,10 @@ struct cpp_reader
_cpp_maybe_push_include_file has yet to restore the line map. */
struct pending_option **next_include_file;
/* Search paths for include files. */
struct cpp_path *quote_include; /* "" */
struct cpp_path *bracket_include; /* <> */
/* Multiple include optimisation. */
const cpp_hashnode *mi_cmacro;
const cpp_hashnode *mi_ind_cmacro;
......@@ -441,6 +425,10 @@ struct cpp_reader
/* Used when doing preprocessed output. */
struct printer print;
/* Nonzero means don't look for #include "foo" the source-file
directory. */
unsigned char quote_ignores_source_dir;
/* Whether cpplib owns the hashtable. */
unsigned char our_hashtable;
......@@ -521,7 +509,6 @@ extern void _cpp_destroy_hashtable PARAMS ((cpp_reader *));
/* In cppfiles.c */
extern void _cpp_fake_include PARAMS ((cpp_reader *, const char *));
extern void _cpp_never_reread PARAMS ((struct include_file *));
extern char *_cpp_simplify_pathname PARAMS ((char *));
extern bool _cpp_read_file PARAMS ((cpp_reader *, const char *));
extern bool _cpp_execute_include PARAMS ((cpp_reader *,
const cpp_token *,
......
......@@ -39,6 +39,7 @@ typedef struct cpp_string cpp_string;
typedef struct cpp_hashnode cpp_hashnode;
typedef struct cpp_macro cpp_macro;
typedef struct cpp_callbacks cpp_callbacks;
typedef struct cpp_path cpp_path;
struct answer;
struct file_name_map_list;
......@@ -224,29 +225,13 @@ struct cpp_options
/* Pending options - -D, -U, -A, -I, -ixxx. */
struct cpp_pending *pending;
/* Search paths for include files. */
struct search_path *quote_include; /* "" */
struct search_path *bracket_include; /* <> */
/* Map between header names and file names, used only on DOS where
file names are limited in length. */
struct file_name_map_list *map_list;
/* Directory prefix that should replace `/usr/lib/gcc-lib/TARGET/VERSION'
in the standard include file directories. */
const char *include_prefix;
unsigned int include_prefix_len;
/* Directory prefix for system include directories in the standard search
path. */
const char *sysroot;
/* The language we're preprocessing. */
enum c_lang lang;
/* Non-0 means -v, so print the full set of include dirs. */
unsigned char verbose;
/* Nonzero means use extra default include directories for C++. */
unsigned char cplusplus;
......@@ -332,10 +317,6 @@ struct cpp_options
/* Nonzero means don't output line number information. */
unsigned char no_line_commands;
/* Nonzero means -I- has been seen, so don't look for #include "foo"
the source-file directory. */
unsigned char ignore_srcdir;
/* Zero means dollar signs are punctuation. */
unsigned char dollars_in_ident;
......@@ -358,12 +339,6 @@ struct cpp_options
bother trying to do macro expansion and whatnot. */
unsigned char preprocessed;
/* Nonzero disables all the standard directories for headers. */
unsigned char no_standard_includes;
/* Nonzero disables the C++-specific standard directories for headers. */
unsigned char no_standard_cplusplus_includes;
/* Nonzero means dump macros in some fashion - see above. */
unsigned char dump_macros;
......@@ -427,6 +402,7 @@ struct cpp_callbacks
void (*undef) PARAMS ((cpp_reader *, unsigned int, cpp_hashnode *));
void (*ident) PARAMS ((cpp_reader *, unsigned int, const cpp_string *));
void (*def_pragma) PARAMS ((cpp_reader *, unsigned int));
void (*simplify_path) PARAMS ((char *));
/* Called when the client has a chance to properly register
built-ins with cpp_define() and cpp_assert(). */
void (*register_builtins) PARAMS ((cpp_reader *));
......@@ -434,6 +410,30 @@ struct cpp_callbacks
void (*read_pch) PARAMS ((cpp_reader *, const char *, int, const char *));
};
/* Chain of directories to look for include files in. */
struct cpp_path
{
/* NULL-terminated singly-linked list. */
struct cpp_path *next;
/* NAME need not be NUL-terminated once inside cpplib. */
char *name;
unsigned int len;
/* One if a system header, two if a system header that has extern
"C" guards for C++. */
unsigned char sysp;
/* Mapping of file names for this directory for MS-DOS and
related platforms. */
struct file_name_map *name_map;
/* The C front end uses these to recognize duplicated
directories in the search path. */
ino_t ino;
dev_t dev;
};
/* Name under which this program was invoked. */
extern const char *progname;
......@@ -526,6 +526,10 @@ extern void cpp_add_dependency_target PARAMS ((cpp_reader *,
const char * target,
int quote));
/* Set the include paths. */
extern void cpp_set_include_chains PARAMS ((cpp_reader *, cpp_path *,
cpp_path *, int));
/* Call these to get pointers to the options and callback structures
for a given reader. These pointers are good until you call
cpp_finish on that reader. You can either edit the callbacks
......@@ -536,12 +540,9 @@ extern const struct line_maps *cpp_get_line_maps PARAMS ((cpp_reader *));
extern cpp_callbacks *cpp_get_callbacks PARAMS ((cpp_reader *));
extern void cpp_set_callbacks PARAMS ((cpp_reader *, cpp_callbacks *));
/* Now call cpp_handle_option[s] to handle 1[or more] switches. The
return value is the number of arguments used. If
cpp_handle_options returns without using all arguments, it couldn't
understand the next switch. Options processing is not completed
/* Now call cpp_handle_option to handle 1 switch. The return value is
the number of arguments used. Options processing is not completed
until you call cpp_finish_options. */
extern int cpp_handle_options PARAMS ((cpp_reader *, int, char **));
extern int cpp_handle_option PARAMS ((cpp_reader *, int, char **));
/* This function reads the file, but does not start preprocessing. It
......
......@@ -82,8 +82,10 @@ the other C-like languages: @file{c-common.c},
@file{c-pragma.c},
@file{c-semantics.c},
@file{c-lex.c},
@file{c-incpath.c}
@file{c-common.h},
@file{c-dump.h},
@file{c-incpath.h}
and
@file{c-pragma.h},
......
/* fix-header.c - Make C header file suitable for C++.
Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998,
1999, 2000, 2001 Free Software Foundation, Inc.
1999, 2000, 2001, 2003 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
......@@ -78,6 +78,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "obstack.h"
#include "scan.h"
#include "cpplib.h"
#include "c-incpath.h"
static void v_fatal PARAMS ((const char *, va_list)) ATTRIBUTE_PRINTF (1,0) ATTRIBUTE_NORETURN;
static void fatal PARAMS ((const char *, ...)) ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
......@@ -616,7 +617,7 @@ read_scan_file (in_fname, argc, argv)
cpp_callbacks *cb;
cpp_options *options;
struct fn_decl *fn;
int i;
int i, strings_processed;
struct symbol_list *cur_symbols;
obstack_init (&scan_file_obstack);
......@@ -624,6 +625,7 @@ read_scan_file (in_fname, argc, argv)
scan_in = cpp_create_reader (CLK_GNUC89);
cb = cpp_get_callbacks (scan_in);
cb->file_change = cb_file_change;
cb->simplify_path = simplify_path;
/* We are going to be scanning a header file out of its proper context,
so ignore warnings and errors. */
......@@ -631,12 +633,32 @@ read_scan_file (in_fname, argc, argv)
options->inhibit_warnings = 1;
options->inhibit_errors = 1;
i = cpp_handle_options (scan_in, argc, argv);
for (i = 0; i < argc; i += strings_processed)
{
if (argv[i][0] == 'I')
{
if (argv[i][1] != '\0')
strings_processed = 1, add_path (argv[i] + 1, BRACKET, false);
else if (i + 1 == argc)
strings_processed = 0;
else
strings_processed = 2, add_path (argv[i + 1], BRACKET, false);
}
else
strings_processed = cpp_handle_option (scan_in, argc - i, argv + i);
if (strings_processed == 0)
break;
}
if (i < argc)
cpp_error (scan_in, DL_ERROR, "invalid option `%s'", argv[i]);
if (cpp_errors (scan_in))
exit (FATAL_EXIT_CODE);
register_include_chains (scan_in, NULL /* sysroot */, NULL /* iprefix */,
true /* stdinc */, false /* cxx_stdinc */,
false /* verbose */);
if (! cpp_read_main_file (scan_in, in_fname, NULL))
exit (FATAL_EXIT_CODE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment