This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: getting back the quote_ignores_source_dir behavior of -I-


Hi,

I could be wrong, but I was under the impression that this patch is close to be in an acceptable state.
Is there anything I need to do in order to make it eventually committed?


Thanks,
--
Daniel Villeneuve

Daniel Villeneuve wrote:

Zack Weinberg writes:
> I have one remaining nitpick:
> > > + if (! strcmp (argv[i], "-I-")) {


(snip)

> > + }
> > This block isn't formatted right: you have some weird
> combination of GNU and K+R brace style going here.
> Please put the { on its own line and reindent.


Another round, with indentation hopefully correct and new test 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/iquote1.c: New test.
	* testsuite/gcc.dg/cpp/iquote2.c: New test.
	* testsuite/gcc.dg/cpp/iquote3.c: New test.
	* testsuite/gcc.dg/cpp/iquote4.c: New test.
	* testsuite/gcc.dg/cpp/iquote5.c: New test.
	* testsuite/gcc.dg/cpp/iquote6.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.

Regards,
--
Daniel Villeneuve


diff -rNup 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 -rNup 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 -rNup 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 -rNup 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 -rNup 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 -rNup 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 -rNup 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 -rNup 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 -rNup 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-18 11:04:00.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,14 @@ 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 +4016,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 -rNup 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-03-18 16:20:06.000000000 -0500
@@ -0,0 +1 @@
+#define A 1
diff -rNup 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-03-18 16:21:37.000000000 -0500
@@ -0,0 +1 @@
+#define A 0
diff -rNup gcc-4.0.2/gcc/testsuite/gcc.dg/cpp/iquote1.c gcc-4.0.2-dv/gcc/testsuite/gcc.dg/cpp/iquote1.c
--- gcc-4.0.2/gcc/testsuite/gcc.dg/cpp/iquote1.c	1969-12-31 19:00:00.000000000 -0500
+++ gcc-4.0.2-dv/gcc/testsuite/gcc.dg/cpp/iquote1.c	2006-03-18 17:04:59.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 -rNup gcc-4.0.2/gcc/testsuite/gcc.dg/cpp/iquote2.c gcc-4.0.2-dv/gcc/testsuite/gcc.dg/cpp/iquote2.c
--- gcc-4.0.2/gcc/testsuite/gcc.dg/cpp/iquote2.c	1969-12-31 19:00:00.000000000 -0500
+++ gcc-4.0.2-dv/gcc/testsuite/gcc.dg/cpp/iquote2.c	2006-03-18 16:30:32.000000000 -0500
@@ -0,0 +1,9 @@
+/* { dg-do preprocess } */
+/* { dg-options "-I $srcdir/gcc.dg/cpp/inc -I-" } */
+
+#include "iquote.h"
+#if A != 1
+# error "-I dir" preceding -I- not transformed properly
+#endif
+
+/* { dg-error "obsolete option -I- used" "warning message about deprecated -I-" { target *-*-* } 0 } */
diff -rNup gcc-4.0.2/gcc/testsuite/gcc.dg/cpp/iquote3.c gcc-4.0.2-dv/gcc/testsuite/gcc.dg/cpp/iquote3.c
--- gcc-4.0.2/gcc/testsuite/gcc.dg/cpp/iquote3.c	1969-12-31 19:00:00.000000000 -0500
+++ gcc-4.0.2-dv/gcc/testsuite/gcc.dg/cpp/iquote3.c	2006-03-18 16:30:38.000000000 -0500
@@ -0,0 +1,9 @@
+/* { dg-do preprocess } */
+/* { dg-options "-I$srcdir/gcc.dg/cpp/inc -I-" } */
+
+#include "iquote.h"
+#if A != 1
+# error "-Idir" preceding -I- not transformed properly
+#endif
+
+/* { dg-error "obsolete option -I- used" "warning message about deprecated -I-" { target *-*-* } 0 } */
diff -rNup gcc-4.0.2/gcc/testsuite/gcc.dg/cpp/iquote4.c gcc-4.0.2-dv/gcc/testsuite/gcc.dg/cpp/iquote4.c
--- gcc-4.0.2/gcc/testsuite/gcc.dg/cpp/iquote4.c	1969-12-31 19:00:00.000000000 -0500
+++ gcc-4.0.2-dv/gcc/testsuite/gcc.dg/cpp/iquote4.c	2006-03-18 16:31:55.000000000 -0500
@@ -0,0 +1,7 @@
+/* { dg-do preprocess } */
+/* { dg-options "-I$srcdir/gcc.dg/cpp/inc -ignore-source-dir" } */
+
+#include "iquote.h"
+#if A != 1
+# error -ignore-source-dir not handled properly
+#endif
diff -rNup gcc-4.0.2/gcc/testsuite/gcc.dg/cpp/iquote5.c gcc-4.0.2-dv/gcc/testsuite/gcc.dg/cpp/iquote5.c
--- gcc-4.0.2/gcc/testsuite/gcc.dg/cpp/iquote5.c	1969-12-31 19:00:00.000000000 -0500
+++ gcc-4.0.2-dv/gcc/testsuite/gcc.dg/cpp/iquote5.c	2006-03-18 16:31:59.000000000 -0500
@@ -0,0 +1,7 @@
+/* { dg-do preprocess } */
+/* { dg-options "-I$srcdir/gcc.dg/cpp/inc --ignore-source-dir" } */
+
+#include "iquote.h"
+#if A != 1
+# error --ignore-source-dir not handled properly
+#endif
diff -rNup gcc-4.0.2/gcc/testsuite/gcc.dg/cpp/iquote6.c gcc-4.0.2-dv/gcc/testsuite/gcc.dg/cpp/iquote6.c
--- gcc-4.0.2/gcc/testsuite/gcc.dg/cpp/iquote6.c	1969-12-31 19:00:00.000000000 -0500
+++ gcc-4.0.2-dv/gcc/testsuite/gcc.dg/cpp/iquote6.c	2006-03-18 16:31:36.000000000 -0500
@@ -0,0 +1,7 @@
+/* { dg-do preprocess } */
+/* { dg-options "-I$srcdir/gcc.dg/cpp/inc" } */
+
+#include "iquote.h"
+#if A != 0
+# error not using the source directory as expected
+#endif






Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]