OSDN Git Service

Merge from pch-branch up to tag pch-commit-20020603.
[pf3gnuchains/gcc-fork.git] / gcc / cppinit.c
index 70fc828..580ef35 100644 (file)
@@ -28,7 +28,6 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #include "version.h"
 #include "mkdeps.h"
 #include "cppdefault.h"
-#include "except.h"    /* for USING_SJLJ_EXCEPTIONS */
 
 /* Predefined symbols, built-in macros, and the default include path.  */
 
@@ -99,6 +98,7 @@ static void path_include              PARAMS ((cpp_reader *,
                                                 char *, int));
 static void init_library               PARAMS ((void));
 static void init_builtins              PARAMS ((cpp_reader *));
+static void mark_named_operators       PARAMS ((cpp_reader *));
 static void append_include_chain       PARAMS ((cpp_reader *,
                                                 char *, int, int));
 static struct search_path * remove_dup_dir     PARAMS ((cpp_reader *,
@@ -130,14 +130,14 @@ enum { BRACKET = 0, SYSTEM, AFTER };
 
 #define init_trigraph_map()  /* Nothing.  */
 #define TRIGRAPH_MAP \
-__extension__ const U_CHAR _cpp_trigraph_map[UCHAR_MAX + 1] = {
+__extension__ const uchar _cpp_trigraph_map[UCHAR_MAX + 1] = {
 
 #define END };
 #define s(p, v) [p] = v,
 
 #else
 
-#define TRIGRAPH_MAP U_CHAR _cpp_trigraph_map[UCHAR_MAX + 1] = { 0 }; \
+#define TRIGRAPH_MAP uchar _cpp_trigraph_map[UCHAR_MAX + 1] = { 0 }; \
  static void init_trigraph_map PARAMS ((void)) { \
  unsigned char *x = _cpp_trigraph_map;
 
@@ -207,7 +207,7 @@ append_include_chain (pfile, dir, path, cxx_aware)
      cpp_reader *pfile;
      char *dir;
      int path;
-     int cxx_aware ATTRIBUTE_UNUSED;
+     int cxx_aware;
 {
   struct cpp_pending *pend = CPP_OPTION (pfile, pending);
   struct search_path *new;
@@ -225,7 +225,7 @@ append_include_chain (pfile, dir, path, cxx_aware)
     {
       /* Dirs that don't exist are silently ignored.  */
       if (errno != ENOENT)
-       cpp_notice_from_errno (pfile, dir);
+       cpp_errno (pfile, DL_ERROR, dir);
       else if (CPP_OPTION (pfile, verbose))
        fprintf (stderr, _("ignoring nonexistent directory \"%s\"\n"), dir);
       free (dir);
@@ -234,7 +234,7 @@ append_include_chain (pfile, dir, path, cxx_aware)
 
   if (!S_ISDIR (st.st_mode))
     {
-      cpp_notice (pfile, "%s: Not a directory", dir);
+      cpp_error_with_line (pfile, DL_ERROR, 0, 0, "%s: Not a directory", dir);
       free (dir);
       return;
     }
@@ -252,11 +252,7 @@ append_include_chain (pfile, dir, path, cxx_aware)
      include files since these two lists are really just a concatenation
      of one "system" list.  */
   if (path == SYSTEM || path == AFTER)
-#ifdef NO_IMPLICIT_EXTERN_C
-    new->sysp = 1;
-#else
     new->sysp = cxx_aware ? 1 : 2;
-#endif
   else
     new->sysp = 0;
   new->name_map = NULL;
@@ -304,20 +300,20 @@ remove_dup_dirs (pfile, head)
   for (cur = head; cur; cur = cur->next)
     {
       for (other = head; other != cur; other = other->next)
-        if (INO_T_EQ (cur->ino, other->ino) && cur->dev == other->dev)
+       if (INO_T_EQ (cur->ino, other->ino) && cur->dev == other->dev)
          {
            if (cur->sysp && !other->sysp)
              {
-               cpp_warning (pfile,
-                            "changing search order for system directory \"%s\"",
-                            cur->name);
+               cpp_error (pfile, DL_WARNING,
+                          "changing search order for system directory \"%s\"",
+                          cur->name);
                if (strcmp (cur->name, other->name))
-                 cpp_warning (pfile, 
-                              "  as it is the same as non-system directory \"%s\"",
-                              other->name);
+                 cpp_error (pfile, DL_WARNING,
+                            "  as it is the same as non-system directory \"%s\"",
+                            other->name);
                else
-                 cpp_warning (pfile, 
-                              "  as it has already been specified as a non-system directory");
+                 cpp_error (pfile, DL_WARNING,
+                            "  as it has already been specified as a non-system directory");
              }
            cur = remove_dup_dir (pfile, prev);
            break;
@@ -392,7 +388,6 @@ merge_include_chains (pfile)
 struct lang_flags
 {
   char c99;
-  char objc;
   char cplusplus;
   char extended_numbers;
   char trigraphs;
@@ -403,17 +398,15 @@ struct lang_flags
 
 /* ??? Enable $ in identifiers in assembly? */
 static const struct lang_flags lang_defaults[] =
-{ /*              c99 objc c++ xnum trig dollar c++comm digr  */
-  /* GNUC89 */  { 0,  0,   0,  1,   0,   1,     1,      1     },
-  /* GNUC99 */  { 1,  0,   0,  1,   0,   1,     1,      1     },
-  /* STDC89 */  { 0,  0,   0,  0,   1,   0,     0,      0     },
-  /* STDC94 */  { 0,  0,   0,  0,   1,   0,     0,      1     },
-  /* STDC99 */  { 1,  0,   0,  1,   1,   0,     1,      1     },
-  /* GNUCXX */  { 0,  0,   1,  1,   0,   1,     1,      1     },
-  /* CXX98  */  { 0,  0,   1,  1,   1,   0,     1,      1     },
-  /* OBJC   */  { 0,  1,   0,  1,   0,   1,     1,      1     },
-  /* OBJCXX */  { 0,  1,   1,  1,   0,   1,     1,      1     },
-  /* ASM    */  { 0,  0,   0,  1,   0,   0,     1,      0     }
+{ /*              c99 c++ xnum trig dollar c++comm digr  */
+  /* GNUC89 */  { 0,  0,  1,   0,   1,     1,      1     },
+  /* GNUC99 */  { 1,  0,  1,   0,   1,     1,      1     },
+  /* STDC89 */  { 0,  0,  0,   1,   0,     0,      0     },
+  /* STDC94 */  { 0,  0,  0,   1,   0,     0,      1     },
+  /* STDC99 */  { 1,  0,  1,   1,   0,     1,      1     },
+  /* GNUCXX */  { 0,  1,  1,   0,   1,     1,      1     },
+  /* CXX98  */  { 0,  1,  1,   1,   0,     1,      1     },
+  /* ASM    */  { 0,  0,  1,   0,   0,     1,      0     }
 };
 
 /* Sets internal flags correctly for a given language.  */
@@ -423,11 +416,10 @@ set_lang (pfile, lang)
      enum c_lang lang;
 {
   const struct lang_flags *l = &lang_defaults[(int) lang];
-  
+
   CPP_OPTION (pfile, lang) = lang;
 
   CPP_OPTION (pfile, c99)               = l->c99;
-  CPP_OPTION (pfile, objc)              = l->objc;
   CPP_OPTION (pfile, cplusplus)                 = l->cplusplus;
   CPP_OPTION (pfile, extended_numbers)  = l->extended_numbers;
   CPP_OPTION (pfile, trigraphs)                 = l->trigraphs;
@@ -487,19 +479,26 @@ cpp_create_reader (lang)
 
   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;
   CPP_OPTION (pfile, show_column) = 1;
   CPP_OPTION (pfile, tabstop) = 8;
   CPP_OPTION (pfile, operator_names) = 1;
-#if DEFAULT_SIGNED_CHAR
-  CPP_OPTION (pfile, signed_char) = 1;
-#else
-  CPP_OPTION (pfile, signed_char) = 0;
-#endif
+  CPP_OPTION (pfile, warn_endif_labels) = 1;
 
   CPP_OPTION (pfile, pending) =
     (struct cpp_pending *) xcalloc (1, sizeof (struct cpp_pending));
 
+  /* Default CPP arithmetic to something sensible for the host for the
+     benefit of dumb users like fix-header.  */
+  CPP_OPTION (pfile, precision) = CHAR_BIT * sizeof (long);
+  CPP_OPTION (pfile, char_precision) = CHAR_BIT;
+  CPP_OPTION (pfile, wchar_precision) = CHAR_BIT * sizeof (int);
+  CPP_OPTION (pfile, int_precision) = CHAR_BIT * sizeof (int);
+  CPP_OPTION (pfile, unsigned_char) = 0;
+  CPP_OPTION (pfile, unsigned_wchar) = 1;
+
   /* It's simplest to just create this struct whether or not it will
      be needed.  */
   pfile->deps = deps_init ();
@@ -507,7 +506,7 @@ cpp_create_reader (lang)
   /* Initialise the line map.  Start at logical line 1, so we can use
      a line number of zero for special states.  */
   init_line_maps (&pfile->line_maps);
-  pfile->line = 1;
+  pfile->trad_line = pfile->line = 1;
 
   /* Initialize lexer state.  */
   pfile->state.save_comments = ! CPP_OPTION (pfile, discard_comments);
@@ -533,6 +532,9 @@ cpp_create_reader (lang)
   pfile->a_buff = _cpp_get_buff (pfile, 0);
   pfile->u_buff = _cpp_get_buff (pfile, 0);
 
+  /* The expression parser stack.  */
+  _cpp_expand_op_stack (pfile);
+
   /* Initialise the buffer obstack.  */
   gcc_obstack_init (&pfile->buffer_ob);
 
@@ -552,9 +554,16 @@ cpp_destroy (pfile)
   cpp_context *context, *contextn;
   tokenrun *run, *runn;
 
+  free_chain (CPP_OPTION (pfile, pending)->include_head);
+  free (CPP_OPTION (pfile, pending));
+  free (pfile->op_stack);
+
   while (CPP_BUFFER (pfile) != NULL)
     _cpp_pop_buffer (pfile);
 
+  if (pfile->trad_out_base)
+    free (pfile->trad_out_base);
+
   if (pfile->macro_buffer)
     {
       free ((PTR) pfile->macro_buffer);
@@ -601,39 +610,28 @@ cpp_destroy (pfile)
   return result;
 }
 
-
 /* This structure defines one built-in identifier.  A node will be
-   entered in the hash table under the name NAME, with value VALUE (if
-   any).  If flags has OPERATOR, the node's operator field is used; if
-   flags has BUILTIN the node's builtin field is used.  Macros that are
-   known at build time should not be flagged BUILTIN, as then they do
-   not appear in macro dumps with e.g. -dM or -dD.
-
-   Two values are not compile time constants, so we tag
-   them in the FLAGS field instead:
-   VERS                value is the global version_string, quoted
-   ULP         value is the global user_label_prefix
-
-   Also, macros with CPLUS set in the flags field are entered only for C++.  */
+   entered in the hash table under the name NAME, with value VALUE.
+
+   There are two tables of these.  builtin_array holds all the
+   "builtin" macros: these are handled by builtin_macro() in
+   cppmacro.c.  Builtin is somewhat of a misnomer -- the property of
+   interest is that these macros require special code to compute their
+   expansions.  The value is a "builtin_type" enumerator.
+
+   operator_array holds the C++ named operators.  These are keywords
+   which act as aliases for punctuators.  In C++, they cannot be
+   altered through #define, and #if recognizes them as operators.  In
+   C, these are not entered into the hash table at all (but see
+   <iso646.h>).  The value is a token-type enumerator.  */
 struct builtin
 {
-  const U_CHAR *name;
-  const char *value;
-  unsigned char builtin;
-  unsigned char operator;
-  unsigned short flags;
+  const uchar *name;
   unsigned short len;
+  unsigned short value;
 };
-#define VERS           0x01
-#define ULP            0x02
-#define CPLUS          0x04
-#define BUILTIN                0x08
-#define OPERATOR       0x10
-
-#define B(n, t)       { U n, 0, t, 0, BUILTIN, sizeof n - 1 }
-#define C(n, v)       { U n, v, 0, 0, 0, sizeof n - 1 }
-#define X(n, f)       { U n, 0, 0, 0, f, sizeof n - 1 }
-#define O(n, c, f)    { U n, 0, 0, c, OPERATOR | f, sizeof n - 1 }
+
+#define B(n, t)    { DSC(n), t }
 static const struct builtin builtin_array[] =
 {
   B("__TIME__",                 BT_TIME),
@@ -643,55 +641,41 @@ static const struct builtin builtin_array[] =
   B("__LINE__",                 BT_SPECLINE),
   B("__INCLUDE_LEVEL__", BT_INCLUDE_LEVEL),
   B("_Pragma",          BT_PRAGMA),
-
-  X("__VERSION__",             VERS),
-  X("__USER_LABEL_PREFIX__",   ULP),
-  C("__REGISTER_PREFIX__",     REGISTER_PREFIX),
-  C("__HAVE_BUILTIN_SETJMP__", "1"),
-#if USING_SJLJ_EXCEPTIONS
-  /* libgcc needs to know this.  */
-  C("__USING_SJLJ_EXCEPTIONS__","1"),
-#endif
-#ifndef NO_BUILTIN_SIZE_TYPE
-  C("__SIZE_TYPE__",           SIZE_TYPE),
-#endif
-#ifndef NO_BUILTIN_PTRDIFF_TYPE
-  C("__PTRDIFF_TYPE__",                PTRDIFF_TYPE),
-#endif
-#ifndef NO_BUILTIN_WCHAR_TYPE
-  C("__WCHAR_TYPE__",          WCHAR_TYPE),
-#endif
-#ifndef NO_BUILTIN_WINT_TYPE
-  C("__WINT_TYPE__",           WINT_TYPE),
-#endif
-#ifdef STDC_0_IN_SYSTEM_HEADERS
   B("__STDC__",                 BT_STDC),
-#else
-  C("__STDC__",                 "1"),
-#endif
+};
 
-  /* Named operators known to the preprocessor.  These cannot be #defined
-     and always have their stated meaning.  They are treated like normal
-     identifiers except for the type code and the meaning.  Most of them
-     are only for C++ (but see iso646.h).  */
-  O("and",     CPP_AND_AND, CPLUS),
-  O("and_eq",  CPP_AND_EQ,  CPLUS),
-  O("bitand",  CPP_AND,     CPLUS),
-  O("bitor",   CPP_OR,      CPLUS),
-  O("compl",   CPP_COMPL,   CPLUS),
-  O("not",     CPP_NOT,     CPLUS),
-  O("not_eq",  CPP_NOT_EQ,  CPLUS),
-  O("or",      CPP_OR_OR,   CPLUS),
-  O("or_eq",   CPP_OR_EQ,   CPLUS),
-  O("xor",     CPP_XOR,     CPLUS),
-  O("xor_eq",  CPP_XOR_EQ,  CPLUS)
+static const struct builtin operator_array[] =
+{
+  B("and",     CPP_AND_AND),
+  B("and_eq",  CPP_AND_EQ),
+  B("bitand",  CPP_AND),
+  B("bitor",   CPP_OR),
+  B("compl",   CPP_COMPL),
+  B("not",     CPP_NOT),
+  B("not_eq",  CPP_NOT_EQ),
+  B("or",      CPP_OR_OR),
+  B("or_eq",   CPP_OR_EQ),
+  B("xor",     CPP_XOR),
+  B("xor_eq",  CPP_XOR_EQ)
 };
 #undef B
-#undef C
-#undef X
-#undef O
-#define builtin_array_end \
- builtin_array + sizeof(builtin_array)/sizeof(struct builtin)
+
+/* Mark the C++ named operators in the hash table.  */
+static void
+mark_named_operators (pfile)
+     cpp_reader *pfile;
+{
+  const struct builtin *b;
+
+  for (b = operator_array;
+       b < (operator_array + ARRAY_SIZE (operator_array));
+       b++)
+    {
+      cpp_hashnode *hp = cpp_lookup (pfile, b->name, b->len);
+      hp->flags |= NODE_OPERATOR;
+      hp->value.operator = b->value;
+    }
+}
 
 /* Subroutine of cpp_read_main_file; reads the builtins table above and
    enters them, and language-specific macros, into the hash table.  */
@@ -701,88 +685,31 @@ init_builtins (pfile)
 {
   const struct builtin *b;
 
-  for(b = builtin_array; b < builtin_array_end; b++)
+  for(b = builtin_array;
+      b < (builtin_array + ARRAY_SIZE (builtin_array));
+      b++)
     {
-      if ((b->flags & CPLUS) && ! CPP_OPTION (pfile, cplusplus))
-       continue;
-
-      if ((b->flags & OPERATOR) && ! CPP_OPTION (pfile, operator_names))
-       continue;
-
-      if (b->flags & (OPERATOR | BUILTIN))
-       {
-         cpp_hashnode *hp = cpp_lookup (pfile, b->name, b->len);
-         if (b->flags & OPERATOR)
-           {
-             hp->flags |= NODE_OPERATOR;
-             hp->value.operator = b->operator;
-           }
-         else
-           {
-             hp->type = NT_MACRO;
-             hp->flags |= NODE_BUILTIN | NODE_WARN;
-             hp->value.builtin = b->builtin;
-           }
-       }
-      else                     /* A standard macro of some kind.  */
-       {
-         const char *val;
-         char *str;
-
-         if (b->flags & VERS)
-           {
-             /* Allocate enough space for 'name "value"\n\0'.  */
-             str = alloca (b->len + strlen (version_string) + 5);
-             sprintf (str, "%s \"%s\"\n", b->name, version_string);
-           }
-         else
-           {
-             if (b->flags & ULP)
-               val = CPP_OPTION (pfile, user_label_prefix);
-             else
-               val = b->value;
-
-             /* Allocate enough space for "name value\n\0".  */
-             str = alloca (b->len + strlen (val) + 3);
-             sprintf(str, "%s %s\n", b->name, val);
-           }
-
-         _cpp_define_builtin (pfile, str);
-       }
+      cpp_hashnode *hp = cpp_lookup (pfile, b->name, b->len);
+      hp->type = NT_MACRO;
+      hp->flags |= NODE_BUILTIN | NODE_WARN;
+      hp->value.builtin = b->value;
     }
 
   if (CPP_OPTION (pfile, cplusplus))
-    {
-      _cpp_define_builtin (pfile, "__cplusplus 1");
-      if (SUPPORTS_ONE_ONLY)
-       _cpp_define_builtin (pfile, "__GXX_WEAK__ 1");
-      else
-       _cpp_define_builtin (pfile, "__GXX_WEAK__ 0");
-    }
-  if (CPP_OPTION (pfile, objc))
+    _cpp_define_builtin (pfile, "__cplusplus 1");
+  else if (CPP_OPTION (pfile, objc))
     _cpp_define_builtin (pfile, "__OBJC__ 1");
+  else if (CPP_OPTION (pfile, lang) == CLK_ASM)
+    _cpp_define_builtin (pfile, "__ASSEMBLER__ 1");
 
   if (CPP_OPTION (pfile, lang) == CLK_STDC94)
     _cpp_define_builtin (pfile, "__STDC_VERSION__ 199409L");
   else if (CPP_OPTION (pfile, c99))
     _cpp_define_builtin (pfile, "__STDC_VERSION__ 199901L");
 
-  if (CPP_OPTION (pfile, signed_char) == 0)
-    _cpp_define_builtin (pfile, "__CHAR_UNSIGNED__ 1");
-
-  if (CPP_OPTION (pfile, lang) == CLK_STDC89
-      || CPP_OPTION (pfile, lang) == CLK_STDC94
-      || CPP_OPTION (pfile, lang) == CLK_STDC99)
-    _cpp_define_builtin (pfile, "__STRICT_ANSI__ 1");
-  else if (CPP_OPTION (pfile, lang) == CLK_ASM)
-    _cpp_define_builtin (pfile, "__ASSEMBLER__ 1");
+  if (pfile->cb.register_builtins)
+    (*pfile->cb.register_builtins) (pfile);
 }
-#undef BUILTIN
-#undef OPERATOR
-#undef VERS
-#undef ULP
-#undef CPLUS
-#undef builtin_array_end
 
 /* And another subroutine.  This one sets up the standard include path.  */
 static void
@@ -908,6 +835,57 @@ free_chain (head)
     }
 }
 
+/* Sanity-checks are dependent on command-line options, so it is
+   called as a subroutine of cpp_read_main_file ().  */
+#if ENABLE_CHECKING
+static void sanity_checks PARAMS ((cpp_reader *));
+static void sanity_checks (pfile)
+     cpp_reader *pfile;
+{
+  cppchar_t test = 0;
+  size_t max_precision = 2 * CHAR_BIT * sizeof (cpp_num_part);
+
+  /* Sanity checks for assumptions about CPP arithmetic and target
+     type precisions made by cpplib.  */
+  test--;
+  if (test < 1)
+    cpp_error (pfile, DL_ICE, "cppchar_t must be an unsigned type");
+
+  if (CPP_OPTION (pfile, precision) > max_precision)
+    cpp_error (pfile, DL_ICE,
+              "preprocessor arithmetic has maximum precision of %lu bits; target requires %lu bits",
+              (unsigned long) max_precision,
+              (unsigned long) CPP_OPTION (pfile, precision));
+
+  if (CPP_OPTION (pfile, precision) < CPP_OPTION (pfile, int_precision))
+    cpp_error (pfile, DL_ICE,
+              "CPP arithmetic must be at least as precise as a target int");
+
+  if (CPP_OPTION (pfile, char_precision) < 8)
+    cpp_error (pfile, DL_ICE, "target char is less than 8 bits wide");
+
+  if (CPP_OPTION (pfile, wchar_precision) < CPP_OPTION (pfile, char_precision))
+    cpp_error (pfile, DL_ICE,
+              "target wchar_t is narrower than target char");
+
+  if (CPP_OPTION (pfile, int_precision) < CPP_OPTION (pfile, char_precision))
+    cpp_error (pfile, DL_ICE,
+              "target int is narrower than target char");
+
+  /* This is assumed in eval_token() and could be fixed if necessary.  */
+  if (sizeof (cppchar_t) > sizeof (cpp_num_part))
+    cpp_error (pfile, DL_ICE, "CPP half-integer narrower than CPP character");
+
+  if (CPP_OPTION (pfile, wchar_precision) > BITS_PER_CPPCHAR_T)
+    cpp_error (pfile, DL_ICE,
+              "CPP on this host cannot handle wide character constants over %lu bits, but the target requires %lu bits",
+              (unsigned long) BITS_PER_CPPCHAR_T,
+              (unsigned long) CPP_OPTION (pfile, wchar_precision));
+}
+#else
+# define sanity_checks(PFILE)
+#endif
+
 /* This is called after options have been parsed, and partially
    processed.  Setup for processing input from the file named FNAME,
    or stdin if it is the empty string.  Return the original filename
@@ -918,6 +896,8 @@ cpp_read_main_file (pfile, fname, table)
      const char *fname;
      hash_table *table;
 {
+  sanity_checks (pfile);
+
   /* The front ends don't set up the hash table until they have
      finished processing the command line options, so initializing the
      hashtable is deferred until now.  */
@@ -960,6 +940,9 @@ cpp_read_main_file (pfile, fname, table)
      of the front ends.  */
   if (CPP_OPTION (pfile, preprocessed))
     read_original_filename (pfile);
+  /* Overlay an empty buffer to seed traditional preprocessing.  */
+  else if (CPP_OPTION (pfile, traditional))
+    _cpp_overlay_buffer (pfile, U"", 0);
 
   return pfile->map->to_file;
 }
@@ -1001,6 +984,10 @@ void
 cpp_finish_options (pfile)
      cpp_reader *pfile;
 {
+  /* Mark named operators before handling command line macros.  */
+  if (CPP_OPTION (pfile, cplusplus) && CPP_OPTION (pfile, operator_names))
+    mark_named_operators (pfile);
+
   /* Install builtins and process command line macros etc. in the order
      they appeared, but only if not already preprocessed.  */
   if (! CPP_OPTION (pfile, preprocessed))
@@ -1008,70 +995,51 @@ cpp_finish_options (pfile)
       struct pending_option *p;
 
       _cpp_do_file_change (pfile, LC_RENAME, _("<built-in>"), 1, 0);
-      init_builtins (pfile);
+      if (!CPP_OPTION (pfile, traditional) /* REMOVEME */)
+       init_builtins (pfile);
       _cpp_do_file_change (pfile, LC_RENAME, _("<command line>"), 1, 0);
-      for (p = CPP_OPTION (pfile, pending)->directive_head; p; p = p->next)
-       (*p->handler) (pfile, p->arg);
-
-      /* Scan -imacros files after command line defines, but before
-        files given with -include.  */
-      while ((p = CPP_OPTION (pfile, pending)->imacros_head) != NULL)
-       {
-         if (push_include (pfile, p))
-           {
-             pfile->buffer->return_at_eof = true;
-             cpp_scan_nooutput (pfile);
-           }
-         CPP_OPTION (pfile, pending)->imacros_head = p->next;
-         free (p);
-       }
+      if (!CPP_OPTION (pfile, traditional) /* REMOVEME */)
+       for (p = CPP_OPTION (pfile, pending)->directive_head; p; p = p->next)
+         (*p->handler) (pfile, p->arg);
+
+      /* Scan -imacros files after -D, -U, but before -include.
+        pfile->next_include_file is NULL, so _cpp_pop_buffer does not
+        push -include files.  */
+      for (p = CPP_OPTION (pfile, pending)->imacros_head; p; p = p->next)
+       if (push_include (pfile, p))
+         cpp_scan_nooutput (pfile);
+
+      pfile->next_include_file = &CPP_OPTION (pfile, pending)->include_head;
+      _cpp_maybe_push_include_file (pfile);
     }
 
+  free_chain (CPP_OPTION (pfile, pending)->imacros_head);
   free_chain (CPP_OPTION (pfile, pending)->directive_head);
-  _cpp_push_next_buffer (pfile);
 }
 
-/* Called to push the next buffer on the stack given by -include.  If
-   there are none, free the pending structure and restore the line map
-   for the main file.  */
-bool
-_cpp_push_next_buffer (pfile)
+/* Push the next buffer on the stack given by -include, if any.  */
+void
+_cpp_maybe_push_include_file (pfile)
      cpp_reader *pfile;
 {
-  bool pushed = false;
-
-  /* This is't pretty; we'd rather not be relying on this as a boolean
-     for reverting the line map.  Further, we only free the chains in
-     this conditional, so an early call to cpp_finish / cpp_destroy
-     will leak that memory.  */
-  if (CPP_OPTION (pfile, pending)
-      && CPP_OPTION (pfile, pending)->imacros_head == NULL)
+  if (pfile->next_include_file)
     {
-      while (!pushed)
-       {
-         struct pending_option *p = CPP_OPTION (pfile, pending)->include_head;
+      struct pending_option *head = *pfile->next_include_file;
 
-         if (p == NULL)
-           break;
-         if (! CPP_OPTION (pfile, preprocessed))
-           pushed = push_include (pfile, p);
-         CPP_OPTION (pfile, pending)->include_head = p->next;
-         free (p);
-       }
+      while (head && !push_include (pfile, head))
+       head = head->next;
 
-      if (!pushed)
+      if (head)
+       pfile->next_include_file = &head->next;
+      else
        {
-         free (CPP_OPTION (pfile, pending));
-         CPP_OPTION (pfile, pending) = NULL;
-
-         /* Restore the line map for the main file.  */
-         if (! CPP_OPTION (pfile, preprocessed))
-           _cpp_do_file_change (pfile, LC_RENAME,
-                                pfile->line_maps.maps[0].to_file, 1, 0);
+         /* All done; restore the line map from <command line>.  */
+         _cpp_do_file_change (pfile, LC_RENAME,
+                              pfile->line_maps.maps[0].to_file, 1, 0);
+         /* Don't come back here again.  */
+         pfile->next_include_file = NULL;
        }
     }
-
-  return pushed;
 }
 
 /* Use mkdeps.c to output dependency information.  */
@@ -1091,7 +1059,7 @@ output_deps (pfile)
       deps_stream = fopen (CPP_OPTION (pfile, deps_file), deps_mode);
       if (deps_stream == 0)
        {
-         cpp_notice_from_errno (pfile, CPP_OPTION (pfile, deps_file));
+         cpp_errno (pfile, DL_ERROR, CPP_OPTION (pfile, deps_file));
          return;
        }
     }
@@ -1105,7 +1073,7 @@ output_deps (pfile)
   if (deps_stream != stdout)
     {
       if (ferror (deps_stream) || fclose (deps_stream) != 0)
-       cpp_fatal (pfile, "I/O error on output");
+       cpp_error (pfile, DL_ERROR, "I/O error on output");
     }
 }
 
@@ -1166,12 +1134,12 @@ new_pending_directive (pend, text, handler)
    "-" removed.  It must be sorted in ASCII collating order.  */
 #define COMMAND_LINE_OPTIONS                                                  \
   DEF_OPT("$",                        0,      OPT_dollar)                     \
-  DEF_OPT("+",                        0,      OPT_plus)                       \
   DEF_OPT("-help",                    0,      OPT__help)                      \
   DEF_OPT("-target-help",             0,      OPT_target__help)               \
   DEF_OPT("-version",                 0,      OPT__version)                   \
   DEF_OPT("A",                        no_ass, OPT_A)                          \
   DEF_OPT("C",                        0,      OPT_C)                          \
+  DEF_OPT("CC",                       0,      OPT_CC)                         \
   DEF_OPT("D",                        no_mac, OPT_D)                          \
   DEF_OPT("H",                        0,      OPT_H)                          \
   DEF_OPT("I",                        no_dir, OPT_I)                          \
@@ -1188,16 +1156,12 @@ new_pending_directive (pend, text, handler)
   DEF_OPT("U",                        no_mac, OPT_U)                          \
   DEF_OPT("W",                        no_arg, OPT_W)  /* arg optional */      \
   DEF_OPT("d",                        no_arg, OPT_d)                          \
-  DEF_OPT("fleading-underscore",      0,      OPT_fleading_underscore)        \
-  DEF_OPT("fno-leading-underscore",   0,      OPT_fno_leading_underscore)     \
   DEF_OPT("fno-operator-names",       0,      OPT_fno_operator_names)         \
   DEF_OPT("fno-preprocessed",         0,      OPT_fno_preprocessed)           \
   DEF_OPT("fno-show-column",          0,      OPT_fno_show_column)            \
   DEF_OPT("fpreprocessed",            0,      OPT_fpreprocessed)              \
   DEF_OPT("fshow-column",             0,      OPT_fshow_column)               \
-  DEF_OPT("fsigned-char",             0,      OPT_fsigned_char)               \
   DEF_OPT("ftabstop=",                no_num, OPT_ftabstop)                   \
-  DEF_OPT("funsigned-char",           0,      OPT_funsigned_char)             \
   DEF_OPT("h",                        0,      OPT_h)                          \
   DEF_OPT("idirafter",                no_dir, OPT_idirafter)                  \
   DEF_OPT("imacros",                  no_fil, OPT_imacros)                    \
@@ -1211,7 +1175,6 @@ new_pending_directive (pend, text, handler)
   DEF_OPT("lang-c++",                 0,      OPT_lang_cplusplus)             \
   DEF_OPT("lang-c89",                 0,      OPT_lang_c89)                   \
   DEF_OPT("lang-objc",                0,      OPT_lang_objc)                  \
-  DEF_OPT("lang-objc++",              0,      OPT_lang_objcplusplus)          \
   DEF_OPT("nostdinc",                 0,      OPT_nostdinc)                   \
   DEF_OPT("nostdinc++",               0,      OPT_nostdincplusplus)           \
   DEF_OPT("o",                        no_fil, OPT_o)                          \
@@ -1229,6 +1192,7 @@ new_pending_directive (pend, text, handler)
   DEF_OPT("std=iso9899:199409",       0,      OPT_std_iso9899_199409)         \
   DEF_OPT("std=iso9899:1999",         0,      OPT_std_iso9899_1999)           \
   DEF_OPT("std=iso9899:199x",         0,      OPT_std_iso9899_199x)           \
+  DEF_OPT("traditional-cpp",         0,      OPT_traditional_cpp)            \
   DEF_OPT("trigraphs",                0,      OPT_trigraphs)                  \
   DEF_OPT("v",                        0,      OPT_v)                          \
   DEF_OPT("version",                  0,      OPT_version)                    \
@@ -1348,7 +1312,8 @@ cpp_handle_option (pfile, argc, argv, ignore)
       else if (CPP_OPTION (pfile, out_fname) == NULL)
        CPP_OPTION (pfile, out_fname) = argv[i];
       else
-       cpp_fatal (pfile, "too many filenames. Type %s --help for usage info",
+       cpp_error (pfile, DL_ERROR,
+                  "too many filenames. Type %s --help for usage info",
                   progname);
     }
   else
@@ -1375,7 +1340,8 @@ cpp_handle_option (pfile, argc, argv, ignore)
              arg = argv[++i];
              if (!arg)
                {
-                 cpp_fatal (pfile, cl_options[opt_index].msg, argv[i - 1]);
+                 cpp_error (pfile, DL_ERROR,
+                            cl_options[opt_index].msg, argv[i - 1]);
                  return argc;
                }
            }
@@ -1385,12 +1351,6 @@ cpp_handle_option (pfile, argc, argv, ignore)
        {
        case N_OPTS: /* Shut GCC up.  */
          break;
-       case OPT_fleading_underscore:
-         CPP_OPTION (pfile, user_label_prefix) = "_";
-         break;
-       case OPT_fno_leading_underscore:
-         CPP_OPTION (pfile, user_label_prefix) = "";
-         break;
        case OPT_fno_operator_names:
          CPP_OPTION (pfile, operator_names) = 0;
          break;
@@ -1406,12 +1366,6 @@ cpp_handle_option (pfile, argc, argv, ignore)
        case OPT_fno_show_column:
          CPP_OPTION (pfile, show_column) = 0;
          break;
-       case OPT_fsigned_char:
-         CPP_OPTION (pfile, signed_char) = 1;
-         break;
-       case OPT_funsigned_char:
-         CPP_OPTION (pfile, signed_char) = 0;
-         break;
        case OPT_ftabstop:
          /* Silently ignore empty string, non-longs and silly values.  */
          if (arg[0] != '\0')
@@ -1431,10 +1385,10 @@ cpp_handle_option (pfile, argc, argv, ignore)
          CPP_OPTION (pfile, help_only) = 1;
          break;
        case OPT_target__help:
-          /* Print if any target specific options. cpplib has none, but
+         /* Print if any target specific options. cpplib has none, but
             make sure help_only gets set.  */
          CPP_OPTION (pfile, help_only) = 1;
-          break;
+         break;
 
          /* --version inhibits compilation, -version doesn't. -v means
             verbose and -version.  Historical reasons, don't ask.  */
@@ -1453,6 +1407,10 @@ cpp_handle_option (pfile, argc, argv, ignore)
        case OPT_C:
          CPP_OPTION (pfile, discard_comments) = 0;
          break;
+       case OPT_CC:
+         CPP_OPTION (pfile, discard_comments) = 0;
+         CPP_OPTION (pfile, discard_comments_in_macro_exp) = 0;
+         break;
        case OPT_P:
          CPP_OPTION (pfile, no_line_commands) = 1;
          break;
@@ -1469,18 +1427,18 @@ cpp_handle_option (pfile, argc, argv, ignore)
          CPP_OPTION (pfile, pedantic_errors) = 1;
          /* fall through */
        case OPT_pedantic:
-         CPP_OPTION (pfile, pedantic) = 1;
+         CPP_OPTION (pfile, pedantic) = 1;
+         CPP_OPTION (pfile, warn_endif_labels) = 1;
          break;
        case OPT_trigraphs:
-         CPP_OPTION (pfile, trigraphs) = 1;
-         break;
-       case OPT_plus:
-         CPP_OPTION (pfile, cplusplus) = 1;
-         CPP_OPTION (pfile, cplusplus_comments) = 1;
+         CPP_OPTION (pfile, trigraphs) = 1;
          break;
        case OPT_remap:
          CPP_OPTION (pfile, remap) = 1;
          break;
+       case OPT_traditional_cpp:
+         CPP_OPTION (pfile, traditional) = 1;
+         break;
        case OPT_iprefix:
          CPP_OPTION (pfile, include_prefix) = arg;
          CPP_OPTION (pfile, include_prefix_len) = strlen (arg);
@@ -1492,10 +1450,7 @@ cpp_handle_option (pfile, argc, argv, ignore)
          set_lang (pfile, CLK_GNUCXX);
          break;
        case OPT_lang_objc:
-         set_lang (pfile, CLK_OBJC);
-         break;
-       case OPT_lang_objcplusplus:
-         set_lang (pfile, CLK_OBJCXX);
+         CPP_OPTION (pfile, objc) = 1;
          break;
        case OPT_lang_asm:
          set_lang (pfile, CLK_ASM);
@@ -1538,7 +1493,7 @@ cpp_handle_option (pfile, argc, argv, ignore)
            CPP_OPTION (pfile, out_fname) = arg;
          else
            {
-             cpp_fatal (pfile, "output filename specified twice");
+             cpp_error (pfile, DL_ERROR, "output filename specified twice");
              return argc;
            }
          break;
@@ -1546,15 +1501,14 @@ cpp_handle_option (pfile, argc, argv, ignore)
          /* Args to -d specify what parts of macros to dump.
             Silently ignore unrecognised options; they may
             be aimed at the compiler proper.  */
-         {
+         {
            char c;
 
            while ((c = *arg++) != '\0')
-             switch (c)
-               {
-               case 'M':
+             switch (c)
+               {
+               case 'M':
                  CPP_OPTION (pfile, dump_macros) = dump_only;
-                 CPP_OPTION (pfile, no_output) = 1;
                  break;
                case 'N':
                  CPP_OPTION (pfile, dump_macros) = dump_names;
@@ -1573,15 +1527,21 @@ cpp_handle_option (pfile, argc, argv, ignore)
          CPP_OPTION (pfile, print_deps_missing_files) = 1;
          break;
        case OPT_M:
+         /* When doing dependencies with -M or -MM, suppress normal
+            preprocessed output, but still do -dM etc. as software
+            depends on this.  Preprocessed output occurs if -MD, -MMD
+            or environment var dependency generation is used.  */
          CPP_OPTION (pfile, print_deps) = 2;
+         CPP_OPTION (pfile, no_output) = 1;
          break;
        case OPT_MM:
          CPP_OPTION (pfile, print_deps) = 1;
+         CPP_OPTION (pfile, no_output) = 1;
          break;
        case OPT_MF:
          CPP_OPTION (pfile, deps_file) = arg;
          break;
-       case OPT_MP:
+       case OPT_MP:
          CPP_OPTION (pfile, deps_phony_targets) = 1;
          break;
        case OPT_MQ:
@@ -1590,12 +1550,6 @@ cpp_handle_option (pfile, argc, argv, ignore)
          deps_add_target (pfile->deps, arg, opt_code == OPT_MQ);
          break;
 
-         /* -MD and -MMD for cpp0 are deprecated and undocumented
-            (use -M or -MM with -MF instead), and probably should be
-            removed with the next major GCC version.  For the moment
-            we allow these for the benefit of Automake 1.4, which
-            uses these when dependency tracking is enabled.  Automake
-            1.5 will fix this.  */
        case OPT_MD:
          CPP_OPTION (pfile, print_deps) = 2;
          CPP_OPTION (pfile, deps_file) = arg;
@@ -1633,7 +1587,7 @@ cpp_handle_option (pfile, argc, argv, ignore)
          break;
        case OPT_I:           /* Add directory to path for includes.  */
          if (!strcmp (arg, "-"))
-           {
+           {
              /* -I- means:
                 Use the preceding -I directories for #include "..."
                 but not #include <...>.
@@ -1650,11 +1604,11 @@ cpp_handle_option (pfile, argc, argv, ignore)
                }
              else
                {
-                 cpp_fatal (pfile, "-I- specified twice");
+                 cpp_error (pfile, DL_ERROR, "-I- specified twice");
                  return argc;
                }
-           }
-         else
+           }
+         else
            append_include_chain (pfile, xstrdup (arg), BRACKET, 0);
          break;
        case OPT_isystem:
@@ -1736,6 +1690,8 @@ cpp_handle_option (pfile, argc, argv, ignore)
            CPP_OPTION (pfile, warnings_are_errors) = 1;
          else if (!strcmp (argv[i], "-Wsystem-headers"))
            CPP_OPTION (pfile, warn_system_headers) = 1;
+         else if (!strcmp (argv[i], "-Wendif-labels"))
+           CPP_OPTION (pfile, warn_endif_labels) = 1;
          else if (!strcmp (argv[i], "-Wno-traditional"))
            CPP_OPTION (pfile, warn_traditional) = 0;
          else if (!strcmp (argv[i], "-Wno-trigraphs"))
@@ -1752,10 +1708,12 @@ cpp_handle_option (pfile, argc, argv, ignore)
            CPP_OPTION (pfile, warnings_are_errors) = 0;
          else if (!strcmp (argv[i], "-Wno-system-headers"))
            CPP_OPTION (pfile, warn_system_headers) = 0;
+         else if (!strcmp (argv[i], "-Wno-endif-labels"))
+           CPP_OPTION (pfile, warn_endif_labels) = 0;
          else if (! ignore)
            return i;
          break;
-       }
+       }
     }
   return i + 1;
 }
@@ -1812,14 +1770,37 @@ cpp_post_options (pfile)
   if (CPP_OPTION (pfile, cplusplus))
     CPP_OPTION (pfile, warn_traditional) = 0;
 
-  /* Set this if it hasn't been set already.  */
-  if (CPP_OPTION (pfile, user_label_prefix) == NULL)
-    CPP_OPTION (pfile, user_label_prefix) = USER_LABEL_PREFIX;
+  /* The compiler front ends override this, but I think this is the
+     appropriate setting for the library.  */
+  CPP_OPTION (pfile, warn_long_long) = (CPP_OPTION (pfile, pedantic)
+                                       && !CPP_OPTION (pfile, c99));
 
   /* Permanently disable macro expansion if we are rescanning
-     preprocessed text.  */
+     preprocessed text.  Read preprocesed source in ISO mode.  */
   if (CPP_OPTION (pfile, preprocessed))
-    pfile->state.prevent_expansion = 1;
+    {
+      pfile->state.prevent_expansion = 1;
+      CPP_OPTION (pfile, traditional) = 0;
+    }
+
+  /* Traditional CPP does not accurately track column information.  */
+  if (CPP_OPTION (pfile, traditional))
+    CPP_OPTION (pfile, show_column) = 0;
+
+  /* -dM makes no normal output.  This is set here so that -dM -dD
+     works as expected.  */
+  if (CPP_OPTION (pfile, dump_macros) == dump_only)
+    CPP_OPTION (pfile, no_output) = 1;
+
+  /* Disable -dD, -dN and -dI if we should make no normal output
+     (such as with -M). Allow -M -dM since some software relies on
+     this.  */
+  if (CPP_OPTION (pfile, no_output))
+    {
+      if (CPP_OPTION (pfile, dump_macros) != dump_only)
+       CPP_OPTION (pfile, dump_macros) = dump_none;
+      CPP_OPTION (pfile, dump_includes) = 0;
+    }
 
   /* We need to do this after option processing and before
      cpp_start_read, as cppmain.c relies on the options->no_output to
@@ -1832,7 +1813,8 @@ cpp_post_options (pfile)
       (CPP_OPTION (pfile, print_deps_missing_files)
        || CPP_OPTION (pfile, deps_file)
        || CPP_OPTION (pfile, deps_phony_targets)))
-    cpp_fatal (pfile, "you must additionally specify either -M or -MM");
+    cpp_error (pfile, DL_ERROR,
+              "you must additionally specify either -M or -MM");
 }
 
 /* Set up dependency-file output.  On exit, if print_deps is non-zero
@@ -1882,22 +1864,15 @@ init_dependency_output (pfile)
       CPP_OPTION (pfile, print_deps_append) = 1;
     }
   else if (CPP_OPTION (pfile, deps_file) == 0)
-    /* If -M or -MM was seen, default output to wherever was specified
-       with -o.  out_fname is non-NULL here.  */
+    /* If -M or -MM was seen without -MF, default output to wherever
+       was specified with -o.  out_fname is non-NULL here.  */
     CPP_OPTION (pfile, deps_file) = CPP_OPTION (pfile, out_fname);
-
-  /* When doing dependencies, we should suppress all output, including
-     -dM, -dI etc.  */
-  CPP_OPTION (pfile, no_output) = 1;
-  CPP_OPTION (pfile, dump_macros) = 0;
-  CPP_OPTION (pfile, dump_includes) = 0;
 }
 
 /* Handle --help output.  */
 static void
 print_help ()
 {
-  fprintf (stderr, _("Usage: %s [switches] input output\n"), progname);
   /* To keep the lines from getting too long for some compilers, limit
      to about 500 characters (6 lines) per chunk.  */
   fputs (_("\
@@ -1928,14 +1903,12 @@ Switches:\n\
   fputs (_("\
   -lang-c++                 Assume that the input sources are in C++\n\
   -lang-objc                Assume that the input sources are in ObjectiveC\n\
-  -lang-objc++              Assume that the input sources are in ObjectiveC++\n\
   -lang-asm                 Assume that the input sources are in assembler\n\
 "), stdout);
   fputs (_("\
   -std=<std name>           Specify the conformance standard; one of:\n\
                             gnu89, gnu99, c89, c99, iso9899:1990,\n\
                             iso9899:199409, iso9899:1999\n\
-  -+                        Allow parsing of C++ style features\n\
   -w                        Inhibit warning messages\n\
   -Wtrigraphs               Warn if trigraphs are encountered\n\
   -Wno-trigraphs            Do not warn about trigraphs\n\
@@ -1960,6 +1933,8 @@ Switches:\n\
   fputs (_("\
   -M                        Generate make dependencies\n\
   -MM                       As -M, but ignore system header files\n\
+  -MD                       Generate make dependencies and compile\n\
+  -MMD                      As -MD, but ignore system header files\n\
   -MF <file>                Write dependency output to the given file\n\
   -MG                       Treat missing header file as generated files\n\
 "), stdout);
@@ -1971,8 +1946,8 @@ Switches:\n\
   fputs (_("\
   -D<macro>                 Define a <macro> with string '1' as its value\n\
   -D<macro>=<val>           Define a <macro> with <val> as its value\n\
-  -A<question> (<answer>)   Assert the <answer> to <question>\n\
-  -A-<question> (<answer>)  Disable the <answer> to <question>\n\
+  -A<question>=<answer>     Assert the <answer> to <question>\n\
+  -A-<question>=<answer>    Disable the <answer> to <question>\n\
   -U<macro>                 Undefine <macro> \n\
   -v                        Display the version number\n\
 "), stdout);
@@ -1989,7 +1964,7 @@ Switches:\n\
   -ftabstop=<number>        Distance between tab stops for column reporting\n\
   -P                        Do not generate #line directives\n\
   -$                        Do not allow '$' in identifiers\n\
-  -remap                    Remap file names when including files.\n\
+  -remap                    Remap file names when including files\n\
   --version                 Display version information\n\
   -h or --help              Display this information\n\
 "), stdout);