OSDN Git Service

* cppfiles.c (cpp_rename_file, cpp_push_include): New.
authorneil <neil@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 12 Mar 2003 21:31:51 +0000 (21:31 +0000)
committerneil <neil@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 12 Mar 2003 21:31:51 +0000 (21:31 +0000)
* cppinit.c (push_include): Move with changes to cppfiles.c.
(cpp_read_main_file): Mark named operators here...
(cpp_finish_options): ...not here.  Update.
(_cpp_maybe_push_include_file): Update.
* cpplib.h (cpp_push_include, cpp_rename_file): New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@64266 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/cppfiles.c
gcc/cppinit.c
gcc/cpplib.h

index 6d4f5d1..f970d7b 100644 (file)
@@ -1,3 +1,12 @@
+2003-03-12  Neil Booth  <neil@daikokuya.co.uk>
+
+       * cppfiles.c (cpp_rename_file, cpp_push_include): New.
+       * cppinit.c (push_include): Move with changes to cppfiles.c.
+       (cpp_read_main_file): Mark named operators here...
+       (cpp_finish_options): ...not here.  Update.
+       (_cpp_maybe_push_include_file): Update.
+       * cpplib.h (cpp_push_include, cpp_rename_file): New.
+
 2003-03-12  Nathanael Nerode  <neroden@gcc.gnu.org>
 
         * aclocal.m4: Introduce gcc_GAS_VERSION_GTE_IFELSE,
index 9e35d0f..9bcdb9e 100644 (file)
@@ -756,6 +756,16 @@ cpp_make_system_header (pfile, syshdr, externc)
                       SOURCE_LINE (pfile->map, pfile->line), flags);
 }
 
+/* Allow the client to rename the current file.  Used by the front end
+   to achieve pseudo-file names like <built-in>.  */
+void
+cpp_rename_file (pfile, new_name)
+     cpp_reader *pfile;
+     const char *new_name;
+{
+  _cpp_do_file_change (pfile, LC_RENAME, new_name, 1, 0);
+}
+
 /* Report on all files that might benefit from a multiple include guard.
    Triggered by -H.  */
 void
@@ -884,6 +894,24 @@ _cpp_read_file (pfile, fname)
   return stack_include_file (pfile, f);
 }
 
+/* Pushes the given file onto the buffer stack.  Returns nonzero if
+   successful.  */
+bool
+cpp_push_include (pfile, filename)
+     cpp_reader *pfile;
+     const char *filename;
+{
+  cpp_token header;
+
+  header.type = CPP_STRING;
+  header.val.str.text = (const unsigned char *) filename;
+  header.val.str.len = strlen (filename);
+  /* Make the command line directive take up a line.  */
+  pfile->line++;
+
+  return _cpp_execute_include (pfile, &header, IT_CMDLINE);
+}
+
 /* Do appropriate cleanup when a file INC's buffer is popped off the
    input stack.  */
 void
index 5cbd87f..8982474 100644 (file)
@@ -68,8 +68,6 @@ struct cpp_pending
 static void init_library               PARAMS ((void));
 static void init_builtins              PARAMS ((cpp_reader *));
 static void mark_named_operators       PARAMS ((cpp_reader *));
-static bool push_include               PARAMS ((cpp_reader *,
-                                                struct pending_option *));
 static void free_chain                 PARAMS ((struct pending_option *));
 static void read_original_filename     PARAMS ((cpp_reader *));
 static void new_pending_directive      PARAMS ((struct cpp_pending *,
@@ -432,26 +430,6 @@ init_builtins (pfile)
     (*pfile->cb.register_builtins) (pfile);
 }
 
-/* Pushes a command line -imacro and -include file indicated by P onto
-   the buffer stack.  Returns nonzero if successful.  */
-static bool
-push_include (pfile, p)
-     cpp_reader *pfile;
-     struct pending_option *p;
-{
-  cpp_token header;
-
-  /* Later: maybe update this to use the #include "" search path
-     if cpp_read_file fails.  */
-  header.type = CPP_STRING;
-  header.val.str.text = (const unsigned char *) p->arg;
-  header.val.str.len = strlen (p->arg);
-  /* Make the command line directive take up a line.  */
-  pfile->line++;
-
-  return _cpp_execute_include (pfile, &header, IT_CMDLINE);
-}
-
 /* Frees a pending_option chain.  */
 static void
 free_chain (head)
@@ -552,6 +530,10 @@ cpp_read_main_file (pfile, fname, table)
      hashtable is deferred until now.  */
   _cpp_init_hashtable (pfile, table);
 
+  /* Mark named operators before handling command line macros.  */
+  if (CPP_OPTION (pfile, cplusplus) && CPP_OPTION (pfile, operator_names))
+    mark_named_operators (pfile);
+
   if (CPP_OPTION (pfile, deps.style) != DEPS_NONE)
     {
       if (!pfile->deps)
@@ -615,10 +597,6 @@ void
 cpp_finish_options (pfile)
      cpp_reader *pfile;
 {
-  /* Mark named operators before handling command line macros.  */
-  if (CPP_OPTION (pfile, cplusplus) && CPP_OPTION (pfile, operator_names))
-    mark_named_operators (pfile);
-
   /* Install builtins and process command line macros etc. in the order
      they appeared, but only if not already preprocessed.  */
   if (! CPP_OPTION (pfile, preprocessed))
@@ -637,7 +615,7 @@ cpp_finish_options (pfile)
         pfile->next_include_file is NULL, so _cpp_pop_buffer does not
         push -include files.  */
       for (p = CPP_OPTION (pfile, pending)->imacros_head; p; p = p->next)
-       if (push_include (pfile, p))
+       if (cpp_push_include (pfile, p->arg))
          cpp_scan_nooutput (pfile);
 
       pfile->next_include_file = &CPP_OPTION (pfile, pending)->include_head;
@@ -659,7 +637,7 @@ _cpp_maybe_push_include_file (pfile)
     {
       struct pending_option *head = *pfile->next_include_file;
 
-      while (head && !push_include (pfile, head))
+      while (head && !cpp_push_include (pfile, head->arg))
        head = head->next;
 
       if (head)
index ebb2766..06a219c 100644 (file)
@@ -719,6 +719,8 @@ extern unsigned char *cpp_quote_string      PARAMS ((unsigned char *,
 extern int cpp_included        PARAMS ((cpp_reader *, const char *));
 extern void cpp_make_system_header PARAMS ((cpp_reader *, int, int));
 extern void cpp_simplify_path PARAMS ((char *));
+extern bool cpp_push_include PARAMS ((cpp_reader *, const char *));
+extern void cpp_rename_file PARAMS ((cpp_reader *, const char *));
 
 /* In cpppch.c */
 struct save_macro_data;