summaryrefslogtreecommitdiff
path: root/gcc/c-opts.c
diff options
context:
space:
mode:
authoraoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4>2003-08-05 21:15:57 +0000
committeraoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4>2003-08-05 21:15:57 +0000
commite7aa92b2a1d420c944ff0c2e0ed5f0240638fa39 (patch)
treeb7f8db5c8aee0a49ffa5b4f9b148561a8a68a233 /gcc/c-opts.c
parent52fa96d362090ae55361c6c2f18a284ffa384927 (diff)
downloadgcc-e7aa92b2a1d420c944ff0c2e0ed5f0240638fa39.tar.gz
* c.opt: Introduce -fworking-directory.
* doc/cpp.texi, doc/invoke.texi, doc/cppopts.texi: Document it. * c-common.h (flag_working_directory): Declare. * c-common.c (flag_working_directory): Define. * c-opts.c (c_common_handle_options): Set it. (sanitize_cpp_opts): Set... * cpplib.h (struct cpp_options): ... working_directory option. (struct cpp_callbacks): Add dir_change. * cppinit.c (read_original_filename): Call... (read_original_directory): New. Look for # 1 "directory//" and process it. (cpp_read_main_file): Call dir_change callback if working_directory option is set. * gcc.c (cpp_unique_options): Pass -g*. * c-lex.c (cb_dir_change): New. (init_c_lex): Set dir_change callback. * toplev.c (src_pwd): New static variable. (set_src_pwd, get_src_pwd): New functions. * toplev.h (get_src_pwd, set_src_pwd): Declare. * dbxout.c (dbxout_init): Call get_src_pwd() instead of getpwd(). * dwarf2out.c (gen_compile_unit_die): Likewise. * dwarfout.c (output_compile_unit_die, dwarfout_init): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@70189 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-opts.c')
-rw-r--r--gcc/c-opts.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/gcc/c-opts.c b/gcc/c-opts.c
index 012f24ba53a..e2a30430997 100644
--- a/gcc/c-opts.c
+++ b/gcc/c-opts.c
@@ -235,7 +235,7 @@ c_common_init_options (unsigned int argc, const char **argv ATTRIBUTE_UNUSED)
return result;
}
-/* Handle switch SCODE with argument ARG. ON is true, unless no-
+/* Handle switch SCODE with argument ARG. VALUE is true, unless no-
form of an -f or -W option was given. Returns 0 if the switch was
invalid, a negative number to prevent language-independent
processing in toplev.c (a hack necessary for the short-term). */
@@ -335,6 +335,10 @@ c_common_handle_option (size_t scode, const char *arg, int value)
flag_no_line_commands = 1;
break;
+ case OPT_fworking_directory:
+ flag_working_directory = value;
+ break;
+
case OPT_U:
defer_opt (code, arg);
break;
@@ -1329,6 +1333,15 @@ sanitize_cpp_opts (void)
and/or -Wtraditional, whatever the ordering. */
cpp_opts->warn_long_long
= warn_long_long && ((!flag_isoc99 && pedantic) || warn_traditional);
+
+ /* If we're generating preprocessor output, emit current directory
+ if explicitly requested or if debugging information is enabled.
+ ??? Maybe we should only do it for debugging formats that
+ actually output the current directory? */
+ if (flag_working_directory == -1)
+ flag_working_directory = (debug_info_level != DINFO_LEVEL_NONE);
+ cpp_opts->working_directory
+ = flag_preprocess_only && flag_working_directory;
}
/* Add include path with a prefix at the front of its name. */