cppfiles.c (_cpp_fake_include): New function.
authorNeil Booth <neil@daikokuya.demon.co.uk>
Sat, 13 Jan 2001 18:39:26 +0000 (18:39 +0000)
committerNeil Booth <neil@gcc.gnu.org>
Sat, 13 Jan 2001 18:39:26 +0000 (18:39 +0000)
        * 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

gcc/ChangeLog
gcc/cppfiles.c
gcc/cpphash.h
gcc/cpplib.c
gcc/cppmain.c

index 6f3787dcef6dcbfd3ced577eb58285e72a0361cb..91d328aef1e62d11f6bfa635d33280722203a45f 100644 (file)
@@ -1,3 +1,12 @@
+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.
index 91f886b8f798dab7654e74ced5a48e088a7593c0..c480cb456c034ff1bbdce4c013cdb9aecb6c169f 100644 (file)
@@ -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
index af60ba43e75b170c1b83bb55b606c00d31e18dda..380f12581e6760963adb2bf2f41c6af5a2f32f4d 100644 (file)
@@ -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 *));
index 20641200ec9b8d38f92cb058048ef5d36f5c9fbb..78045e31fc33de398e141857c90024c93ed8a7d1 100644 (file)
@@ -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)
index a7e7ea2c42e2af6699578429e339136551181228..d575f9fba51e96249576f4b2e35c532eda6f11d2 100644 (file)
@@ -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)