Commit 8f9b4009 by Neil Booth Committed by Neil Booth

Makefile.in (LIBCPP_DEPS): Add HASHTAB_H.

	* Makefile.in (LIBCPP_DEPS): Add HASHTAB_H.
	* cppfiles.c: Completely rewritten.
	* c-incpath.c (free_path, remove_duplicates, heads, tails, add_path):
	struct cpp_path is now struct cpp_dir.
	(remove_duplicates): Don't simplify path names.
	* c-opts.c (c_common_parse_file): cpp_read_next_file renamed
	cpp_stack_file.
	* cpphash.h: Include hashtab.h.
	(_cpp_file): Declare.
	(struct cpp_buffer): struct include_file is now struct _cpp_file,
	and struct cpp_path is now struct cpp_dir.  Rename members.
	(struct cpp_reader): Similarly.  New members once_only_files,
	file_hash, file_hash_entries, quote_ignores_source_dir,
	no_search_path, saw_pragma_once.  Remove all_include_files and
	max_include_len.  Make some members bool.
	(_cpp_mark_only_only): Renamed from _cpp_never_reread.
	(_cpp_stack_file): Renamed from _cpp_read_file.
	(_cpp_stack_include): Renamed from _cpp_execute_include.
	(_cpp_init_files): Renamed from _cpp_init_includes.
	(_cpp_cleanup_files): Renamed from _cpp_cleanup_includes.
	* cppinit.c (cpp_create_reader): Initialize no_search_path.  Update.
	(cpp_read_next_file): Rename and move to cppfiles.c.
	(cpp_read_main_file): Update.
	* cpplib.c (run_directive): Update for renamed members.
	(do_include_common, _cpp_pop_buffer): Update.
	(do_import): Undeprecate #import.
	(do_pragma_once): Undeprecate.  Use _cpp_mark_file_once_only.
	* cpplib.h: Remove file_name_map_list.
	(cpp_options): Remove map_list.
	(cpp_dir): Rename from cpp_path.  New datatype for name_map.
	(cpp_set_include_chains, cpp_stack_file, cpp_included): Update.
testsuite:
	* gcc.dg/cpp/include2.c: Only expect one message.

From-SVN: r69942
parent ad96995b
2003-07-29 Neil Booth <neil@daikokuya.co.uk>
* Makefile.in (LIBCPP_DEPS): Add HASHTAB_H.
* cppfiles.c: Completely rewritten.
* c-incpath.c (free_path, remove_duplicates, heads, tails, add_path):
struct cpp_path is now struct cpp_dir.
(remove_duplicates): Don't simplify path names.
* c-opts.c (c_common_parse_file): cpp_read_next_file renamed
cpp_stack_file.
* cpphash.h: Include hashtab.h.
(_cpp_file): Declare.
(struct cpp_buffer): struct include_file is now struct _cpp_file,
and struct cpp_path is now struct cpp_dir. Rename members.
(struct cpp_reader): Similarly. New members once_only_files,
file_hash, file_hash_entries, quote_ignores_source_dir,
no_search_path, saw_pragma_once. Remove all_include_files and
max_include_len. Make some members bool.
(_cpp_mark_only_only): Renamed from _cpp_never_reread.
(_cpp_stack_file): Renamed from _cpp_read_file.
(_cpp_stack_include): Renamed from _cpp_execute_include.
(_cpp_init_files): Renamed from _cpp_init_includes.
(_cpp_cleanup_files): Renamed from _cpp_cleanup_includes.
* cppinit.c (cpp_create_reader): Initialize no_search_path. Update.
(cpp_read_next_file): Rename and move to cppfiles.c.
(cpp_read_main_file): Update.
* cpplib.c (run_directive): Update for renamed members.
(do_include_common, _cpp_pop_buffer): Update.
(do_import): Undeprecate #import.
(do_pragma_once): Undeprecate. Use _cpp_mark_file_once_only.
* cpplib.h: Remove file_name_map_list.
(cpp_options): Remove map_list.
(cpp_dir): Rename from cpp_path. New datatype for name_map.
(cpp_set_include_chains, cpp_stack_file, cpp_included): Update.
2003-07-29 Phil Edwards <pme@gcc.gnu.org>
* Makefile.in: Make stamp-objdir safe for parallel builds.
......
......@@ -2348,7 +2348,7 @@ LIBCPP_OBJS = cpplib.o cpplex.o cppmacro.o cppexp.o cppfiles.o cpptrad.o \
hashtable.o line-map.o mkdeps.o cpppch.o
LIBCPP_DEPS = $(CPPLIB_H) cpphash.h line-map.h hashtable.h intl.h \
$(OBSTACK_H) $(CONFIG_H) $(SYSTEM_H)
$(HASHTAB_H) $(OBSTACK_H) $(CONFIG_H) $(SYSTEM_H)
# Most of the other archives built/used by this makefile are for
# targets. This one is strictly for the host.
......
......@@ -45,21 +45,21 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
static void add_env_var_paths (const char *, int);
static void add_standard_paths (const char *, const char *, int);
static void free_path (struct cpp_path *, int);
static void free_path (struct cpp_dir *, int);
static void merge_include_chains (cpp_reader *, int);
static struct cpp_path *remove_duplicates (cpp_reader *, struct cpp_path *,
struct cpp_path *,
struct cpp_path *, int);
static struct cpp_dir *remove_duplicates (cpp_reader *, struct cpp_dir *,
struct cpp_dir *,
struct cpp_dir *, int);
/* Include chains heads and tails. */
static struct cpp_path *heads[4];
static struct cpp_path *tails[4];
static struct cpp_dir *heads[4];
static struct cpp_dir *tails[4];
static bool quote_ignores_source_dir;
enum { REASON_QUIET = 0, REASON_NOENT, REASON_DUP, REASON_DUP_SYS };
/* Free an element of the include chain, possibly giving a reason. */
static void
free_path (struct cpp_path *path, int reason)
free_path (struct cpp_dir *path, int reason)
{
switch (reason)
{
......@@ -169,12 +169,12 @@ add_standard_paths (const char *sysroot, const char *iprefix, int cxx_stdinc)
JOIN, unless it duplicates JOIN in which case the last path is
removed. Return the head of the resulting chain. Any of HEAD,
JOIN and SYSTEM can be NULL. */
static struct cpp_path *
remove_duplicates (cpp_reader *pfile, struct cpp_path *head,
struct cpp_path *system, struct cpp_path *join,
static struct cpp_dir *
remove_duplicates (cpp_reader *pfile, struct cpp_dir *head,
struct cpp_dir *system, struct cpp_dir *join,
int verbose)
{
struct cpp_path **pcur, *tmp, *cur;
struct cpp_dir **pcur, *tmp, *cur;
struct stat st;
for (pcur = &head; *pcur; )
......@@ -182,7 +182,6 @@ remove_duplicates (cpp_reader *pfile, struct cpp_path *head,
int reason = REASON_QUIET;
cur = *pcur;
cpp_simplify_path (cur->name);
if (stat (cur->name, &st))
{
......@@ -269,7 +268,7 @@ merge_include_chains (cpp_reader *pfile, int verbose)
/* If verbose, print the list of dirs to search. */
if (verbose)
{
struct cpp_path *p;
struct cpp_dir *p;
fprintf (stderr, _("#include \"...\" search starts here:\n"));
for (p = heads[QUOTE];; p = p->next)
......@@ -304,9 +303,9 @@ split_quote_chain (void)
void
add_path (char *path, int chain, int cxx_aware)
{
struct cpp_path *p;
struct cpp_dir *p;
p = xmalloc (sizeof (struct cpp_path));
p = xmalloc (sizeof (struct cpp_dir));
p->next = NULL;
p->name = path;
if (chain == SYSTEM || chain == AFTER)
......
......@@ -1206,7 +1206,7 @@ c_common_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
/* Reset cpplib's macros and start a new file. */
cpp_undef_all (parse_in);
cpp_read_next_file (parse_in, in_fnames[file_index]);
cpp_stack_file (parse_in, in_fnames[file_index]);
}
finish_options(in_fnames[file_index]);
......
......@@ -24,6 +24,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#define GCC_CPPHASH_H
#include "hashtable.h"
#include "hashtab.h"
#ifdef HAVE_ICONV
#include <iconv.h>
......@@ -36,6 +37,7 @@ struct directive; /* Deliberately incomplete. */
struct pending_option;
struct op;
struct strbuf;
struct _cpp_file;
typedef bool (*convert_f) (iconv_t, const unsigned char *, size_t,
struct strbuf *);
......@@ -281,9 +283,9 @@ struct cpp_buffer
struct cpp_buffer *prev;
/* Pointer into the include table; non-NULL if this is a file
buffer. Used for include_next and to record control macros. */
struct include_file *inc;
/* Pointer into the file table; non-NULL if this is a file buffer.
Used for include_next and to record control macros. */
struct _cpp_file *file;
/* Value of if_stack at start of this file.
Used to prohibit unmatched #endif (etc) in an include file. */
......@@ -314,7 +316,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 cpp_path dir;
struct cpp_dir dir;
/* Used for buffer overlays by cpptrad.c. */
const uchar *saved_cur, *saved_rlimit;
......@@ -355,8 +357,24 @@ struct cpp_reader
const struct directive *directive;
/* Search paths for include files. */
struct cpp_path *quote_include; /* "" */
struct cpp_path *bracket_include; /* <> */
struct cpp_dir *quote_include; /* "" */
struct cpp_dir *bracket_include; /* <> */
struct cpp_dir no_search_path; /* No path. */
/* Chain of files that were #import-ed or contain #pragma once. */
struct _cpp_file *once_only_files;
/* File and directory hash table. */
htab_t file_hash;
struct file_hash_entry *file_hash_entries;
unsigned int file_hash_entries_allocated, file_hash_entries_used;
/* Nonzero means don't look for #include "foo" the source-file
directory. */
bool quote_ignores_source_dir;
/* Non-zero if any file has contained #pragma once. */
bool saw_pragma_once;
/* Multiple include optimization. */
const cpp_hashnode *mi_cmacro;
......@@ -386,13 +404,6 @@ struct cpp_reader
wide execution character set. */
struct cset_converter wide_cset_desc;
/* Tree of other included files. See cppfiles.c. */
struct splay_tree_s *all_include_files;
/* Current maximum length of directory names in the search path
for include files. (Altered as we get more of them.) */
unsigned int max_include_len;
/* Date and time text. Calculated together if either is requested. */
const uchar *date;
const uchar *time;
......@@ -432,12 +443,8 @@ struct cpp_reader
preprocessor. */
struct spec_nodes spec_nodes;
/* 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;
bool our_hashtable;
/* Traditional preprocessing output buffer (a logical line). */
struct
......@@ -509,16 +516,16 @@ extern void _cpp_init_hashtable (cpp_reader *, hash_table *);
extern void _cpp_destroy_hashtable (cpp_reader *);
/* In cppfiles.c */
extern void _cpp_mark_file_once_only (cpp_reader *, struct _cpp_file *, bool);
extern void _cpp_fake_include (cpp_reader *, const char *);
extern void _cpp_never_reread (struct include_file *);
extern bool _cpp_read_file (cpp_reader *, const char *);
extern bool _cpp_execute_include (cpp_reader *, const char *, int,
enum include_type);
extern bool _cpp_stack_file (cpp_reader *, const char *);
extern bool _cpp_stack_include (cpp_reader *, const char *, int,
enum include_type);
extern int _cpp_compare_file_date (cpp_reader *, const char *, int);
extern void _cpp_report_missing_guards (cpp_reader *);
extern void _cpp_init_includes (cpp_reader *);
extern void _cpp_cleanup_includes (cpp_reader *);
extern void _cpp_pop_file_buffer (cpp_reader *, struct include_file *);
extern void _cpp_init_files (cpp_reader *);
extern void _cpp_cleanup_files (cpp_reader *);
extern void _cpp_pop_file_buffer (cpp_reader *, struct _cpp_file *);
/* In cppexp.c */
extern bool _cpp_parse_expr (cpp_reader *);
......
......@@ -161,6 +161,12 @@ cpp_create_reader (enum c_lang lang, hash_table *table)
CPP_OPTION (pfile, narrow_charset) = 0;
CPP_OPTION (pfile, wide_charset) = 0;
/* A fake empty "directory" used as the starting point for files
looked up without a search path. Name cannot be '/' because we
don't want to prepend anything at all to filenames using it. All
other entries are correct zero-initialized. */
pfile->no_search_path.name = (char *) "";
/* Initialize the line map. Start at logical line 1, so we can use
a line number of zero for special states. */
linemap_init (&pfile->line_maps);
......@@ -196,7 +202,7 @@ cpp_create_reader (enum c_lang lang, hash_table *table)
(void *(*) (long)) xmalloc,
(void (*) (void *)) free);
_cpp_init_includes (pfile);
_cpp_init_files (pfile);
_cpp_init_hashtable (pfile, table);
......@@ -231,7 +237,7 @@ cpp_destroy (cpp_reader *pfile)
obstack_free (&pfile->buffer_ob, 0);
_cpp_destroy_hashtable (pfile);
_cpp_cleanup_includes (pfile);
_cpp_cleanup_files (pfile);
_cpp_destroy_iconv (pfile);
_cpp_free_buff (pfile->a_buff);
......@@ -427,15 +433,6 @@ cpp_add_dependency_target (cpp_reader *pfile, const char *target, int quote)
deps_add_target (pfile->deps, target, quote);
}
/* This sets up for processing input from the file FNAME.
It returns false on error. */
bool
cpp_read_next_file (cpp_reader *pfile, const char *fname)
{
/* Open the main input file. */
return _cpp_read_file (pfile, fname);
}
/* This is called after options have been parsed, and partially
processed. Setup for processing input from the file named FNAME,
or stdin if it is the empty string. Return the original filename
......@@ -461,7 +458,7 @@ cpp_read_main_file (cpp_reader *pfile, const char *fname)
}
pfile->line = 1;
if (!cpp_read_next_file (pfile, fname))
if (!cpp_stack_file (pfile, fname))
return NULL;
/* Set this here so the client can change the option if it wishes,
......
......@@ -441,7 +441,7 @@ run_directive (cpp_reader *pfile, int dir_no, const char *buf, size_t count)
/* from_stage3 */ true, 1);
/* Disgusting hack. */
if (dir_no == T_PRAGMA)
pfile->buffer->inc = pfile->buffer->prev->inc;
pfile->buffer->file = pfile->buffer->prev->file;
start_directive (pfile);
/* This is a short-term fix to prevent a leading '#' being
......@@ -454,7 +454,7 @@ run_directive (cpp_reader *pfile, int dir_no, const char *buf, size_t count)
pfile->directive->handler (pfile);
end_directive (pfile, 1);
if (dir_no == T_PRAGMA)
pfile->buffer->inc = NULL;
pfile->buffer->file = NULL;
_cpp_pop_buffer (pfile);
}
......@@ -684,7 +684,7 @@ do_include_common (cpp_reader *pfile, enum include_type type)
pfile->cb.include (pfile, pfile->directive_line,
pfile->directive->name, fname, angle_brackets);
_cpp_execute_include (pfile, fname, angle_brackets, type);
_cpp_stack_include (pfile, fname, angle_brackets, type);
}
free ((void *) fname);
......@@ -699,13 +699,6 @@ do_include (cpp_reader *pfile)
static void
do_import (cpp_reader *pfile)
{
if (CPP_OPTION (pfile, warn_import))
{
CPP_OPTION (pfile, warn_import) = 0;
cpp_error (pfile, DL_WARNING,
"#import is obsolete, use an #ifndef wrapper in the header file");
}
do_include_common (pfile, IT_IMPORT);
}
......@@ -1170,15 +1163,11 @@ do_pragma (cpp_reader *pfile)
static void
do_pragma_once (cpp_reader *pfile)
{
if (CPP_OPTION (pfile, warn_deprecated))
cpp_error (pfile, DL_WARNING, "#pragma once is obsolete");
if (pfile->buffer->prev == NULL)
cpp_error (pfile, DL_WARNING, "#pragma once in main file");
else
_cpp_never_reread (pfile->buffer->inc);
check_eol (pfile);
_cpp_mark_file_once_only (pfile, pfile->buffer->file, false);
}
/* Handle #pragma GCC poison, to poison one or more identifiers so
......@@ -1944,7 +1933,7 @@ void
_cpp_pop_buffer (cpp_reader *pfile)
{
cpp_buffer *buffer = pfile->buffer;
struct include_file *inc = buffer->inc;
struct _cpp_file *inc = buffer->file;
struct if_stack *ifs;
/* Walk back up the conditional stack till we reach its level at
......
......@@ -39,10 +39,9 @@ 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;
typedef struct cpp_dir cpp_dir;
struct answer;
struct file_name_map_list;
/* The first three groups, apart from '=', can appear in preprocessor
expressions (+= and -= are used to indicate unary + and - resp.).
......@@ -214,10 +213,6 @@ struct cpp_options
/* Characters between tab stops. */
unsigned int tabstop;
/* 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;
/* The language we're preprocessing. */
enum c_lang lang;
......@@ -397,12 +392,12 @@ struct cpp_callbacks
};
/* Chain of directories to look for include files in. */
struct cpp_path
struct cpp_dir
{
/* NULL-terminated singly-linked list. */
struct cpp_path *next;
struct cpp_dir *next;
/* NAME need not be NUL-terminated once inside cpplib. */
/* NAME of the directory, NUL-terminated. */
char *name;
unsigned int len;
......@@ -410,9 +405,9 @@ struct cpp_path
"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;
/* Mapping of file names for this directory for MS-DOS and related
platforms. A NULL-terminated array of (from, to) pairs. */
const char **name_map;
/* The C front end uses these to recognize duplicated
directories in the search path. */
......@@ -516,7 +511,7 @@ extern void cpp_set_lang (cpp_reader *, enum c_lang);
extern void cpp_add_dependency_target (cpp_reader *, const char *, int);
/* Set the include paths. */
extern void cpp_set_include_chains (cpp_reader *, cpp_path *, cpp_path *, int);
extern void cpp_set_include_chains (cpp_reader *, cpp_dir *, cpp_dir *, int);
/* Call these to get pointers to the options and callback structures
for a given reader. These pointers are good until you call
......@@ -535,9 +530,9 @@ extern void cpp_set_callbacks (cpp_reader *, cpp_callbacks *);
too. If there was an error opening the file, it returns NULL. */
extern const char *cpp_read_main_file (cpp_reader *, const char *);
/* This continues processing to a new file. It will return false if
there was an error opening the file. */
extern bool cpp_read_next_file (cpp_reader *, const char *);
/* Stacks a new file. It will return false if there was an error
opening the file. */
extern bool cpp_stack_file (cpp_reader *, const char *);
/* Set up built-ins like __FILE__. */
extern void cpp_init_builtins (cpp_reader *, int);
......@@ -715,7 +710,7 @@ extern unsigned char *cpp_quote_string (unsigned char *, const unsigned char *,
unsigned int);
/* In cppfiles.c */
extern int cpp_included (cpp_reader *, const char *);
extern bool cpp_included (cpp_reader *, const char *);
extern void cpp_make_system_header (cpp_reader *, int, int);
extern void cpp_simplify_path (char *);
extern bool cpp_push_include (cpp_reader *, const char *);
......
2003-07-29 Neil Booth <neil@daikokuya.co.uk>
* gcc.dg/cpp/include2.c: Only expect one message.
2003-07-29 Nathan Sidwell <nathan@codesourcery.com>
PR c++/9447
......
......@@ -10,7 +10,7 @@
#include <silly\>> /* { dg-warning "extra tokens" "" } */
#include "silly\"" /* { dg-warning "extra tokens" "" } */
/* These first 2 errors are No such file or directory. However, this
/* These error is No such file or directory, just once. However, this
message is locale-dependent, so don't test for it. */
/* { dg-error "silly" "" { target *-*-* } 10 } */
/* { dg-error "silly" "" { target *-*-* } 11 } */
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