Makefile.in: Refine dependencies.
authorNeil Booth <neil@daikokuya.co.uk>
Fri, 1 Aug 2003 14:04:02 +0000 (14:04 +0000)
committerNeil Booth <neil@gcc.gnu.org>
Fri, 1 Aug 2003 14:04:02 +0000 (14:04 +0000)
* Makefile.in: Refine dependencies.
* c-opts.c (c_common_handle_option): Do nothing for -Wimport.
* c.opt: Update help for -Wimport.
* cppfiles.c: Include hashtab.h.  Update comments.
(stack_file): Read the file before updating dependencies.
(once_only_file_p): Be smarter about marking once-only files.
(_cpp_mark_file_once_only): Correct the check for existence on
the list.
(open_file_failed): Use name not path, which is NULL.
* cpphash.h: Don't include hashtab.h.
(struct _cpp_file): Remove.
(struct cpp_reader): Update.
* cppinit.c (cpp_create_reader): Don't initialize warn_import.
* cpplib.h (struct cpp_options): Remove warn_import.
(cpp_simplify_path): Remove.

From-SVN: r70045

gcc/ChangeLog
gcc/Makefile.in
gcc/c-opts.c
gcc/c.opt
gcc/cppfiles.c
gcc/cpphash.h
gcc/cppinit.c
gcc/cpplib.h

index 56fe21a8a30c85c4b41284b5489a494734748f90..625eb041342e1acae4ae27ecfbde8d4071a2ede4 100644 (file)
@@ -1,3 +1,21 @@
+2003-08-01  Neil Booth  <neil@daikokuya.co.uk>
+
+       * Makefile.in: Refine dependencies.
+       * c-opts.c (c_common_handle_option): Do nothing for -Wimport.
+       * c.opt: Update help for -Wimport.
+       * cppfiles.c: Include hashtab.h.  Update comments.
+       (stack_file): Read the file before updating dependencies.
+       (once_only_file_p): Be smarter about marking once-only files.
+       (_cpp_mark_file_once_only): Correct the check for existence on
+       the list.
+       (open_file_failed): Use name not path, which is NULL.
+       * cpphash.h: Don't include hashtab.h.
+       (struct _cpp_file): Remove.
+       (struct cpp_reader): Update.
+       * cppinit.c (cpp_create_reader): Don't initialize warn_import.
+       * cpplib.h (struct cpp_options): Remove warn_import.
+       (cpp_simplify_path): Remove.
+
 2003-08-01  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR c++/11295
index 78cd1710c50def2a4079647ffcda42ff5efaa6b5..1bb944fe31ffb1c653a363b1c3c6ec0aa18bad90 100644 (file)
@@ -2354,7 +2354,7 @@ LIBCPP_OBJS =     cpplib.o cpplex.o cppmacro.o cppexp.o cppfiles.o cpptrad.o \
                hashtable.o line-map.o mkdeps.o cpppch.o
 
 LIBCPP_DEPS =  $(CPPLIB_H) cpphash.h line-map.h hashtable.h intl.h \
-               $(HASHTAB_H) $(OBSTACK_H) $(CONFIG_H) $(SYSTEM_H)
+               $(OBSTACK_H) $(CONFIG_H) $(SYSTEM_H)
 
 # Most of the other archives built/used by this makefile are for
 # targets.  This one is strictly for the host.
@@ -2371,7 +2371,7 @@ cppmacro.o: cppmacro.c $(LIBCPP_DEPS)
 cpplib.o:   cpplib.c   $(LIBCPP_DEPS)
 cpphash.o:  cpphash.c  $(LIBCPP_DEPS)
 cpptrad.o:  cpptrad.c  $(LIBCPP_DEPS)
-cppfiles.o: cppfiles.c $(LIBCPP_DEPS) $(SPLAY_TREE_H) mkdeps.h
+cppfiles.o: cppfiles.c $(LIBCPP_DEPS) $(HASHTAB_H) mkdeps.h
 cppinit.o:  cppinit.c  $(LIBCPP_DEPS) mkdeps.h
 cpppch.o:   cpppch.c   $(LIBCPP_DEPS) mkdeps.h
 
index 3e4a10aafd3c3745b6fba8328836251da5409303..e1922cb9bcb94ed61b35ff83b493a1afa311980a 100644 (file)
@@ -484,7 +484,7 @@ c_common_handle_option (size_t scode, const char *arg, int value)
       break;
 
     case OPT_Wimport:
-      cpp_opts->warn_import = value;
+      /* Silently ignore for now.  */
       break;
 
     case OPT_Winvalid_offsetof:
index 15b96ad5e826442261fff55554d889c6dafeb0a3..221fb678b3ddbc4fa44009dd49646dffa215639a 100644 (file)
--- a/gcc/c.opt
+++ b/gcc/c.opt
@@ -251,7 +251,7 @@ Warn when a declaration does not specify a type
 
 Wimport
 C ObjC C++ ObjC++
-Warn about uses of the \"#import\" directive
+Deprecated.  This switch has no effect.
 
 Winvalid-offsetof
 C++ ObjC++
index cd3498e42dac3c7c6b862af997563cedd6a29180..374036a29cd4f1eae67a92da780f869c6b452dfc 100644 (file)
@@ -27,6 +27,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #include "cpphash.h"
 #include "intl.h"
 #include "mkdeps.h"
+#include "hashtab.h"
 #include <dirent.h>
 
 /* Variable length record files on VMS will have a stat size that includes
@@ -68,8 +69,8 @@ struct _cpp_file
   /* The full path of the pch file.  */
   const char *pchname;
 
-  /* The file's path with the basename stripped, malloced.  NULL if it
-     hasn't been calculated yet.  */
+  /* The file's path with the basename stripped.  NULL if it hasn't
+     been calculated yet.  */
   const char *dir_name;
 
   /* Chain through #import-ed files or those  containing #pragma once.  */
@@ -83,8 +84,7 @@ struct _cpp_file
 
   /* The directory in the search path where FILE was found.  Used for
      #include_next and determining whether a header is a system
-     header.  Is NULL if the file was given as an absolute path, or
-     opened with read_file.  */
+     header.  */
   cpp_dir *dir;
 
   /* As filled in by stat(2) for the file.  */
@@ -126,23 +126,28 @@ struct _cpp_file
    its head pointed to by a slot in FILE_HASH.  The file name is what
    appeared between the quotes in a #include directive; it can be
    determined implicity from the hash table location or explicitly
-   from FILE->fname.
+   from FILE->name.
 
    FILE is a structure containing details about the file that was
    found with that search, or details of how the search failed.
 
    START_DIR is the starting location of the search in the include
    chain.  The current directories for "" includes are also hashed in
-   the hash table.  Files that are looked up without using a search
-   path, such as absolute filenames and file names from the command
-   line share a special starting directory so they don't get confused
-   with normal include-chain lookups in the cache.
+   the hash table and therefore unique.  Files that are looked up
+   without using a search path, such as absolute filenames and file
+   names from the command line share a special starting directory so
+   they don't cause cache hits with normal include-chain lookups.
 
    If START_DIR is NULL then the entry is for a directory, not a file,
    and the directory is in DIR.  Since the starting point in a file
    lookup chain is never NULL, this means that simple pointer
    comparisons against START_DIR can be made to determine cache hits
    in file lookups.
+
+   If a cache lookup fails because of e.g. an extra "./" in the path,
+   then nothing will break.  It is just less efficient as CPP will
+   have to do more work re-preprocessing the file, and/or comparing
+   its contents against earlier once-only files.
 */
 struct file_hash_entry
 {
@@ -530,6 +535,9 @@ stack_file (cpp_reader *pfile, _cpp_file *file, bool import)
   if (once_only_file_p (pfile, file, import))
       return false;
 
+  if (!read_file (pfile, file))
+    return false;
+
   sysp = MAX ((pfile->map ? pfile->map->sysp : 0),
              (file->dir ? file->dir->sysp : 0));
 
@@ -540,9 +548,6 @@ stack_file (cpp_reader *pfile, _cpp_file *file, bool import)
        deps_add_dep (pfile->deps, file->path);
     }
 
-  if (!read_file (pfile, file))
-    return false;
-
   /* Clear buffer_valid since _cpp_clean_line messes it up.  */
   file->buffer_valid = false;
   file->stack_count++;
@@ -580,15 +585,12 @@ once_only_file_p (cpp_reader *pfile, _cpp_file *file, bool import)
     return true;
 
   /* Are we #import-ing a previously #import-ed file?  */
-  if (import)
-    {
-      if (file->import)
-       return true;
-      _cpp_mark_file_once_only (pfile, file, true);
-    }
+  if (import && file->import)
+    return true;
 
   /* Read the file contents now.  stack_file would do it later, and
-     we're smart enough to not do it twice, so this is no loss.  */
+     we're smart enough to not do it twice, so this is no loss.  Note
+     we don't mark the file once-only if we can't read it.  */
   if (!read_file (pfile, file))
     return false;
 
@@ -609,10 +611,13 @@ once_only_file_p (cpp_reader *pfile, _cpp_file *file, bool import)
          /* Size might have changed in read_file().  */
          && f->st.st_size == file->st.st_size
          && !memcmp (f->buffer, file->buffer, f->st.st_size))
-       return true;
+       break;
     }
 
-  return false;
+  if (import || f != NULL)
+    _cpp_mark_file_once_only (pfile, file, import);
+
+  return f != NULL;
 }
 
 /* Mark FILE to be included once only.  IMPORT is true if because of
@@ -620,22 +625,22 @@ once_only_file_p (cpp_reader *pfile, _cpp_file *file, bool import)
 void
 _cpp_mark_file_once_only (cpp_reader *pfile, _cpp_file *file, bool import)
 {
-  if (import)
-    file->import = true;
-  else
-    {
-      pfile->saw_pragma_once = true;
-      file->pragma_once = true;
-    }
-
   /* Put it on the once-only list if it's not on there already (an
      earlier #include with a #pragma once might have put it on there
      already).  */
-  if (file->once_only_next == NULL)
+  if (!file->import && !file->pragma_once)
     {
       file->once_only_next = pfile->once_only_files;
       pfile->once_only_files = file;
     }
+
+  if (import)
+    file->import = true;
+  else
+    {
+      pfile->saw_pragma_once = true;
+      file->pragma_once = true;
+    }
 }
 
 /* Return the directory from which searching for FNAME should start,
@@ -731,7 +736,7 @@ open_file_failed (cpp_reader *pfile, _cpp_file *file)
 
   errno = file->err_no;
   if (print_dep && CPP_OPTION (pfile, deps.missing_files) && errno == ENOENT)
-    deps_add_dep (pfile->deps, file->path);
+    deps_add_dep (pfile->deps, file->name);
   else
     {
       /* If we are outputting dependencies but not for this file then
index e4378cb89d0556f43a40a5afed31278bcedf1e9d..951dd2f4101d8ad0ef03aedf5fde1d725008fdaf 100644 (file)
@@ -24,7 +24,6 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #define GCC_CPPHASH_H
 
 #include "hashtable.h"
-#include "hashtab.h"
 
 #ifdef HAVE_ICONV
 #include <iconv.h>
@@ -37,7 +36,6 @@ struct directive;             /* Deliberately incomplete.  */
 struct pending_option;
 struct op;
 struct strbuf;
-struct _cpp_file;
 
 typedef bool (*convert_f) (iconv_t, const unsigned char *, size_t,
                           struct strbuf *);
@@ -365,7 +363,7 @@ struct cpp_reader
   struct _cpp_file *once_only_files;
 
   /* File and directory hash table.  */
-  htab_t file_hash;
+  struct htab *file_hash;
   struct file_hash_entry *file_hash_entries;
   unsigned int file_hash_entries_allocated, file_hash_entries_used;
 
index 5f10e2730713f7f33e044932a407f5fc339087f0..b719a85bb8cc4930d92890962ef9b35e719fdb3f 100644 (file)
@@ -133,7 +133,6 @@ cpp_create_reader (enum c_lang lang, hash_table *table)
   pfile = xcalloc (1, sizeof (cpp_reader));
 
   cpp_set_lang (pfile, lang);
-  CPP_OPTION (pfile, warn_import) = 1;
   CPP_OPTION (pfile, warn_multichar) = 1;
   CPP_OPTION (pfile, discard_comments) = 1;
   CPP_OPTION (pfile, discard_comments_in_macro_exp) = 1;
index 7f5cfd4edd98477bf799d2fdb9d489e062f48d6d..ca3f81422ad8beebb215358613ea4a9fb918361b 100644 (file)
@@ -267,9 +267,6 @@ struct cpp_options
   /* Nonzero means warn if there are any trigraphs.  */
   unsigned char warn_trigraphs;
 
-  /* Nonzero means warn if #import is used.  */
-  unsigned char warn_import;
-
   /* Nonzero means warn about multicharacter charconsts.  */
   unsigned char warn_multichar;
 
@@ -712,7 +709,6 @@ extern unsigned char *cpp_quote_string (unsigned char *, const unsigned char *,
 /* In cppfiles.c */
 extern bool cpp_included (cpp_reader *, const char *);
 extern void cpp_make_system_header (cpp_reader *, int, int);
-extern void cpp_simplify_path (char *);
 extern bool cpp_push_include (cpp_reader *, const char *);
 extern void cpp_change_file (cpp_reader *, enum lc_reason, const char *);