OSDN Git Service

* config/rs6000/rs6000.c (spe_init_builtins,
[pf3gnuchains/gcc-fork.git] / gcc / cpplib.c
index 59e2fe6..935a0e0 100644 (file)
@@ -162,14 +162,7 @@ D(ident,   T_IDENT,        EXTENSION, IN_I)           /*     11 */ \
 D(import,      T_IMPORT,       EXTENSION, INCL | EXPAND)  /* 0 ObjC */ \
 D(assert,      T_ASSERT,       EXTENSION, 0)              /* 0 SVR4 */ \
 D(unassert,    T_UNASSERT,     EXTENSION, 0)              /* 0 SVR4 */ \
-SCCS_ENTRY                                                /* 0 SVR4? */
-
-/* #sccs is not always recognized.  */
-#ifdef SCCS_DIRECTIVE
-# define SCCS_ENTRY D(sccs, T_SCCS, EXTENSION, 0)
-#else
-# define SCCS_ENTRY /* nothing */
-#endif
+D(sccs,                T_SCCS,         EXTENSION, 0)              /* 0 SVR4? */
 
 /* Use the table to generate a series of prototypes, an enum for the
    directive names, and an array of directive handlers.  */
@@ -284,9 +277,7 @@ static void
 prepare_directive_trad (pfile)
      cpp_reader *pfile;
 {
-  if (pfile->directive == &dtable[T_DEFINE])
-    CUR (pfile->context) = pfile->buffer->cur;
-  else
+  if (pfile->directive != &dtable[T_DEFINE])
     {
       bool no_expand = (pfile->directive
                        && ! (pfile->directive->flags & EXPAND));
@@ -305,9 +296,6 @@ prepare_directive_trad (pfile)
                           pfile->out.cur - pfile->out.base);
     }
 
-  /* Report diagnostics on the line of the directive.  */
-  pfile->line = pfile->directive_line;
-
   /* Stop ISO C from expanding anything.  */
   pfile->state.prevent_expansion++;
 }
@@ -390,10 +378,6 @@ _cpp_handle_directive (pfile, indented)
                   "style of line directive is a GCC extension");
     }
 
-  pfile->directive = dir;
-  if (CPP_OPTION (pfile, traditional))
-    prepare_directive_trad (pfile);
-
   if (dir)
     {
       /* If we have a directive that is not an opening conditional,
@@ -444,17 +428,12 @@ _cpp_handle_directive (pfile, indented)
                   cpp_token_as_text (pfile, dname));
     }
 
+  pfile->directive = dir;
+  if (CPP_OPTION (pfile, traditional))
+    prepare_directive_trad (pfile);
+
   if (dir)
-    {
-      /* If we are processing a `#define' directive and we have been
-        requested to expand comments into macros, then re-enable
-        saving of comments.  */
-      if (dir == &dtable[T_DEFINE])
-       pfile->state.save_comments =
-         ! CPP_OPTION (pfile, discard_comments_in_macro_exp);
-
-      (*pfile->directive->handler) (pfile);
-    }
+    (*pfile->directive->handler) (pfile);
   else if (skip == 0)
     _cpp_backup_tokens (pfile, 1);
 
@@ -504,16 +483,7 @@ lex_macro_node (pfile)
      In C++, it may not be any of the "named operators" either,
      per C++98 [lex.digraph], [lex.key].
      Finally, the identifier may not have been poisoned.  (In that case
-     the lexer has issued the error message for us.)
-
-     Note that if we're copying comments into macro expansions, we
-     could encounter comment tokens here, so eat them all up first.  */
-
-  if (! CPP_OPTION (pfile, discard_comments_in_macro_exp))
-    {
-      while (token->type == CPP_COMMENT)
-       token = _cpp_lex_token (pfile);
-    }
+     the lexer has issued the error message for us.)  */
 
   if (token->type == CPP_NAME)
     {
@@ -547,6 +517,11 @@ do_define (pfile)
 
   if (node)
     {
+      /* If we have been requested to expand comments into macros,
+        then re-enable saving of comments.  */
+      pfile->state.save_comments =
+       ! CPP_OPTION (pfile, discard_comments_in_macro_exp);
+
       if (_cpp_create_definition (pfile, node))
        if (pfile->cb.define)
          (*pfile->cb.define) (pfile, pfile->directive_line, node);
@@ -570,6 +545,9 @@ do_undef (pfile)
       if (node->flags & NODE_WARN)
        cpp_error (pfile, DL_WARNING, "undefining \"%s\"", NODE_NAME (node));
 
+      if (CPP_OPTION (pfile, warn_unused_macros))
+       _cpp_warn_if_unused_macro (pfile, node, NULL);
+
       _cpp_free_definition (node);
     }
   check_eol (pfile);
@@ -704,7 +682,6 @@ do_include_common (pfile, type)
          if (pfile->cb.include)
            (*pfile->cb.include) (pfile, pfile->directive_line,
                                  pfile->directive->name, header);
-
          _cpp_execute_include (pfile, header, type);
        }
     }
@@ -1338,14 +1315,12 @@ _cpp_do__Pragma (pfile)
     }
 }
 
-/* Just ignore #sccs, on systems where we define it at all.  */
-#ifdef SCCS_DIRECTIVE
+/* Just ignore #sccs on all systems.  */
 static void
 do_sccs (pfile)
      cpp_reader *pfile ATTRIBUTE_UNUSED;
 {
 }
-#endif
 
 /* Handle #ifdef.  */
 static void
@@ -1359,10 +1334,11 @@ do_ifdef (pfile)
       const cpp_hashnode *node = lex_macro_node (pfile);
 
       if (node)
-       skip = node->type != NT_MACRO;
-
-      if (node)
-       check_eol (pfile);
+       {
+         skip = node->type != NT_MACRO;
+         _cpp_mark_macro_used (node);
+         check_eol (pfile);
+       }
     }
 
   push_conditional (pfile, skip, T_IFDEF, 0);
@@ -1379,11 +1355,13 @@ do_ifndef (pfile)
   if (! pfile->state.skipping)
     {
       node = lex_macro_node (pfile);
-      if (node)
-       skip = node->type == NT_MACRO;
 
       if (node)
-       check_eol (pfile);
+       {
+         skip = node->type == NT_MACRO;
+         _cpp_mark_macro_used (node);
+         check_eol (pfile);
+       }
     }
 
   push_conditional (pfile, skip, T_IFNDEF, node);
@@ -1934,9 +1912,6 @@ cpp_push_buffer (pfile, buffer, len, from_stage3, return_at_eof)
 
   pfile->buffer = new;
 
-  if (CPP_OPTION (pfile, traditional))
-    _cpp_set_trad_context (pfile);
-
   return new;
 }
 
@@ -1981,9 +1956,6 @@ _cpp_pop_buffer (pfile)
            _cpp_maybe_push_include_file (pfile);
        }
     }
-
-  if (pfile->buffer && CPP_OPTION (pfile, traditional))
-    _cpp_set_trad_context (pfile);
 }
 
 /* Enter all recognised directives in the hash table.  */