From: Neil Booth Date: Wed, 12 Mar 2003 21:31:51 +0000 (+0000) Subject: cppfiles.c (cpp_rename_file, [...]): New. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c19b12cb004dd81035fe2779438612804a27d3a9;p=gcc.git cppfiles.c (cpp_rename_file, [...]): New. * 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. From-SVN: r64266 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6d4f5d1927c..f970d7b997c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2003-03-12 Neil Booth + + * 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 * aclocal.m4: Introduce gcc_GAS_VERSION_GTE_IFELSE, diff --git a/gcc/cppfiles.c b/gcc/cppfiles.c index 9e35d0f4d24..9bcdb9edb5d 100644 --- a/gcc/cppfiles.c +++ b/gcc/cppfiles.c @@ -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 . */ +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 diff --git a/gcc/cppinit.c b/gcc/cppinit.c index 5cbd87feec3..8982474d26e 100644 --- a/gcc/cppinit.c +++ b/gcc/cppinit.c @@ -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) diff --git a/gcc/cpplib.h b/gcc/cpplib.h index ebb27666070..06a219c99e9 100644 --- a/gcc/cpplib.h +++ b/gcc/cpplib.h @@ -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;