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]

#import and subframeworks on Darwin


In order to have files found by the loop below that looks to see if a
#import is in effect, they must be in the list of all files.

Although this is not a regression, the bug it fixes was not present in
previous versions of GCC so I am committing it anyway.

Bootstrapped & tested on powerpc-darwin.

-- 
- Geoffrey Keating <geoffk@apple.com>

===File ~/patches/gcc-3883233.patch=========================
Index: libcpp/ChangeLog
2005-01-03  Geoffrey Keating  <geoffk@apple.com>

	* files.c (_cpp_find_file): Add files found by search_path_exhausted
	to the list of all files.

Index: gcc/testsuite/ChangeLog
2005-01-03  Geoffrey Keating  <geoffk@apple.com>
	    Robert Bowdidge <bowdidge@apple.com>

	* gcc.dg/cpp/subframework1.c: New.
	* gcc.dg/cpp/frame/one.framework/Frameworks/OneSub.framework/Headers/A.h: New.
	* gcc.dg/cpp/frame/one.framework/Frameworks/OneSub.framework/Headers/B.h: New.
	* gcc.dg/cpp/frame/one.framework/Frameworks/OneSub.framework/Headers/C.h: New.
	* gcc.dg/cpp/frame/one.framework/Headers/one-includeSubs.h: New.

Index: libcpp/files.c
===================================================================
RCS file: /cvs/gcc/gcc/libcpp/files.c,v
retrieving revision 1.6
diff -u -p -u -p -r1.6 files.c
--- libcpp/files.c	15 Dec 2004 13:31:24 -0000	1.6
+++ libcpp/files.c	4 Jan 2005 02:08:02 -0000
@@ -438,7 +438,15 @@ _cpp_find_file (cpp_reader *pfile, const
       if (file->dir == NULL)
 	{
 	  if (search_path_exhausted (pfile, fname, file))
-	    return file;
+	    {
+	      /* Although this file must not go in the cache, because
+		 the file found might depend on things (like the current file)
+		 that aren't represented in the cache, it still has to go in
+		 the list of all files so that #import works.  */
+	      file->next_file = pfile->all_files;
+	      pfile->all_files = file;
+	      return file;
+	    }
 
 	  open_file_failed (pfile, file);
 	  if (invalid_pch)
Index: gcc/testsuite/gcc.dg/cpp/subframework1.c
===================================================================
RCS file: gcc/testsuite/gcc.dg/cpp/subframework1.c
diff -N gcc/testsuite/gcc.dg/cpp/subframework1.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gcc/testsuite/gcc.dg/cpp/subframework1.c	4 Jan 2005 02:09:04 -0000
@@ -0,0 +1,15 @@
+/* Copyright (C) 2004 Free Software Foundation, Inc.  */
+
+/* { dg-do preprocess } */
+/* { dg-options "-F$srcdir/gcc.dg/cpp/frame" } */
+
+/* Contributed by Robert Bowdidge <bowdidge@apple.com>  */
+/* include a file from a subframework that will import two files that
+   both look at the same file.  Make sure we only include that file once;
+   if so, the program will compile fine.  If not, we'll get redefinition
+   errors */
+
+#include <one/one-includeSubs.h>
+#ifndef ONESUB_C_INCLUDED
+#error C.h not included
+#endif
Index: gcc/testsuite/gcc.dg/cpp/frame/one.framework/Frameworks/OneSub.framework/Headers/A.h
===================================================================
RCS file: gcc/testsuite/gcc.dg/cpp/frame/one.framework/Frameworks/OneSub.framework/Headers/A.h
diff -N gcc/testsuite/gcc.dg/cpp/frame/one.framework/Frameworks/OneSub.framework/Headers/A.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gcc/testsuite/gcc.dg/cpp/frame/one.framework/Frameworks/OneSub.framework/Headers/A.h	4 Jan 2005 02:09:04 -0000
@@ -0,0 +1 @@
+#import <OneSub/C.h>
Index: gcc/testsuite/gcc.dg/cpp/frame/one.framework/Frameworks/OneSub.framework/Headers/B.h
===================================================================
RCS file: gcc/testsuite/gcc.dg/cpp/frame/one.framework/Frameworks/OneSub.framework/Headers/B.h
diff -N gcc/testsuite/gcc.dg/cpp/frame/one.framework/Frameworks/OneSub.framework/Headers/B.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gcc/testsuite/gcc.dg/cpp/frame/one.framework/Frameworks/OneSub.framework/Headers/B.h	4 Jan 2005 02:09:04 -0000
@@ -0,0 +1 @@
+#import <OneSub/C.h>
Index: gcc/testsuite/gcc.dg/cpp/frame/one.framework/Frameworks/OneSub.framework/Headers/C.h
===================================================================
RCS file: gcc/testsuite/gcc.dg/cpp/frame/one.framework/Frameworks/OneSub.framework/Headers/C.h
diff -N gcc/testsuite/gcc.dg/cpp/frame/one.framework/Frameworks/OneSub.framework/Headers/C.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gcc/testsuite/gcc.dg/cpp/frame/one.framework/Frameworks/OneSub.framework/Headers/C.h	4 Jan 2005 02:09:04 -0000
@@ -0,0 +1,4 @@
+#ifdef ONESUB_C_INCLUDED
+#error should only be imported once
+#endif
+#define ONESUB_C_INCLUDED 1
Index: gcc/testsuite/gcc.dg/cpp/frame/one.framework/Headers/one-includeSubs.h
===================================================================
RCS file: gcc/testsuite/gcc.dg/cpp/frame/one.framework/Headers/one-includeSubs.h
diff -N gcc/testsuite/gcc.dg/cpp/frame/one.framework/Headers/one-includeSubs.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gcc/testsuite/gcc.dg/cpp/frame/one.framework/Headers/one-includeSubs.h	4 Jan 2005 02:09:04 -0000
@@ -0,0 +1,2 @@
+#import <OneSub/A.h>
+#import <OneSub/B.h>
============================================================


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