getting back the quote_ignores_source_dir behavior of -I-
Daniel Villeneuve
daniel_villeneuve@sympatico.ca
Sun Mar 12 16:34:00 GMT 2006
Zack Weinberg writes:
> On Tue, Mar 07, 2006 at 09:09:30PM -0500, Daniel Villeneuve wrote:
> > I think I've incorporated all the changes that you've
> > mentioned above.
>
> It doesn't look like you got rid of the old definition of
> quote_ignores_source_dir, which I think means this
> shouldn't even compile; and if it does, it certainly
> won't work. Have you tested it yet?
It did compile, because "options.h" was not already
included, but that was clearly an error. I must admit I did
not test these last modifications (shame...).
For the tabs, I did not notice the change, probably caused by
copying and pasting from emacs to my browser.
Another attempt at finalizing this issue, this time tested
with several cases.
2006-03-07 Daniel Villeneuve <daniel_villeneuve@sympatico.ca>
* c.opt (-ignore-source-dir): New option.
* c-opts.c (quote_chain_split): Removed.
(c_common_handle_option): No longer process -I- within OPT_I case.
* c-incpath.h (split_quote_chain): Removed.
* c-incpath.c (split_quote_chain): Removed.
* gcc.c (process_command): Fix side-effect problems of -I- on the
QUOTE list by transforming -I options that occur before -I- into
-iquote. Transform -I- into -ignore-source-dir.
(option_map): add --ignore-source-dir entry.
* testsuite/gcc.dg/cpp/iquote.c: New test.
* testsuite/gcc.dg/cpp/iquote.h: Used along with iquote.c.
* testsuite/gcc.dg/cpp/inc/iquote.h: Used along with iquote.c.
* doc/invoke.texi: Document -ignore-source-dir.
* doc/cpp.texi: Likewise.
* doc/cppopts.texi: Likewise.
--
Daniel Villeneuve
diff -Nrup gcc-4.0.2/NEWS gcc-4.0.2-dv/NEWS
--- gcc-4.0.2/NEWS 2005-09-28 02:18:15.000000000 -0400
+++ gcc-4.0.2-dv/NEWS 2006-02-19 15:17:36.000000000 -0500
@@ -123,8 +123,8 @@ Caveats
differently and doesn't need those work-arounds.
* The graph-coloring register allocator, formerly enabled by the
option -fnew-ra, has been discontinued.
- * -I- has been deprecated. -iquote is meant to replace the need for
- this option.
+ * -I- has been deprecated. -iquote and -ignore-source-dir are meant
+ to replace the need for this option.
* The MIPS -membedded-pic and -mrnames options have been removed.
* All MIPS targets now require the GNU assembler. In particular,
IRIX configurations can no longer use the MIPSpro assemblers,
diff -Nrup gcc-4.0.2/gcc/c-incpath.c gcc-4.0.2-dv/gcc/c-incpath.c
--- gcc-4.0.2/gcc/c-incpath.c 2005-01-23 10:05:27.000000000 -0500
+++ gcc-4.0.2-dv/gcc/c-incpath.c 2006-03-08 17:46:38.000000000 -0500
@@ -28,6 +28,7 @@ Foundation, 59 Temple Place - Suite 330,
#include "prefix.h"
#include "intl.h"
#include "c-incpath.h"
+#include "options.h"
#include "cppdefault.h"
/* Windows does not natively support inodes, and neither does MSDOS.
@@ -56,7 +57,6 @@ static struct cpp_dir *remove_duplicates
/* Include chains heads and tails. */
static struct cpp_dir *heads[4];
static struct cpp_dir *tails[4];
-static bool quote_ignores_source_dir;
enum { REASON_QUIET = 0, REASON_NOENT, REASON_DUP, REASON_DUP_SYS };
/* Free an element of the include chain, possibly giving a reason. */
@@ -296,21 +296,6 @@ merge_include_chains (cpp_reader *pfile,
}
}
-/* Use given -I paths for #include "..." but not #include <...>, and
- don't search the directory of the present file for #include "...".
- (Note that -I. -I- is not the same as the default setup; -I. uses
- the compiler's working dir.) */
-void
-split_quote_chain (void)
-{
- heads[QUOTE] = heads[BRACKET];
- tails[QUOTE] = tails[BRACKET];
- heads[BRACKET] = NULL;
- tails[BRACKET] = NULL;
- /* This is NOT redundant. */
- quote_ignores_source_dir = true;
-}
-
/* Add P to the chain specified by CHAIN. */
void
diff -Nrup gcc-4.0.2/gcc/c-incpath.h gcc-4.0.2-dv/gcc/c-incpath.h
--- gcc-4.0.2/gcc/c-incpath.h 2005-01-23 10:05:28.000000000 -0500
+++ gcc-4.0.2-dv/gcc/c-incpath.h 2006-03-07 18:31:06.000000000 -0500
@@ -15,7 +15,6 @@ You should have received a copy of the G
along with this program; if not, write to the Free Software
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-extern void split_quote_chain (void);
extern void add_path (char *, int, int, bool);
extern void register_include_chains (cpp_reader *, const char *,
const char *, int, int, int);
diff -Nrup gcc-4.0.2/gcc/c-opts.c gcc-4.0.2-dv/gcc/c-opts.c
--- gcc-4.0.2/gcc/c-opts.c 2005-04-30 21:11:56.000000000 -0400
+++ gcc-4.0.2-dv/gcc/c-opts.c 2006-03-07 18:39:58.000000000 -0500
@@ -85,9 +85,6 @@ static bool std_inc = true;
/* Zero disables the C++-specific standard directories for headers. */
static bool std_cxx_inc = true;
-/* If the quote chain has been split by -I-. */
-static bool quote_chain_split;
-
/* If -Wunused-macros. */
static bool warn_unused_macros;
@@ -295,16 +292,7 @@ c_common_handle_option (size_t scode, co
break;
case OPT_I:
- if (strcmp (arg, "-"))
- add_path (xstrdup (arg), BRACKET, 0, true);
- else
- {
- if (quote_chain_split)
- error ("-I- specified twice");
- quote_chain_split = true;
- split_quote_chain ();
- inform ("obsolete option -I- used, please use -iquote instead");
- }
+ add_path (xstrdup (arg), BRACKET, 0, true);
break;
case OPT_M:
diff -Nrup gcc-4.0.2/gcc/c.opt gcc-4.0.2-dv/gcc/c.opt
--- gcc-4.0.2/gcc/c.opt 2005-04-30 21:11:57.000000000 -0400
+++ gcc-4.0.2-dv/gcc/c.opt 2006-03-07 18:30:23.000000000 -0500
@@ -739,6 +739,10 @@ idirafter
C ObjC C++ ObjC++ Joined Separate
-idirafter <dir> Add <dir> to the end of the system include path
+ignore-source-dir
+C ObjC C++ ObjC++ Var(quote_ignores_source_dir)
+Ignore source file's directory when searching for #include \"...\" files
+
imacros
C ObjC C++ ObjC++ Joined Separate
-imacros <file> Accept definition of macros in <file>
diff -Nrup gcc-4.0.2/gcc/doc/cpp.texi gcc-4.0.2-dv/gcc/doc/cpp.texi
--- gcc-4.0.2/gcc/doc/cpp.texi 2005-04-14 13:17:29.000000000 -0400
+++ gcc-4.0.2-dv/gcc/doc/cpp.texi 2006-02-19 15:27:56.000000000 -0500
@@ -898,8 +898,8 @@ This has two effects. First, directorie
quote marks. Directories after @option{-I-} are searched for all
headers. Second, the directory containing the current file is not
searched for anything, unless it happens to be one of the directories
-named by an @option{-I} switch. @option{-I-} is deprecated, @option{-iquote}
-should be used instead.
+named by an @option{-I} switch. @option{-I-} is deprecated,
+@option{-iquote} and @option{-ignore-source-dir} should be used instead.
@option{-I. -I-} is not the same as no @option{-I} options at all, and does
not cause the same behavior for @samp{<>} includes that @samp{""}
@@ -4045,8 +4045,8 @@ they generally represent bugs in the sna
@item -I- deprecated
-This option has been deprecated in 4.0. @option{-iquote} is meant to
-replace the need for this option.
+This option has been deprecated in 4.0. @option{-iquote} and
+@option{-ignore-source-dir} are meant to replace the need for this option.
@item Order of evaluation of @samp{#} and @samp{##} operators
@@ -4140,8 +4140,8 @@ without notice.
@ignore
@c man begin SYNOPSIS
cpp [@option{-D}@var{macro}[=@var{defn}]@dots{}] [@option{-U}@var{macro}]
- [@option{-I}@var{dir}@dots{}] [@option{-iquote}@var{dir}@dots{}]
- [@option{-W}@var{warn}@dots{}]
+ [@option{-I}@var{dir}@dots{}] [@option{-ignore-source-dir}]
+ [@option{-iquote}@var{dir}@dots{}] [@option{-W}@var{warn}@dots{}]
[@option{-M}|@option{-MM}] [@option{-MG}] [@option{-MF} @var{filename}]
[@option{-MP}] [@option{-MQ} @var{target}@dots{}]
[@option{-MT} @var{target}@dots{}]
diff -Nrup gcc-4.0.2/gcc/doc/cppopts.texi gcc-4.0.2-dv/gcc/doc/cppopts.texi
--- gcc-4.0.2/gcc/doc/cppopts.texi 2005-04-17 07:37:51.000000000 -0400
+++ gcc-4.0.2-dv/gcc/doc/cppopts.texi 2006-02-19 15:28:48.000000000 -0500
@@ -463,6 +463,11 @@ Search @var{dir} for header files, but d
directories specified with @option{-I} and the standard system directories
have been exhausted. @var{dir} is treated as a system include directory.
+@item -ignore-source-dir
+@opindex ignore-source-dir
+Inhibit the use of the current directory (where the current input file
+came from) as the first search directory for @samp{#include "@var{file}"}.
+
@item -iprefix @var{prefix}
@opindex iprefix
Specify @var{prefix} as the prefix for subsequent @option{-iwithprefix}
diff -Nrup gcc-4.0.2/gcc/doc/invoke.texi gcc-4.0.2-dv/gcc/doc/invoke.texi
--- gcc-4.0.2/gcc/doc/invoke.texi 2005-09-02 04:12:30.000000000 -0400
+++ gcc-4.0.2-dv/gcc/doc/invoke.texi 2006-02-19 15:23:18.000000000 -0500
@@ -355,7 +355,7 @@ Objective-C and Objective-C++ Dialects}.
@item Directory Options
@xref{Directory Options,,Options for Directory Search}.
-@gccoptlist{-B@var{prefix} -I@var{dir} -iquote@var{dir} -L@var{dir} -specs=@var{file} -I-}
+@gccoptlist{-B@var{prefix} -I@var{dir} -ignore-source-dir -iquote@var{dir} -L@var{dir} -specs=@var{file} -I-}
@item Target Options
@c I wrote this xref this way to avoid overfull hbox. -- rms
@@ -6033,6 +6033,11 @@ the ordering for the include_next direct
If you really need to change the search order for system directories,
use the @option{-nostdinc} and/or @option{-isystem} options.
+@item -ignore-source-dir
+@opindex ignore-source-dir
+Inhibit the use of the current directory (where the current input file
+came from) as the first search directory for @samp{#include "@var{file}"}.
+
@item -iquote@var{dir}
@opindex iquote
Add the directory @var{dir} to the head of the list of directories to
@@ -6100,8 +6105,10 @@ are processed in order, from left to rig
@item -I-
@opindex I-
This option has been deprecated. Please use @option{-iquote} instead for
-@option{-I} directories before the @option{-I-} and remove the @option{-I-}.
-Any directories you specify with @option{-I} options before the @option{-I-}
+@option{-I} directories before the @option{-I-}, use
+@option{-ignore-source-dir} for not using the source file's directory in
+the include path, and remove the @option{-I-}. Any directories you
+specify with @option{-I} options before the @option{-I-}
option are searched only for the case of @samp{#include "@var{file}"};
they are not searched for @samp{#include <@var{file}>}.
diff -Nrup gcc-4.0.2/gcc/gcc.c gcc-4.0.2-dv/gcc/gcc.c
--- gcc-4.0.2/gcc/gcc.c 2005-06-06 15:20:29.000000000 -0400
+++ gcc-4.0.2-dv/gcc/gcc.c 2006-03-07 18:32:30.000000000 -0500
@@ -1065,6 +1065,7 @@ static const struct option_map option_ma
{"--for-assembler", "-Wa", "a"},
{"--for-linker", "-Xlinker", "a"},
{"--force-link", "-u", "a"},
+ {"--ignore-source-dir", "-ignore-source-dir", 0},
{"--imacros", "-imacros", "a"},
{"--include", "-include", "a"},
{"--include-barrier", "-I-", 0},
@@ -3134,6 +3135,7 @@ process_command (int argc, const char **
int last_language_n_infiles;
int have_c = 0;
int lang_n_infiles = 0;
+ int include_barrier = 0;
#ifdef MODIFY_TARGET_NAME
int is_modify_target_name;
int j;
@@ -3755,6 +3757,12 @@ warranty; not even for MERCHANTABILITY o
if (is_modify_target_name)
break;
#endif
+ if (! strcmp (argv[i], "-I-")) {
+ if (include_barrier)
+ fatal ("-I- specified twice");
+ include_barrier = 1;
+ error ("warning: obsolete option -I- used, please use -iquote/-ignore-source-dir instead");
+ }
n_switches++;
@@ -4006,6 +4014,31 @@ warranty; not even for MERCHANTABILITY o
continue;
}
switches[n_switches].part1 = p;
+
+ if (include_barrier)
+ {
+ /* Substitute -I options that precede -I- with -iquote ones.
+ Substitute -I- with -ignore-source-dir. */
+ if (c == 'I')
+ {
+ if (p[1] == '-')
+ {
+ include_barrier = 0;
+ switches[n_switches].part1 = "ignore-source-dir";
+ }
+ else if (p[1] == 0)
+ switches[n_switches].part1 = "iquote";
+ else
+ {
+ int len = strlen (p);
+ char *q = xmalloc (len + sizeof ("iquote") - 1);
+ memcpy (q, "iquote", sizeof ("iquote") - 1);
+ memcpy (q + sizeof ("iquote") - 1, p + 1, len);
+ switches[n_switches].part1 = q;
+ }
+ }
+ }
+
/* Deal with option arguments in separate argv elements. */
if ((SWITCH_TAKES_ARG (c) > (p[1] != 0))
|| WORD_SWITCH_TAKES_ARG (p))
diff -Nrup gcc-4.0.2/gcc/testsuite/gcc.dg/cpp/inc/iquote.h gcc-4.0.2-dv/gcc/testsuite/gcc.dg/cpp/inc/iquote.h
--- gcc-4.0.2/gcc/testsuite/gcc.dg/cpp/inc/iquote.h 1969-12-31 19:00:00.000000000 -0500
+++ gcc-4.0.2-dv/gcc/testsuite/gcc.dg/cpp/inc/iquote.h 2006-02-17 15:00:49.000000000 -0500
@@ -0,0 +1 @@
+#define A 1
diff -Nrup gcc-4.0.2/gcc/testsuite/gcc.dg/cpp/iquote.c gcc-4.0.2-dv/gcc/testsuite/gcc.dg/cpp/iquote.c
--- gcc-4.0.2/gcc/testsuite/gcc.dg/cpp/iquote.c 1969-12-31 19:00:00.000000000 -0500
+++ gcc-4.0.2-dv/gcc/testsuite/gcc.dg/cpp/iquote.c 2006-02-17 16:42:16.000000000 -0500
@@ -0,0 +1,9 @@
+/* { dg-do preprocess } */
+/* { dg-options "-iquote $srcdir/gcc.dg/cpp/inc -I $srcdir/gcc.dg/cpp -I-" } */
+
+#include "iquote.h"
+#if A != 1
+# error -iquote was not preserved by later use of -I-
+#endif
+
+/* { dg-error "obsolete option -I- used" "warning message about deprecated -I-" { target *-*-* } 0 } */
diff -Nrup gcc-4.0.2/gcc/testsuite/gcc.dg/cpp/iquote.h gcc-4.0.2-dv/gcc/testsuite/gcc.dg/cpp/iquote.h
--- gcc-4.0.2/gcc/testsuite/gcc.dg/cpp/iquote.h 1969-12-31 19:00:00.000000000 -0500
+++ gcc-4.0.2-dv/gcc/testsuite/gcc.dg/cpp/iquote.h 2006-02-17 15:00:54.000000000 -0500
@@ -0,0 +1 @@
+#define A 2
More information about the Gcc-patches
mailing list