2001-01-11 Neil Booth <neil@daikokuya.demon.co.uk>
authorneil <neil@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 11 Jan 2001 21:30:16 +0000 (21:30 +0000)
committerneil <neil@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 11 Jan 2001 21:30:16 +0000 (21:30 +0000)
        * cppinit.c (cpp_start_read): If -fpreprocessed, ignore
-D, -U and -A, and don't initialize the builtins.
* cppmain.c (cb_define, cb_undef): Unconditionally process
the callback.
* tradcpp.c (main): Fix typo.

2000-01-11  Mark Elbrecht  <snowball3@bigfoot.com>

        * cppfiles.c (cpp_included, find_include_file, _cpp_execute_include)
          (read_name_map): Use IS_ABSOLUTE_PATH.
        * tradcpp.c (get_filename): Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@38925 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/cppfiles.c
gcc/cppinit.c
gcc/cppmain.c
gcc/tradcpp.c

index 6fc8dc2..8e8c116 100644 (file)
@@ -1,3 +1,17 @@
+2001-01-11  Neil Booth  <neil@daikokuya.demon.co.uk>
+
+        * cppinit.c (cpp_start_read): If -fpreprocessed, ignore
+        -D, -U and -A, and don't initialize the builtins.
+        * cppmain.c (cb_define, cb_undef): Unconditionally process
+        the callback.
+        * tradcpp.c (main): Fix typo.
+
+2000-01-11  Mark Elbrecht  <snowball3@bigfoot.com>
+         
+        * cppfiles.c (cpp_included, find_include_file, _cpp_execute_include)
+          (read_name_map): Use IS_ABSOLUTE_PATH.
+        * tradcpp.c (get_filename): Likewise.   
+
 2001-01-11  Stephane Carrez  <Stephane.Carrez@worldnet.fr>
 
        * config/m68hc11/m68hc11.md (*adcq, *subcq): Fix operand numbers.
index 0549df3..91f886b 100644 (file)
@@ -430,7 +430,7 @@ cpp_included (pfile, fname)
   char *name;
   splay_tree_node nd;
 
-  if (fname[0] == '/')
+  if (IS_ABSOLUTE_PATHNAME (fname))
     {
       /* Just look it up.  */
       nd = splay_tree_lookup (pfile->all_include_files, (splay_tree_key) fname);
@@ -470,7 +470,7 @@ find_include_file (pfile, fname, search_start)
   char *name;
   struct include_file *file;
 
-  if (fname[0] == '/')
+  if (IS_ABSOLUTE_PATHNAME (fname))
     return open_file (pfile, fname);
       
   /* Search directory path for the file.  */
@@ -648,7 +648,7 @@ _cpp_execute_include (pfile, header, no_reinclude, include_next)
   if (CPP_OPTION (pfile, print_deps_missing_files)
       && PRINT_THIS_DEP (pfile, angle_brackets))
     {
-      if (!angle_brackets || *fname == '/')
+      if (!angle_brackets || IS_ABSOLUTE_PATHNAME (fname))
        deps_add_dep (pfile->deps, fname);
       else
        {
@@ -890,7 +890,7 @@ read_name_map (pfile, dirname)
          ptr->map_from = from;
 
          /* Make the real filename absolute.  */
-         if (*to == '/')
+         if (IS_ABSOLUTE_PATHNAME (to))
            ptr->map_to = to;
          else
            {
index 0a7fe48..b7cbbf2 100644 (file)
@@ -849,9 +849,11 @@ do_includes (pfile, p, scan)
     {
       struct pending_option *q;
 
-      /* Later: maybe update this to use the #include "" search path
-        if cpp_read_file fails.  */
-      if (_cpp_read_file (pfile, p->arg) && scan)
+      /* Don't handle if -fpreprocessed.  Later: maybe update this to
+        use the #include "" search path if cpp_read_file fails.  */
+      if (! CPP_OPTION (pfile, preprocessed))
+       cpp_error (pfile, "-include and -imacros cannot be used with -fpreprocessed");
+      else if (_cpp_read_file (pfile, p->arg) && scan)
        cpp_scan_buffer_nooutput (pfile, 0);
       q = p->next;
       free (p);
@@ -859,10 +861,9 @@ do_includes (pfile, p, scan)
     }
 }
 
-/* This is called after options have been processed.  Check options
- for consistency, and setup for processing input from the file named
- FNAME.  (Use standard input if FNAME == NULL.)  Return 1 on success,
- 0 on failure.  */
+/* This is called after options have been processed.  Setup for
+   processing input from the file named FNAME.  (Use standard input if
+   FNAME == NULL.)  Return 1 on success, 0 on failure.  */
 
 int
 cpp_start_read (pfile, fname)
@@ -915,18 +916,22 @@ cpp_start_read (pfile, fname)
   if (!_cpp_read_file (pfile, fname))
     return 0;
 
-  /* Install __LINE__, etc.  */
-  init_builtins (pfile);
+  /* If already preprocessed, don't install __LINE__, etc., and ignore
+     command line definitions and assertions.  Handle -U's, -D's and
+     -A's in the order they were seen.  */
+  if (! CPP_OPTION (pfile, preprocessed))
+    init_builtins (pfile);
 
-  /* Do -U's, -D's and -A's in the order they were seen.  */
   p = CPP_OPTION (pfile, pending)->directive_head;
   while (p)
     {
-      (*p->handler) (pfile, p->arg);
+      if (! CPP_OPTION (pfile, preprocessed))
+       (*p->handler) (pfile, p->arg);
       q = p->next;
       free (p);
       p = q;
     }
+
   pfile->done_initializing = 1;
 
   /* The -imacros files can be scanned now, but the -include files
@@ -1131,10 +1136,10 @@ static const struct cl_option cl_options[] =
    command-line matches.  Returns its index in the option array,
    negative on failure.  Complications arise since some options can be
    suffixed with an argument, and multiple complete matches can occur,
-   e.g. -iwithprefix and -iwithprefixbefore.  Moreover, we want to
-   accept options beginning with -g and -W that we do not recognise,
-   but not to swallow any subsequent command line argument; these are
-   handled as special cases in cpp_handle_option.  */
+   e.g. -iwithprefix and -iwithprefixbefore.  Moreover, we need to
+   accept options beginning with -W that we do not recognise, but not
+   to swallow any subsequent command line argument; this is handled as
+   special cases in cpp_handle_option.  */
 static int
 parse_option (input)
      const char *input;
index 9e08bbe..dbb86ea 100644 (file)
@@ -344,18 +344,15 @@ cb_define (pfile, node)
      cpp_reader *pfile;
      cpp_hashnode *node;
 {
-  if (pfile->done_initializing)
-    {
-      maybe_print_line (cpp_get_line (pfile)->output_line);
-      fprintf (print.outf, "#define %s", node->name);
+  maybe_print_line (cpp_get_line (pfile)->output_line);
+  fprintf (print.outf, "#define %s", node->name);
 
-      /* -dD command line option.  */
-      if (CPP_OPTION (pfile, dump_macros) == dump_definitions)
-       fputs ((const char *) cpp_macro_definition (pfile, node), print.outf);
+  /* -dD command line option.  */
+  if (CPP_OPTION (pfile, dump_macros) == dump_definitions)
+    fputs ((const char *) cpp_macro_definition (pfile, node), print.outf);
 
-      putc ('\n', print.outf);
-      print.lineno++;
-    }
+  putc ('\n', print.outf);
+  print.lineno++;
 }
 
 static void
@@ -363,12 +360,9 @@ cb_undef (pfile, node)
      cpp_reader *pfile;
      cpp_hashnode *node;
 {
-  if (pfile->done_initializing)
-    {
-      maybe_print_line (cpp_get_line (pfile)->output_line);
-      fprintf (print.outf, "#undef %s\n", node->name);
-      print.lineno++;
-    }
+  maybe_print_line (cpp_get_line (pfile)->output_line);
+  fprintf (print.outf, "#undef %s\n", node->name);
+  print.lineno++;
 }
 
 static void
index 64ff649..e5e0935 100644 (file)
@@ -647,7 +647,7 @@ main (argc, argv)
            int quoted = argv[i][2] == 'Q';
 
            if (*tgt == '\0' && i + 1 == argc)
-             fatal ("Filename missing after %s option", argv[i]);
+             fatal ("Target missing after %s option", argv[i]);
            else
              {
                if (*tgt == '\0')
@@ -2374,7 +2374,7 @@ get_filename:
 
   /* If specified file name is absolute, just open it.  */
 
-  if (*fbeg == '/') {
+  if (IS_ABSOLUTE_PATHNAME (fbeg)) {
     strncpy (fname, (const char *)fbeg, flen);
     fname[flen] = 0;
     f = open (fname, O_RDONLY, 0666);
@@ -2409,7 +2409,7 @@ get_filename:
       else
        stackp = include;
 
-      if (!system_header_p || *fbeg == '/' || !stackp->fname)
+      if (!system_header_p || IS_ABSOLUTE_PATHNAME (fbeg) || !stackp->fname)
        deps_add_dep (deps, fname);
       else {
        char *p;