aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Booth <neil@daikokuya.demon.co.uk>2001-01-13 18:39:26 +0000
committerNeil Booth <neil@gcc.gnu.org>2001-01-13 18:39:26 +0000
commitd6d52dd655506899ea8ddbb5a18c0df16a45f3f9 (patch)
tree842229d5e9effcad193597ab41fcfb2eb4a902bc
parentccd96f0ad82a526127150a8d254fbf70f3c93030 (diff)
downloadgcc-d6d52dd655506899ea8ddbb5a18c0df16a45f3f9.zip
gcc-d6d52dd655506899ea8ddbb5a18c0df16a45f3f9.tar.gz
gcc-d6d52dd655506899ea8ddbb5a18c0df16a45f3f9.tar.bz2
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
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/cppfiles.c23
-rw-r--r--gcc/cpphash.h3
-rw-r--r--gcc/cpplib.c6
-rw-r--r--gcc/cppmain.c49
5 files changed, 40 insertions, 50 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6f3787d..91d328a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,14 @@
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.
2001-01-13 Andreas Jaeger <aj@suse.de>
diff --git a/gcc/cppfiles.c b/gcc/cppfiles.c
index 91f886b..c480cb4 100644
--- a/gcc/cppfiles.c
+++ b/gcc/cppfiles.c
@@ -1,6 +1,6 @@
/* Part of CPP library. (include file handling)
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.
Based on CCCP program by Paul Rubin, June 1986
Adapted to ANSI C, Richard Stallman, Jan 1987
@@ -117,6 +117,7 @@ destroy_include_file_node (v)
splay_tree_value v;
{
struct include_file *f = (struct include_file *)v;
+
if (f)
{
purge_cache (f);
@@ -149,6 +150,26 @@ _cpp_never_reread (file)
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,
create one with a non-NULL value (regardless of success in opening
the file). If the file doesn't exist or is inaccessible, this
diff --git a/gcc/cpphash.h b/gcc/cpphash.h
index af60ba4..380f125 100644
--- a/gcc/cpphash.h
+++ b/gcc/cpphash.h
@@ -1,5 +1,5 @@
/* 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
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,
unsigned int));
/* 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_simplify_pathname PARAMS ((char *));
extern int _cpp_read_file PARAMS ((cpp_reader *, const char *));
diff --git a/gcc/cpplib.c b/gcc/cpplib.c
index 2064120..78045e3 100644
--- a/gcc/cpplib.c
+++ b/gcc/cpplib.c
@@ -1,6 +1,6 @@
/* CPP Library. (Directive handling.)
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.
Based on CCCP program by Paul Rubin, June 1986
Adapted to ANSI C, Richard Stallman, Jan 1987
@@ -716,6 +716,7 @@ do_line (pfile)
_cpp_simplify_pathname (fname);
+ /* Only accept flags for the # 55 form. */
if (! pfile->state.line_extension)
check_eol (pfile);
else
@@ -743,7 +744,10 @@ do_line (pfile)
if (reason == FC_ENTER)
{
+ /* Fake a buffer stack for diagnostics. */
cpp_push_buffer (pfile, 0, 0, BUF_FAKE, fname);
+ /* Fake an include for cpp_included. */
+ _cpp_fake_include (pfile, fname);
buffer = pfile->buffer;
}
else if (reason == FC_LEAVE)
diff --git a/gcc/cppmain.c b/gcc/cppmain.c
index a7e7ea2..d575f9f 100644
--- a/gcc/cppmain.c
+++ b/gcc/cppmain.c
@@ -1,5 +1,6 @@
/* 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.
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 *,
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_def_pragma PARAMS ((cpp_reader *));
-static void do_pragma_implementation PARAMS ((cpp_reader *));
const char *progname; /* Needs to be global. */
static cpp_reader *pfile; /* An opaque handle. */
@@ -177,10 +177,6 @@ setup_callbacks ()
cb->undef = cb_undef;
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,
@@ -419,47 +415,6 @@ cb_def_pragma (pfile)
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. */
static int
dump_macro (pfile, node, v)