Commit d6d52dd6 by Neil Booth Committed by Neil Booth

cppfiles.c (_cpp_fake_include): New function.

        * cppfiles.c (_cpp_fake_include): New function.
        * cpphash.h (_cpp_fake_include): New.
        * cpplib.c (do_line): Call _cpp_fake_include when entering
        header files in preprocessed input.
        * cppmain.c (cb_pragma_implementation): Remove handling.
	(setup_callbacks): Don't register pragmas.

From-SVN: r38987
parent ccd96f0a
2001-01-13 Neil Booth <neil@daikokuya.demon.co.uk> 2001-01-13 Neil Booth <neil@daikokuya.demon.co.uk>
* cppfiles.c (_cpp_fake_include): New function.
* cpphash.h (_cpp_fake_include): New.
* cpplib.c (do_line): Call _cpp_fake_include when entering
header files in preprocessed input.
* cppmain.c (cb_pragma_implementation): Remove handling.
(setup_callbacks): Don't register pragmas.
2001-01-13 Neil Booth <neil@daikokuya.demon.co.uk>
* extend.texi: Udate for CPP. * extend.texi: Udate for CPP.
2001-01-13 Andreas Jaeger <aj@suse.de> 2001-01-13 Andreas Jaeger <aj@suse.de>
......
/* Part of CPP library. (include file handling) /* Part of CPP library. (include file handling)
Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1998, Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1998,
1999, 2000 Free Software Foundation, Inc. 1999, 2000, 2001 Free Software Foundation, Inc.
Written by Per Bothner, 1994. Written by Per Bothner, 1994.
Based on CCCP program by Paul Rubin, June 1986 Based on CCCP program by Paul Rubin, June 1986
Adapted to ANSI C, Richard Stallman, Jan 1987 Adapted to ANSI C, Richard Stallman, Jan 1987
...@@ -117,6 +117,7 @@ destroy_include_file_node (v) ...@@ -117,6 +117,7 @@ destroy_include_file_node (v)
splay_tree_value v; splay_tree_value v;
{ {
struct include_file *f = (struct include_file *)v; struct include_file *f = (struct include_file *)v;
if (f) if (f)
{ {
purge_cache (f); purge_cache (f);
...@@ -149,6 +150,26 @@ _cpp_never_reread (file) ...@@ -149,6 +150,26 @@ _cpp_never_reread (file)
file->cmacro = NEVER_REREAD; file->cmacro = NEVER_REREAD;
} }
/* Put a file name in the splay tree, for the sake of cpp_included ().
Assume that FNAME has already had its path simplified. */
void
_cpp_fake_include (pfile, fname)
cpp_reader *pfile;
const char *fname;
{
splay_tree_node nd;
nd = splay_tree_lookup (pfile->all_include_files, (splay_tree_key) fname);
if (! nd)
{
struct include_file *file = xcnew (struct include_file);
file->name = xstrdup (fname);
splay_tree_insert (pfile->all_include_files,
(splay_tree_key) file->name,
(splay_tree_value) file);
}
}
/* Given a file name, look it up in the cache; if there is no entry, /* Given a file name, look it up in the cache; if there is no entry,
create one with a non-NULL value (regardless of success in opening create one with a non-NULL value (regardless of success in opening
the file). If the file doesn't exist or is inaccessible, this the file). If the file doesn't exist or is inaccessible, this
......
/* Part of CPP library. /* Part of CPP library.
Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it 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 under the terms of the GNU General Public License as published by the
...@@ -400,6 +400,7 @@ extern cpp_hashnode *_cpp_lookup_with_hash PARAMS ((cpp_reader*, size_t, ...@@ -400,6 +400,7 @@ extern cpp_hashnode *_cpp_lookup_with_hash PARAMS ((cpp_reader*, size_t,
unsigned int)); unsigned int));
/* In cppfiles.c */ /* In cppfiles.c */
extern void _cpp_fake_include PARAMS ((cpp_reader *, const char *));
extern void _cpp_never_reread PARAMS ((struct include_file *)); extern void _cpp_never_reread PARAMS ((struct include_file *));
extern void _cpp_simplify_pathname PARAMS ((char *)); extern void _cpp_simplify_pathname PARAMS ((char *));
extern int _cpp_read_file PARAMS ((cpp_reader *, const char *)); extern int _cpp_read_file PARAMS ((cpp_reader *, const char *));
......
/* CPP Library. (Directive handling.) /* CPP Library. (Directive handling.)
Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
1999, 2000 Free Software Foundation, Inc. 1999, 2000, 2001 Free Software Foundation, Inc.
Contributed by Per Bothner, 1994-95. Contributed by Per Bothner, 1994-95.
Based on CCCP program by Paul Rubin, June 1986 Based on CCCP program by Paul Rubin, June 1986
Adapted to ANSI C, Richard Stallman, Jan 1987 Adapted to ANSI C, Richard Stallman, Jan 1987
...@@ -716,6 +716,7 @@ do_line (pfile) ...@@ -716,6 +716,7 @@ do_line (pfile)
_cpp_simplify_pathname (fname); _cpp_simplify_pathname (fname);
/* Only accept flags for the # 55 form. */
if (! pfile->state.line_extension) if (! pfile->state.line_extension)
check_eol (pfile); check_eol (pfile);
else else
...@@ -743,7 +744,10 @@ do_line (pfile) ...@@ -743,7 +744,10 @@ do_line (pfile)
if (reason == FC_ENTER) if (reason == FC_ENTER)
{ {
/* Fake a buffer stack for diagnostics. */
cpp_push_buffer (pfile, 0, 0, BUF_FAKE, fname); cpp_push_buffer (pfile, 0, 0, BUF_FAKE, fname);
/* Fake an include for cpp_included. */
_cpp_fake_include (pfile, fname);
buffer = pfile->buffer; buffer = pfile->buffer;
} }
else if (reason == FC_LEAVE) else if (reason == FC_LEAVE)
......
/* CPP main program, using CPP Library. /* CPP main program, using CPP Library.
Copyright (C) 1995, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. Copyright (C) 1995, 1997, 1998, 1999, 2000, 2001
Free Software Foundation, Inc.
Written by Per Bothner, 1994-95. Written by Per Bothner, 1994-95.
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
...@@ -58,7 +59,6 @@ static void cb_include PARAMS ((cpp_reader *, const unsigned char *, ...@@ -58,7 +59,6 @@ static void cb_include PARAMS ((cpp_reader *, const unsigned char *,
static void cb_ident PARAMS ((cpp_reader *, const cpp_string *)); static void cb_ident PARAMS ((cpp_reader *, const cpp_string *));
static void cb_file_change PARAMS ((cpp_reader *, const cpp_file_change *)); static void cb_file_change PARAMS ((cpp_reader *, const cpp_file_change *));
static void cb_def_pragma PARAMS ((cpp_reader *)); static void cb_def_pragma PARAMS ((cpp_reader *));
static void do_pragma_implementation PARAMS ((cpp_reader *));
const char *progname; /* Needs to be global. */ const char *progname; /* Needs to be global. */
static cpp_reader *pfile; /* An opaque handle. */ static cpp_reader *pfile; /* An opaque handle. */
...@@ -177,10 +177,6 @@ setup_callbacks () ...@@ -177,10 +177,6 @@ setup_callbacks ()
cb->undef = cb_undef; cb->undef = cb_undef;
cb->poison = cb_def_pragma; cb->poison = cb_def_pragma;
} }
/* Register one #pragma which needs special handling. */
cpp_register_pragma(pfile, 0, "implementation", do_pragma_implementation);
cpp_register_pragma(pfile, "GCC", "implementation", do_pragma_implementation);
} }
/* Writes out the preprocessed file. Alternates between two tokens, /* Writes out the preprocessed file. Alternates between two tokens,
...@@ -419,47 +415,6 @@ cb_def_pragma (pfile) ...@@ -419,47 +415,6 @@ cb_def_pragma (pfile)
print.lineno++; print.lineno++;
} }
static void
do_pragma_implementation (pfile)
cpp_reader *pfile;
{
/* Be quiet about `#pragma implementation' for a file only if it hasn't
been included yet. */
cpp_token token;
cpp_start_lookahead (pfile);
cpp_get_token (pfile, &token);
cpp_stop_lookahead (pfile, 0);
/* If it's not a string, pass it through and let the front end complain. */
if (token.type == CPP_STRING)
{
/* Make a NUL-terminated copy of the string. */
char *filename = alloca (token.val.str.len + 1);
memcpy (filename, token.val.str.text, token.val.str.len);
filename[token.val.str.len] = '\0';
if (cpp_included (pfile, filename))
cpp_warning (pfile,
"#pragma GCC implementation for \"%s\" appears after file is included",
filename);
}
else if (token.type != CPP_EOF)
{
cpp_error (pfile, "malformed #pragma GCC implementation");
return;
}
/* Output? This is nasty, but we don't have [GCC] implementation in
the buffer. */
if (cb->def_pragma)
{
maybe_print_line (cpp_get_line (pfile)->output_line);
fputs ("#pragma GCC implementation ", print.outf);
cpp_output_line (pfile, print.outf);
print.lineno++;
}
}
/* Dump out the hash table. */ /* Dump out the hash table. */
static int static int
dump_macro (pfile, node, v) dump_macro (pfile, node, v)
......
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