Ignore:
Timestamp:
Apr 28, 2004, 6:58:06 AM (21 years ago)
Author:
bird
Message:

#1040: Joined the GCC 3.3.3 with the trunk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gcc/gcc/cppinit.c

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r1393 r1394  
    11/* CPP Library.
    22   Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
    3    1999, 2000, 2001, 2002 Free Software Foundation, Inc.
     3   1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
    44   Contributed by Per Bothner, 1994-95.
    55   Based on CCCP program by Paul Rubin, June 1986
     
    2626#include "prefix.h"
    2727#include "intl.h"
    28 #include "version.h"
    2928#include "mkdeps.h"
    3029#include "cppdefault.h"
    31 #include "except.h"     /* for USING_SJLJ_EXCEPTIONS */
    32 
    33 /* Predefined symbols, built-in macros, and the default include path.  */
    34 
    35 #ifndef GET_ENV_PATH_LIST
    36 #define GET_ENV_PATH_LIST(VAR,NAME)     do { (VAR) = getenv (NAME); } while (0)
    37 #endif
    3830
    3931/* Windows does not natively support inodes, and neither does MSDOS.
     
    9587#endif
    9688
    97 static void print_help                  PARAMS ((void));
    9889static void path_include                PARAMS ((cpp_reader *,
    9990                                                 char *, int));
     
    115106                                                 struct pending_option *));
    116107static void free_chain                  PARAMS ((struct pending_option *));
    117 static void set_lang                    PARAMS ((cpp_reader *, enum c_lang));
    118 static void init_dependency_output      PARAMS ((cpp_reader *));
    119108static void init_standard_includes      PARAMS ((cpp_reader *));
    120109static void read_original_filename      PARAMS ((cpp_reader *));
     
    122111                                                 const char *,
    123112                                                 cl_directive_handler));
    124 static void output_deps                 PARAMS ((cpp_reader *));
    125113static int parse_option                 PARAMS ((const char *));
     114static void post_options                PARAMS ((cpp_reader *));
    126115
    127116/* Fourth argument to append_include_chain: chain to use.
     
    136125#define init_trigraph_map()  /* Nothing.  */
    137126#define TRIGRAPH_MAP \
    138 __extension__ const U_CHAR _cpp_trigraph_map[UCHAR_MAX + 1] = {
     127__extension__ const uchar _cpp_trigraph_map[UCHAR_MAX + 1] = {
    139128
    140129#define END };
     
    143132#else
    144133
    145 #define TRIGRAPH_MAP U_CHAR _cpp_trigraph_map[UCHAR_MAX + 1] = { 0 }; \
     134#define TRIGRAPH_MAP uchar _cpp_trigraph_map[UCHAR_MAX + 1] = { 0 }; \
    146135 static void init_trigraph_map PARAMS ((void)) { \
    147136 unsigned char *x = _cpp_trigraph_map;
     
    206195/* Append DIR to include path PATH.  DIR must be allocated on the
    207196   heap; this routine takes responsibility for freeing it.  CXX_AWARE
    208    is non-zero if the header contains extern "C" guards for C++,
     197   is nonzero if the header contains extern "C" guards for C++,
    209198   otherwise it is zero.  */
    210199static void
     
    213202     char *dir;
    214203     int path;
    215      int cxx_aware ATTRIBUTE_UNUSED;
     204     int cxx_aware;
    216205{
    217206  struct cpp_pending *pend = CPP_OPTION (pfile, pending);
     
    231220      /* Dirs that don't exist are silently ignored.  */
    232221      if (errno != ENOENT)
    233         cpp_notice_from_errno (pfile, dir);
     222        cpp_errno (pfile, DL_ERROR, dir);
    234223      else if (CPP_OPTION (pfile, verbose))
    235224        fprintf (stderr, _("ignoring nonexistent directory \"%s\"\n"), dir);
     
    240229  if (!S_ISDIR (st.st_mode))
    241230    {
    242       cpp_notice (pfile, "%s: Not a directory", dir);
     231      cpp_error_with_line (pfile, DL_ERROR, 0, 0, "%s: Not a directory", dir);
    243232      free (dir);
    244233      return;
     
    258247     of one "system" list.  */
    259248  if (path == SYSTEM || path == AFTER)
    260 #ifdef NO_IMPLICIT_EXTERN_C
    261     new->sysp = 1;
    262 #else
    263249    new->sysp = cxx_aware ? 1 : 2;
    264 #endif
    265250  else
    266251    new->sysp = 0;
     
    309294
    310295/* Remove duplicate non-system directories for which there is an equivalent
    311    system directory later in the chain.  The range for removal is between
     296   system directory latter in the chain.  The range for removal is between
    312297   *HEAD_PTR and END.  Returns the directory before END, or NULL if none.
    313    This algorithm is quadratic in the number of system directories, which is
     298   This algorithm is quadratic in the number system directories, which is
    314299   acceptable since there aren't usually that many of them.  */
    315300static struct search_path *
     
    366351    {
    367352      for (other = *head_ptr; other != cur; other = other->next)
    368         if (INO_T_EQ (cur->ino, other->ino) && cur->dev == other->dev)
     353        if (INO_T_EQ (cur->ino, other->ino) && cur->dev == other->dev)
    369354          {
    370355            cur = remove_dup_dir (pfile, prev, head_ptr);
     
    446431{
    447432  char c99;
    448   char objc;
    449433  char cplusplus;
    450434  char extended_numbers;
     
    457441/* ??? Enable $ in identifiers in assembly? */
    458442static const struct lang_flags lang_defaults[] =
    459 { /*              c99 objc c++ xnum std dollar c++comm digr  */
    460   /* GNUC89 */  { 0,  0,   0,  1,   0,   1,     1,      1     },
    461   /* GNUC99 */  { 1,  0,   0,  1,   0,   1,     1,      1     },
    462   /* STDC89 */  { 0,  0,   0,  0,   1,   0,     0,      0     },
    463   /* STDC94 */  { 0,  0,   0,  0,   1,   0,     0,      1     },
    464   /* STDC99 */  { 1,  0,   0,  1,   1,   0,     1,      1     },
    465   /* GNUCXX */  { 0,  0,   1,  1,   0,   1,     1,      1     },
    466   /* CXX98  */  { 0,  0,   1,  1,   1,   0,     1,      1     },
    467   /* OBJC   */  { 0,  1,   0,  1,   0,   1,     1,      1     },
    468   /* OBJCXX */  { 0,  1,   1,  1,   0,   1,     1,      1     },
    469   /* ASM    */  { 0,  0,   0,  1,   0,   0,     1,      0     }
     443{ /*              c99 c++ xnum std dollar c++comm digr  */
     444  /* GNUC89 */  { 0,  0,  1,   0,   1,     1,      1     },
     445  /* GNUC99 */  { 1,  0,  1,   0,   1,     1,      1     },
     446  /* STDC89 */  { 0,  0,  0,   1,   0,     0,      0     },
     447  /* STDC94 */  { 0,  0,  0,   1,   0,     0,      1     },
     448  /* STDC99 */  { 1,  0,  1,   1,   0,     1,      1     },
     449  /* GNUCXX */  { 0,  1,  1,   0,   1,     1,      1     },
     450  /* CXX98  */  { 0,  1,  1,   1,   0,     1,      1     },
     451  /* ASM    */  { 0,  0,  1,   0,   0,     1,      0     }
    470452};
    471453
    472454/* Sets internal flags correctly for a given language.  */
    473 static void
    474 set_lang (pfile, lang)
     455void
     456cpp_set_lang (pfile, lang)
    475457     cpp_reader *pfile;
    476458     enum c_lang lang;
     
    481463
    482464  CPP_OPTION (pfile, c99)                = l->c99;
    483   CPP_OPTION (pfile, objc)               = l->objc;
    484465  CPP_OPTION (pfile, cplusplus)          = l->cplusplus;
    485466  CPP_OPTION (pfile, extended_numbers)   = l->extended_numbers;
     
    535516  cpp_reader *pfile;
    536517
    537   /* Initialise this instance of the library if it hasn't been already.  */
     518  /* Initialize this instance of the library if it hasn't been already.  */
    538519  init_library ();
    539520
    540521  pfile = (cpp_reader *) xcalloc (1, sizeof (cpp_reader));
    541522
    542   set_lang (pfile, lang);
     523  cpp_set_lang (pfile, lang);
    543524  CPP_OPTION (pfile, warn_import) = 1;
     525  CPP_OPTION (pfile, warn_multichar) = 1;
    544526  CPP_OPTION (pfile, discard_comments) = 1;
     527  CPP_OPTION (pfile, discard_comments_in_macro_exp) = 1;
    545528  CPP_OPTION (pfile, show_column) = 1;
    546529  CPP_OPTION (pfile, tabstop) = 8;
    547530  CPP_OPTION (pfile, operator_names) = 1;
    548 #if DEFAULT_SIGNED_CHAR
    549   CPP_OPTION (pfile, signed_char) = 1;
    550 #else
    551   CPP_OPTION (pfile, signed_char) = 0;
    552 #endif
     531  CPP_OPTION (pfile, warn_endif_labels) = 1;
     532  CPP_OPTION (pfile, warn_long_long) = !CPP_OPTION (pfile, c99);
     533  CPP_OPTION (pfile, sysroot) = cpp_SYSROOT;
    553534
    554535  CPP_OPTION (pfile, pending) =
    555536    (struct cpp_pending *) xcalloc (1, sizeof (struct cpp_pending));
    556537
    557   /* It's simplest to just create this struct whether or not it will
    558      be needed.  */
    559   pfile->deps = deps_init ();
    560 
    561   /* Initialise the line map.  Start at logical line 1, so we can use
     538  /* Default CPP arithmetic to something sensible for the host for the
     539     benefit of dumb users like fix-header.  */
     540  CPP_OPTION (pfile, precision) = CHAR_BIT * sizeof (long);
     541  CPP_OPTION (pfile, char_precision) = CHAR_BIT;
     542  CPP_OPTION (pfile, wchar_precision) = CHAR_BIT * sizeof (int);
     543  CPP_OPTION (pfile, int_precision) = CHAR_BIT * sizeof (int);
     544  CPP_OPTION (pfile, unsigned_char) = 0;
     545  CPP_OPTION (pfile, unsigned_wchar) = 1;
     546
     547  /* Initialize the line map.  Start at logical line 1, so we can use
    562548     a line number of zero for special states.  */
    563549  init_line_maps (&pfile->line_maps);
     
    568554
    569555  /* Set up static tokens.  */
    570   pfile->date.type = CPP_EOF;
    571556  pfile->avoid_paste.type = CPP_PADDING;
    572557  pfile->avoid_paste.val.source = NULL;
     
    579564  pfile->cur_token = pfile->base_run.base;
    580565
    581   /* Initialise the base context.  */
     566  /* Initialize the base context.  */
    582567  pfile->context = &pfile->base_context;
    583568  pfile->base_context.macro = 0;
     
    588573  pfile->u_buff = _cpp_get_buff (pfile, 0);
    589574
    590   /* Initialise the buffer obstack.  */
     575  /* The expression parser stack.  */
     576  _cpp_expand_op_stack (pfile);
     577
     578  /* Initialize the buffer obstack.  */
    591579  gcc_obstack_init (&pfile->buffer_ob);
    592580
     
    597585
    598586/* Free resources used by PFILE.  Accessing PFILE after this function
    599    returns leads to undefined behaviour.  Returns the error count.  */
    600 int
     587   returns leads to undefined behavior.  Returns the error count.  */
     588void
    601589cpp_destroy (pfile)
    602590     cpp_reader *pfile;
    603591{
    604   int result;
    605592  struct search_path *dir, *dirn;
    606593  cpp_context *context, *contextn;
    607594  tokenrun *run, *runn;
    608595
     596  free_chain (CPP_OPTION (pfile, pending)->include_head);
     597  free (CPP_OPTION (pfile, pending));
     598  free (pfile->op_stack);
     599
    609600  while (CPP_BUFFER (pfile) != NULL)
    610601    _cpp_pop_buffer (pfile);
     602
     603  if (pfile->out.base)
     604    free (pfile->out.base);
    611605
    612606  if (pfile->macro_buffer)
     
    617611    }
    618612
    619   deps_free (pfile->deps);
     613  if (pfile->deps)
     614    deps_free (pfile->deps);
    620615  obstack_free (&pfile->buffer_ob, 0);
    621616
     
    649644
    650645  free_line_maps (&pfile->line_maps);
    651 
    652   result = pfile->errors;
    653646  free (pfile);
    654 
    655   return result;
    656 }
    657 
     647}
    658648
    659649/* This structure defines one built-in identifier.  A node will be
    660    entered in the hash table under the name NAME, with value VALUE (if
    661    any).  If flags has OPERATOR, the node's operator field is used; if
    662    flags has BUILTIN the node's builtin field is used.  Macros that are
    663    known at build time should not be flagged BUILTIN, as then they do
    664    not appear in macro dumps with e.g. -dM or -dD.
    665 
    666    Two values are not compile time constants, so we tag
    667    them in the FLAGS field instead:
    668    VERS         value is the global version_string, quoted
    669    ULP          value is the global user_label_prefix  */
     650   entered in the hash table under the name NAME, with value VALUE.
     651
     652   There are two tables of these.  builtin_array holds all the
     653   "builtin" macros: these are handled by builtin_macro() in
     654   cppmacro.c.  Builtin is somewhat of a misnomer -- the property of
     655   interest is that these macros require special code to compute their
     656   expansions.  The value is a "builtin_type" enumerator.
     657
     658   operator_array holds the C++ named operators.  These are keywords
     659   which act as aliases for punctuators.  In C++, they cannot be
     660   altered through #define, and #if recognizes them as operators.  In
     661   C, these are not entered into the hash table at all (but see
     662   <iso646.h>).  The value is a token-type enumerator.  */
    670663struct builtin
    671664{
    672   const U_CHAR *name;
    673   const char *value;
    674   unsigned char builtin;
    675   unsigned short flags;
     665  const uchar *name;
    676666  unsigned short len;
     667  unsigned short value;
    677668};
    678 #define VERS            0x01
    679 #define ULP             0x02
    680 #define BUILTIN         0x08
    681 
    682 #define B(n, t)       { U n, 0, t, BUILTIN, sizeof n - 1 }
    683 #define C(n, v)       { U n, v, 0, 0, sizeof n - 1 }
    684 #define X(n, f)       { U n, 0, 0, f, sizeof n - 1 }
     669
     670#define B(n, t)    { DSC(n), t }
    685671static const struct builtin builtin_array[] =
    686672{
     
    691677  B("__LINE__",          BT_SPECLINE),
    692678  B("__INCLUDE_LEVEL__", BT_INCLUDE_LEVEL),
     679  /* Keep builtins not used for -traditional-cpp at the end, and
     680     update init_builtins() if any more are added.  */
    693681  B("_Pragma",           BT_PRAGMA),
    694 
    695   X("__VERSION__",              VERS),
    696   X("__USER_LABEL_PREFIX__",    ULP),
    697   C("__REGISTER_PREFIX__",      REGISTER_PREFIX),
    698   C("__HAVE_BUILTIN_SETJMP__",  "1"),
    699 #if USING_SJLJ_EXCEPTIONS
    700   /* libgcc needs to know this.  */
    701   C("__USING_SJLJ_EXCEPTIONS__","1"),
    702 #endif
    703 #ifndef NO_BUILTIN_SIZE_TYPE
    704   C("__SIZE_TYPE__",            SIZE_TYPE),
    705 #endif
    706 #ifndef NO_BUILTIN_PTRDIFF_TYPE
    707   C("__PTRDIFF_TYPE__",         PTRDIFF_TYPE),
    708 #endif
    709 #ifndef NO_BUILTIN_WCHAR_TYPE
    710   C("__WCHAR_TYPE__",           WCHAR_TYPE),
    711 #endif
    712 #ifndef NO_BUILTIN_WINT_TYPE
    713   C("__WINT_TYPE__",            WINT_TYPE),
    714 #endif
    715 #ifdef STDC_0_IN_SYSTEM_HEADERS
    716682  B("__STDC__",          BT_STDC),
    717 #else
    718   C("__STDC__",          "1"),
    719 #endif
    720683};
    721 #undef B
    722 #undef C
    723 #undef X
    724 #define builtin_array_end \
    725  builtin_array + sizeof(builtin_array)/sizeof(struct builtin)
    726 
    727 /* Named operators known to the preprocessor.  These cannot be
    728    #defined and always have their stated meaning.  They are treated
    729    like normal identifiers except for the type code and the meaning.
    730    Most of them are only for C++ (but see iso646.h).  */
    731 #define B(n, t)    { DSC(n), t }
    732 static const struct named_op
    733 {
    734   const U_CHAR *name;
    735   unsigned int len;
    736   enum cpp_ttype value;
    737 } operator_array[] = {
     684
     685static const struct builtin operator_array[] =
     686{
    738687  B("and",      CPP_AND_AND),
    739688  B("and_eq",   CPP_AND_EQ),
     
    755704     cpp_reader *pfile;
    756705{
    757   const struct named_op *b;
     706  const struct builtin *b;
    758707
    759708  for (b = operator_array;
     
    774723{
    775724  const struct builtin *b;
    776 
    777   for(b = builtin_array; b < builtin_array_end; b++)
    778     {
    779       if (b->flags & BUILTIN)
    780         {
    781           cpp_hashnode *hp = cpp_lookup (pfile, b->name, b->len);
    782           hp->type = NT_MACRO;
    783           hp->flags |= NODE_BUILTIN | NODE_WARN;
    784           hp->value.builtin = b->builtin;
    785         }
    786       else                      /* A standard macro of some kind.  */
    787         {
    788           const char *val;
    789           char *str;
    790 
    791           if (b->flags & VERS)
    792             {
    793               /* Allocate enough space for 'name "value"\n\0'.  */
    794               str = alloca (b->len + strlen (version_string) + 5);
    795               sprintf (str, "%s \"%s\"\n", b->name, version_string);
    796             }
    797           else
    798             {
    799               if (b->flags & ULP)
    800                 val = CPP_OPTION (pfile, user_label_prefix);
    801               else
    802                 val = b->value;
    803 
    804               /* Allocate enough space for "name value\n\0".  */
    805               str = alloca (b->len + strlen (val) + 3);
    806               sprintf(str, "%s %s\n", b->name, val);
    807             }
    808 
    809           _cpp_define_builtin (pfile, str);
    810         }
     725  size_t n = ARRAY_SIZE (builtin_array);
     726
     727  if (CPP_OPTION (pfile, traditional))
     728    n -= 2;
     729
     730  for(b = builtin_array; b < builtin_array + n; b++)
     731    {
     732      cpp_hashnode *hp = cpp_lookup (pfile, b->name, b->len);
     733      hp->type = NT_MACRO;
     734      hp->flags |= NODE_BUILTIN | NODE_WARN;
     735      hp->value.builtin = b->value;
    811736    }
    812737
    813738  if (CPP_OPTION (pfile, cplusplus))
    814     {
    815       _cpp_define_builtin (pfile, "__cplusplus 1");
    816       if (SUPPORTS_ONE_ONLY)
    817         _cpp_define_builtin (pfile, "__GXX_WEAK__ 1");
    818       else
    819         _cpp_define_builtin (pfile, "__GXX_WEAK__ 0");
    820     }
    821   if (CPP_OPTION (pfile, objc))
    822     _cpp_define_builtin (pfile, "__OBJC__ 1");
    823 
    824   if (CPP_OPTION (pfile, lang) == CLK_STDC94)
     739    _cpp_define_builtin (pfile, "__cplusplus 1");
     740  else if (CPP_OPTION (pfile, lang) == CLK_ASM)
     741    _cpp_define_builtin (pfile, "__ASSEMBLER__ 1");
     742  else if (CPP_OPTION (pfile, lang) == CLK_STDC94)
    825743    _cpp_define_builtin (pfile, "__STDC_VERSION__ 199409L");
    826744  else if (CPP_OPTION (pfile, c99))
    827745    _cpp_define_builtin (pfile, "__STDC_VERSION__ 199901L");
    828746
    829   if (CPP_OPTION (pfile, signed_char) == 0)
    830     _cpp_define_builtin (pfile, "__CHAR_UNSIGNED__ 1");
    831 
    832   if (CPP_OPTION (pfile, lang) == CLK_STDC89
    833       || CPP_OPTION (pfile, lang) == CLK_STDC94
    834       || CPP_OPTION (pfile, lang) == CLK_STDC99)
    835     _cpp_define_builtin (pfile, "__STRICT_ANSI__ 1");
    836   else if (CPP_OPTION (pfile, lang) == CLK_ASM)
    837     _cpp_define_builtin (pfile, "__ASSEMBLER__ 1");
    838 }
    839 #undef BUILTIN
    840 #undef OPERATOR
    841 #undef VERS
    842 #undef ULP
    843 #undef builtin_array_end
     747  if (CPP_OPTION (pfile, objc))
     748    _cpp_define_builtin (pfile, "__OBJC__ 1");
     749
     750  if (pfile->cb.register_builtins)
     751    (*pfile->cb.register_builtins) (pfile);
     752}
    844753
    845754/* And another subroutine.  This one sets up the standard include path.  */
     
    851760  const struct default_include *p;
    852761  const char *specd_prefix = CPP_OPTION (pfile, include_prefix);
     762  int default_len, specd_len;
     763  char *default_prefix;
    853764
    854765  /* Several environment variables may add to the include search path.
     
    858769     if specified with -isystem, for the language indicated.  */
    859770
    860   GET_ENV_PATH_LIST (path, "CPATH");
     771  GET_ENVIRONMENT (path, "CPATH");
    861772  if (path != 0 && *path != 0)
    862773    path_include (pfile, path, BRACKET);
     
    865776    {
    866777    case 0:
    867       GET_ENV_PATH_LIST (path, "C_INCLUDE_PATH");
     778      GET_ENVIRONMENT (path, "C_INCLUDE_PATH");
    868779      break;
    869780    case 1:
    870       GET_ENV_PATH_LIST (path, "CPLUS_INCLUDE_PATH");
     781      GET_ENVIRONMENT (path, "CPLUS_INCLUDE_PATH");
    871782      break;
    872783    case 2:
    873       GET_ENV_PATH_LIST (path, "OBJC_INCLUDE_PATH");
     784      GET_ENVIRONMENT (path, "OBJC_INCLUDE_PATH");
    874785      break;
    875786    case 3:
    876       GET_ENV_PATH_LIST (path, "OBJCPLUS_INCLUDE_PATH");
     787      GET_ENVIRONMENT (path, "OBJCPLUS_INCLUDE_PATH");
    877788      break;
    878789    }
     
    882793  /* Search "translated" versions of GNU directories.
    883794     These have /usr/local/lib/gcc... replaced by specd_prefix.  */
     795  default_len = 0;
     796  specd_len = 0;
     797  default_prefix = NULL;
    884798  if (specd_prefix != 0 && cpp_GCC_INCLUDE_DIR_len)
    885799    {
    886800      /* Remove the `include' from /usr/local/lib/gcc.../include.
    887801         GCC_INCLUDE_DIR will always end in /include.  */
    888       int default_len = cpp_GCC_INCLUDE_DIR_len;
    889       char *default_prefix = (char *) alloca (default_len + 1);
    890       int specd_len = strlen (specd_prefix);
     802      default_len = cpp_GCC_INCLUDE_DIR_len;
     803      default_prefix = (char *) alloca (default_len + 1);
     804      specd_len = strlen (specd_prefix);
    891805
    892806      memcpy (default_prefix, cpp_GCC_INCLUDE_DIR, default_len);
     
    900814                  && !CPP_OPTION (pfile, no_standard_cplusplus_includes)))
    901815            {
     816              char *str;
     817
     818              /* Should we be translating sysrooted dirs too?  Assume
     819                 that iprefix and sysroot are mutually exclusive, for
     820                 now.  */
     821              if (p->add_sysroot && CPP_OPTION (pfile, sysroot))
     822                continue;
     823
    902824              /* Does this dir start with the prefix?  */
    903825              if (!strncmp (p->fname, default_prefix, default_len))
     
    906828                  int flen = strlen (p->fname);
    907829                  int this_len = specd_len + flen - default_len;
    908                   char *str = (char *) xmalloc (this_len + 1);
     830
     831                  str = (char *) xmalloc (this_len + 1);
    909832                  memcpy (str, specd_prefix, specd_len);
    910833                  memcpy (str + specd_len,
     
    918841    }
    919842
    920   /* Search ordinary names for GNU include directories.  */
    921843  for (p = cpp_include_defaults; p->fname; p++)
    922844    {
     
    926848              && !CPP_OPTION (pfile, no_standard_cplusplus_includes)))
    927849        {
    928           char *str = update_path (p->fname, p->component);
     850          char *str;
     851
     852          /* Should this dir start with the sysroot?  */
     853          if (p->add_sysroot && CPP_OPTION (pfile, sysroot))
     854            str = concat (CPP_OPTION (pfile, sysroot), p->fname, NULL);
     855
     856          else
     857            str = update_path (p->fname, p->component);
     858
    929859          append_include_chain (pfile, str, SYSTEM, p->cxx_aware);
    930860        }
     
    933863
    934864/* Pushes a command line -imacro and -include file indicated by P onto
    935    the buffer stack.  Returns non-zero if successful.  */
     865   the buffer stack.  Returns nonzero if successful.  */
    936866static bool
    937867push_include (pfile, p)
     
    967897}
    968898
     899/* Sanity-checks are dependent on command-line options, so it is
     900   called as a subroutine of cpp_read_main_file ().  */
     901#if ENABLE_CHECKING
     902static void sanity_checks PARAMS ((cpp_reader *));
     903static void sanity_checks (pfile)
     904     cpp_reader *pfile;
     905{
     906  cppchar_t test = 0;
     907  size_t max_precision = 2 * CHAR_BIT * sizeof (cpp_num_part);
     908
     909  /* Sanity checks for assumptions about CPP arithmetic and target
     910     type precisions made by cpplib.  */
     911  test--;
     912  if (test < 1)
     913    cpp_error (pfile, DL_ICE, "cppchar_t must be an unsigned type");
     914
     915  if (CPP_OPTION (pfile, precision) > max_precision)
     916    cpp_error (pfile, DL_ICE,
     917               "preprocessor arithmetic has maximum precision of %lu bits; target requires %lu bits",
     918               (unsigned long) max_precision,
     919               (unsigned long) CPP_OPTION (pfile, precision));
     920
     921  if (CPP_OPTION (pfile, precision) < CPP_OPTION (pfile, int_precision))
     922    cpp_error (pfile, DL_ICE,
     923               "CPP arithmetic must be at least as precise as a target int");
     924
     925  if (CPP_OPTION (pfile, char_precision) < 8)
     926    cpp_error (pfile, DL_ICE, "target char is less than 8 bits wide");
     927
     928  if (CPP_OPTION (pfile, wchar_precision) < CPP_OPTION (pfile, char_precision))
     929    cpp_error (pfile, DL_ICE,
     930               "target wchar_t is narrower than target char");
     931
     932  if (CPP_OPTION (pfile, int_precision) < CPP_OPTION (pfile, char_precision))
     933    cpp_error (pfile, DL_ICE,
     934               "target int is narrower than target char");
     935
     936  /* This is assumed in eval_token() and could be fixed if necessary.  */
     937  if (sizeof (cppchar_t) > sizeof (cpp_num_part))
     938    cpp_error (pfile, DL_ICE, "CPP half-integer narrower than CPP character");
     939
     940  if (CPP_OPTION (pfile, wchar_precision) > BITS_PER_CPPCHAR_T)
     941    cpp_error (pfile, DL_ICE,
     942               "CPP on this host cannot handle wide character constants over %lu bits, but the target requires %lu bits",
     943               (unsigned long) BITS_PER_CPPCHAR_T,
     944               (unsigned long) CPP_OPTION (pfile, wchar_precision));
     945}
     946#else
     947# define sanity_checks(PFILE)
     948#endif
     949
     950/* Add a dependency target.  Can be called any number of times before
     951   cpp_read_main_file().  If no targets have been added before
     952   cpp_read_main_file(), then the default target is used.  */
     953void
     954cpp_add_dependency_target (pfile, target, quote)
     955     cpp_reader *pfile;
     956     const char *target;
     957     int quote;
     958{
     959  if (!pfile->deps)
     960    pfile->deps = deps_init ();
     961
     962  deps_add_target (pfile->deps, target, quote);
     963}
     964
    969965/* This is called after options have been parsed, and partially
    970966   processed.  Setup for processing input from the file named FNAME,
     
    977973     hash_table *table;
    978974{
     975  sanity_checks (pfile);
     976
     977  post_options (pfile);
     978
    979979  /* The front ends don't set up the hash table until they have
    980980     finished processing the command line options, so initializing the
     
    10021002    }
    10031003
    1004   if (CPP_OPTION (pfile, print_deps))
    1005     /* Set the default target (if there is none already).  */
    1006     deps_add_default_target (pfile->deps, fname);
     1004  if (CPP_OPTION (pfile, deps.style) != DEPS_NONE)
     1005    {
     1006      if (!pfile->deps)
     1007        pfile->deps = deps_init ();
     1008
     1009      /* Set the default target (if there is none already).  */
     1010      deps_add_default_target (pfile->deps, fname);
     1011    }
    10071012
    10081013  /* Open the main input file.  */
     
    10101015    return NULL;
    10111016
    1012   /* Set this after cpp_post_options so the client can change the
    1013      option if it wishes, and after stacking the main file so we don't
    1014      trace the main file.  */
     1017  /* Set this here so the client can change the option if it wishes,
     1018     and after stacking the main file so we don't trace the main
     1019     file.  */
    10151020  pfile->line_maps.trace_includes = CPP_OPTION (pfile, print_include_names);
    10161021
     
    10701075      struct pending_option *p;
    10711076
     1077      /* Prevent -Wunused-macros with command-line redefinitions.  */
     1078      pfile->first_unused_line = (unsigned int) -1;
    10721079      _cpp_do_file_change (pfile, LC_RENAME, _("<built-in>"), 1, 0);
    10731080      init_builtins (pfile);
     
    10761083        (*p->handler) (pfile, p->arg);
    10771084
    1078       /* Scan -imacros files after command line defines, but before
    1079          files given with -include.  */
    1080       while ((p = CPP_OPTION (pfile, pending)->imacros_head) != NULL)
     1085      /* Scan -imacros files after -D, -U, but before -include.
     1086         pfile->next_include_file is NULL, so _cpp_pop_buffer does not
     1087         push -include files.  */
     1088      for (p = CPP_OPTION (pfile, pending)->imacros_head; p; p = p->next)
     1089        if (push_include (pfile, p))
     1090          cpp_scan_nooutput (pfile);
     1091
     1092      pfile->next_include_file = &CPP_OPTION (pfile, pending)->include_head;
     1093      _cpp_maybe_push_include_file (pfile);
     1094    }
     1095
     1096  pfile->first_unused_line = pfile->line;
     1097
     1098  free_chain (CPP_OPTION (pfile, pending)->imacros_head);
     1099  free_chain (CPP_OPTION (pfile, pending)->directive_head);
     1100}
     1101
     1102/* Push the next buffer on the stack given by -include, if any.  */
     1103void
     1104_cpp_maybe_push_include_file (pfile)
     1105     cpp_reader *pfile;
     1106{
     1107  if (pfile->next_include_file)
     1108    {
     1109      struct pending_option *head = *pfile->next_include_file;
     1110
     1111      while (head && !push_include (pfile, head))
     1112        head = head->next;
     1113
     1114      if (head)
     1115        pfile->next_include_file = &head->next;
     1116      else
    10811117        {
    1082           if (push_include (pfile, p))
    1083             {
    1084               pfile->buffer->return_at_eof = true;
    1085               cpp_scan_nooutput (pfile);
    1086             }
    1087           CPP_OPTION (pfile, pending)->imacros_head = p->next;
    1088           free (p);
     1118          /* All done; restore the line map from <command line>.  */
     1119          _cpp_do_file_change (pfile, LC_RENAME,
     1120                               pfile->line_maps.maps[0].to_file, 1, 0);
     1121          /* Don't come back here again.  */
     1122          pfile->next_include_file = NULL;
    10891123        }
    10901124    }
    1091 
    1092   free_chain (CPP_OPTION (pfile, pending)->directive_head);
    1093   _cpp_push_next_buffer (pfile);
    1094 }
    1095 
    1096 /* Called to push the next buffer on the stack given by -include.  If
    1097    there are none, free the pending structure and restore the line map
    1098    for the main file.  */
    1099 bool
    1100 _cpp_push_next_buffer (pfile)
    1101      cpp_reader *pfile;
    1102 {
    1103   bool pushed = false;
    1104 
    1105   /* This is't pretty; we'd rather not be relying on this as a boolean
    1106      for reverting the line map.  Further, we only free the chains in
    1107      this conditional, so an early call to cpp_finish / cpp_destroy
    1108      will leak that memory.  */
    1109   if (CPP_OPTION (pfile, pending)
    1110       && CPP_OPTION (pfile, pending)->imacros_head == NULL)
    1111     {
    1112       while (!pushed)
    1113         {
    1114           struct pending_option *p = CPP_OPTION (pfile, pending)->include_head;
    1115 
    1116           if (p == NULL)
    1117             break;
    1118           if (! CPP_OPTION (pfile, preprocessed))
    1119             pushed = push_include (pfile, p);
    1120           CPP_OPTION (pfile, pending)->include_head = p->next;
    1121           free (p);
    1122         }
    1123 
    1124       if (!pushed)
    1125         {
    1126           free (CPP_OPTION (pfile, pending));
    1127           CPP_OPTION (pfile, pending) = NULL;
    1128 
    1129           /* Restore the line map for the main file.  */
    1130           if (! CPP_OPTION (pfile, preprocessed))
    1131             _cpp_do_file_change (pfile, LC_RENAME,
    1132                                  pfile->line_maps.maps[0].to_file, 1, 0);
    1133         }
    1134     }
    1135 
    1136   return pushed;
    1137 }
    1138 
    1139 /* Use mkdeps.c to output dependency information.  */
    1140 static void
    1141 output_deps (pfile)
    1142      cpp_reader *pfile;
    1143 {
    1144   /* Stream on which to print the dependency information.  */
    1145   FILE *deps_stream = 0;
    1146   const char *const deps_mode =
    1147     CPP_OPTION (pfile, print_deps_append) ? "a" : "w";
    1148 
    1149   if (CPP_OPTION (pfile, deps_file)[0] == '\0')
    1150     deps_stream = stdout;
    1151   else
    1152     {
    1153       deps_stream = fopen (CPP_OPTION (pfile, deps_file), deps_mode);
    1154       if (deps_stream == 0)
    1155         {
    1156           cpp_notice_from_errno (pfile, CPP_OPTION (pfile, deps_file));
    1157           return;
    1158         }
    1159     }
    1160 
    1161   deps_write (pfile->deps, deps_stream, 72);
    1162 
    1163   if (CPP_OPTION (pfile, deps_phony_targets))
    1164     deps_phony_targets (pfile->deps, deps_stream);
    1165 
    1166   /* Don't close stdout.  */
    1167   if (deps_stream != stdout)
    1168     {
    1169       if (ferror (deps_stream) || fclose (deps_stream) != 0)
    1170         cpp_fatal (pfile, "I/O error on output");
    1171     }
    1172 }
    1173 
    1174 /* This is called at the end of preprocessing.  It pops the
    1175    last buffer and writes dependency output.  It should also
    1176    clear macro definitions, such that you could call cpp_start_read
    1177    with a new filename to restart processing.  */
    1178 void
    1179 cpp_finish (pfile)
    1180      cpp_reader *pfile;
    1181 {
     1125}
     1126
     1127/* This is called at the end of preprocessing.  It pops the last
     1128   buffer and writes dependency output, and returns the number of
     1129   errors.
     1130 
     1131   Maybe it should also reset state, such that you could call
     1132   cpp_start_read with a new filename to restart processing.  */
     1133int
     1134cpp_finish (pfile, deps_stream)
     1135     cpp_reader *pfile;
     1136     FILE *deps_stream;
     1137{
     1138  /* Warn about unused macros before popping the final buffer.  */
     1139  if (CPP_OPTION (pfile, warn_unused_macros))
     1140    cpp_forall_identifiers (pfile, _cpp_warn_if_unused_macro, NULL);
     1141
    11821142  /* cpplex.c leaves the final buffer on the stack.  This it so that
    11831143     it returns an unending stream of CPP_EOFs to the client.  If we
     
    11881148    _cpp_pop_buffer (pfile);
    11891149
    1190   /* Don't write the deps file if preprocessing has failed.  */
    1191   if (CPP_OPTION (pfile, print_deps) && pfile->errors == 0)
    1192     output_deps (pfile);
     1150  /* Don't write the deps file if there are errors.  */
     1151  if (CPP_OPTION (pfile, deps.style) != DEPS_NONE
     1152      && deps_stream && pfile->errors == 0)
     1153    {
     1154      deps_write (pfile->deps, deps_stream, 72);
     1155
     1156      if (CPP_OPTION (pfile, deps.phony_targets))
     1157        deps_phony_targets (pfile->deps, deps_stream);
     1158    }
    11931159
    11941160  /* Report on headers that could use multiple include guards.  */
    11951161  if (CPP_OPTION (pfile, print_include_names))
    11961162    _cpp_report_missing_guards (pfile);
     1163
     1164  return pfile->errors;
    11971165}
    11981166
     
    12161184   I.e. a const string initializer with parens around it.  That is
    12171185   what N_("string") resolves to, so we make no_* be macros instead.  */
    1218 #define no_arg N_("argument missing after %s")
    12191186#define no_ass N_("assertion missing after %s")
    12201187#define no_dir N_("directory name missing after %s")
     
    12221189#define no_mac N_("macro name missing after %s")
    12231190#define no_pth N_("path name missing after %s")
    1224 #define no_num N_("number missing after %s")
    1225 #define no_tgt N_("target missing after %s")
    12261191
    12271192/* This is the list of all command line options, with the leading
    12281193   "-" removed.  It must be sorted in ASCII collating order.  */
    12291194#define COMMAND_LINE_OPTIONS                                                  \
    1230   DEF_OPT("$",                        0,      OPT_dollar)                     \
    1231   DEF_OPT("+",                        0,      OPT_plus)                       \
    1232   DEF_OPT("-help",                    0,      OPT__help)                      \
    1233   DEF_OPT("-target-help",             0,      OPT_target__help)               \
    1234   DEF_OPT("-version",                 0,      OPT__version)                   \
    12351195  DEF_OPT("A",                        no_ass, OPT_A)                          \
    1236   DEF_OPT("C",                        0,      OPT_C)                          \
    12371196  DEF_OPT("D",                        no_mac, OPT_D)                          \
    1238   DEF_OPT("H",                        0,      OPT_H)                          \
    12391197  DEF_OPT("I",                        no_dir, OPT_I)                          \
    1240   DEF_OPT("M",                        0,      OPT_M)                          \
    1241   DEF_OPT("MD",                       no_fil, OPT_MD)                         \
    1242   DEF_OPT("MF",                       no_fil, OPT_MF)                         \
    1243   DEF_OPT("MG",                       0,      OPT_MG)                         \
    1244   DEF_OPT("MM",                       0,      OPT_MM)                         \
    1245   DEF_OPT("MMD",                      no_fil, OPT_MMD)                        \
    1246   DEF_OPT("MP",                       0,      OPT_MP)                         \
    1247   DEF_OPT("MQ",                       no_tgt, OPT_MQ)                         \
    1248   DEF_OPT("MT",                       no_tgt, OPT_MT)                         \
    1249   DEF_OPT("P",                        0,      OPT_P)                          \
    12501198  DEF_OPT("U",                        no_mac, OPT_U)                          \
    1251   DEF_OPT("W",                        no_arg, OPT_W)  /* arg optional */      \
    1252   DEF_OPT("d",                        no_arg, OPT_d)                          \
    1253   DEF_OPT("fleading-underscore",      0,      OPT_fleading_underscore)        \
    1254   DEF_OPT("fno-leading-underscore",   0,      OPT_fno_leading_underscore)     \
    1255   DEF_OPT("fno-operator-names",       0,      OPT_fno_operator_names)         \
    1256   DEF_OPT("fno-preprocessed",         0,      OPT_fno_preprocessed)           \
    1257   DEF_OPT("fno-show-column",          0,      OPT_fno_show_column)            \
    1258   DEF_OPT("fpreprocessed",            0,      OPT_fpreprocessed)              \
    1259   DEF_OPT("fshow-column",             0,      OPT_fshow_column)               \
    1260   DEF_OPT("fsigned-char",             0,      OPT_fsigned_char)               \
    1261   DEF_OPT("ftabstop=",                no_num, OPT_ftabstop)                   \
    1262   DEF_OPT("funsigned-char",           0,      OPT_funsigned_char)             \
    1263   DEF_OPT("h",                        0,      OPT_h)                          \
    12641199  DEF_OPT("idirafter",                no_dir, OPT_idirafter)                  \
    12651200  DEF_OPT("imacros",                  no_fil, OPT_imacros)                    \
    12661201  DEF_OPT("include",                  no_fil, OPT_include)                    \
    12671202  DEF_OPT("iprefix",                  no_pth, OPT_iprefix)                    \
     1203  DEF_OPT("isysroot",                 no_dir, OPT_isysroot)                   \
    12681204  DEF_OPT("isystem",                  no_dir, OPT_isystem)                    \
    12691205  DEF_OPT("iwithprefix",              no_dir, OPT_iwithprefix)                \
    1270   DEF_OPT("iwithprefixbefore",        no_dir, OPT_iwithprefixbefore)          \
    1271   DEF_OPT("lang-asm",                 0,      OPT_lang_asm)                   \
    1272   DEF_OPT("lang-c",                   0,      OPT_lang_c)                     \
    1273   DEF_OPT("lang-c++",                 0,      OPT_lang_cplusplus)             \
    1274   DEF_OPT("lang-c89",                 0,      OPT_lang_c89)                   \
    1275   DEF_OPT("lang-objc",                0,      OPT_lang_objc)                  \
    1276   DEF_OPT("lang-objc++",              0,      OPT_lang_objcplusplus)          \
    1277   DEF_OPT("nostdinc",                 0,      OPT_nostdinc)                   \
    1278   DEF_OPT("nostdinc++",               0,      OPT_nostdincplusplus)           \
    1279   DEF_OPT("o",                        no_fil, OPT_o)                          \
    1280   DEF_OPT("pedantic",                 0,      OPT_pedantic)                   \
    1281   DEF_OPT("pedantic-errors",          0,      OPT_pedantic_errors)            \
    1282   DEF_OPT("remap",                    0,      OPT_remap)                      \
    1283   DEF_OPT("std=c++98",                0,      OPT_std_cplusplus98)            \
    1284   DEF_OPT("std=c89",                  0,      OPT_std_c89)                    \
    1285   DEF_OPT("std=c99",                  0,      OPT_std_c99)                    \
    1286   DEF_OPT("std=c9x",                  0,      OPT_std_c9x)                    \
    1287   DEF_OPT("std=gnu89",                0,      OPT_std_gnu89)                  \
    1288   DEF_OPT("std=gnu99",                0,      OPT_std_gnu99)                  \
    1289   DEF_OPT("std=gnu9x",                0,      OPT_std_gnu9x)                  \
    1290   DEF_OPT("std=iso9899:1990",         0,      OPT_std_iso9899_1990)           \
    1291   DEF_OPT("std=iso9899:199409",       0,      OPT_std_iso9899_199409)         \
    1292   DEF_OPT("std=iso9899:1999",         0,      OPT_std_iso9899_1999)           \
    1293   DEF_OPT("std=iso9899:199x",         0,      OPT_std_iso9899_199x)           \
    1294   DEF_OPT("trigraphs",                0,      OPT_trigraphs)                  \
    1295   DEF_OPT("v",                        0,      OPT_v)                          \
    1296   DEF_OPT("version",                  0,      OPT_version)                    \
    1297   DEF_OPT("w",                        0,      OPT_w)
     1206  DEF_OPT("iwithprefixbefore",        no_dir, OPT_iwithprefixbefore)
    12981207
    12991208#define DEF_OPT(text, msg, code) code,
     
    13291238   negative on failure.  Complications arise since some options can be
    13301239   suffixed with an argument, and multiple complete matches can occur,
    1331    e.g. -iwithprefix and -iwithprefixbefore.  Moreover, we need to
    1332    accept options beginning with -W that we do not recognise, but not
    1333    to swallow any subsequent command line argument; this is handled as
    1334    special cases in cpp_handle_option.  */
     1240   e.g. -pedantic and -pedantic-errors.  */
    13351241static int
    13361242parse_option (input)
     
    13911297/* Handle one command-line option in (argc, argv).
    13921298   Can be called multiple times, to handle multiple sets of options.
    1393    If ignore is non-zero, this will ignore unrecognized -W* options.
    13941299   Returns number of strings consumed.  */
    13951300int
    1396 cpp_handle_option (pfile, argc, argv, ignore)
     1301cpp_handle_option (pfile, argc, argv)
    13971302     cpp_reader *pfile;
    13981303     int argc;
    13991304     char **argv;
    1400      int ignore;
    14011305{
    14021306  int i = 0;
    14031307  struct cpp_pending *pend = CPP_OPTION (pfile, pending);
    14041308
    1405   /* Interpret "-" or a non-option as a file name.  */
    1406   if (argv[i][0] != '-' || argv[i][1] == '\0')
    1407     {
    1408       if (CPP_OPTION (pfile, in_fname) == NULL)
    1409         CPP_OPTION (pfile, in_fname) = argv[i];
    1410       else if (CPP_OPTION (pfile, out_fname) == NULL)
    1411         CPP_OPTION (pfile, out_fname) = argv[i];
    1412       else
    1413         cpp_fatal (pfile, "too many filenames. Type %s --help for usage info",
    1414                    progname);
    1415     }
    1416   else
    14171309    {
    14181310      enum opt_code opt_code;
     
    14291321        {
    14301322          arg = &argv[i][cl_options[opt_index].opt_len + 1];
    1431 
    1432           /* Yuk. Special case for -W as it must not swallow
    1433              up any following argument.  If this becomes common, add
    1434              another field to the cl_options table.  */
    1435           if (arg[0] == '\0' && opt_code != OPT_W)
     1323          if (arg[0] == '\0')
    14361324            {
    14371325              arg = argv[++i];
    14381326              if (!arg)
    14391327                {
    1440                   cpp_fatal (pfile, cl_options[opt_index].msg, argv[i - 1]);
     1328                  cpp_error (pfile, DL_ERROR,
     1329                             cl_options[opt_index].msg, argv[i - 1]);
    14411330                  return argc;
    14421331                }
     
    14481337        case N_OPTS: /* Shut GCC up.  */
    14491338          break;
    1450         case OPT_fleading_underscore:
    1451           CPP_OPTION (pfile, user_label_prefix) = "_";
    1452           break;
    1453         case OPT_fno_leading_underscore:
    1454           CPP_OPTION (pfile, user_label_prefix) = "";
    1455           break;
    1456         case OPT_fno_operator_names:
    1457           CPP_OPTION (pfile, operator_names) = 0;
    1458           break;
    1459         case OPT_fpreprocessed:
    1460           CPP_OPTION (pfile, preprocessed) = 1;
    1461           break;
    1462         case OPT_fno_preprocessed:
    1463           CPP_OPTION (pfile, preprocessed) = 0;
    1464           break;
    1465         case OPT_fshow_column:
    1466           CPP_OPTION (pfile, show_column) = 1;
    1467           break;
    1468         case OPT_fno_show_column:
    1469           CPP_OPTION (pfile, show_column) = 0;
    1470           break;
    1471         case OPT_fsigned_char:
    1472           CPP_OPTION (pfile, signed_char) = 1;
    1473           break;
    1474         case OPT_funsigned_char:
    1475           CPP_OPTION (pfile, signed_char) = 0;
    1476           break;
    1477         case OPT_ftabstop:
    1478           /* Silently ignore empty string, non-longs and silly values.  */
    1479           if (arg[0] != '\0')
    1480             {
    1481               char *endptr;
    1482               long tabstop = strtol (arg, &endptr, 10);
    1483               if (*endptr == '\0' && tabstop >= 1 && tabstop <= 100)
    1484                 CPP_OPTION (pfile, tabstop) = tabstop;
    1485             }
    1486           break;
    1487         case OPT_w:
    1488           CPP_OPTION (pfile, inhibit_warnings) = 1;
    1489           break;
    1490         case OPT_h:
    1491         case OPT__help:
    1492           print_help ();
    1493           CPP_OPTION (pfile, help_only) = 1;
    1494           break;
    1495         case OPT_target__help:
    1496           /* Print if any target specific options. cpplib has none, but
    1497              make sure help_only gets set.  */
    1498           CPP_OPTION (pfile, help_only) = 1;
    1499           break;
    1500 
    1501           /* --version inhibits compilation, -version doesn't. -v means
    1502              verbose and -version.  Historical reasons, don't ask.  */
    1503         case OPT__version:
    1504           CPP_OPTION (pfile, help_only) = 1;
    1505           pfile->print_version = 1;
    1506           break;
    1507         case OPT_v:
    1508           CPP_OPTION (pfile, verbose) = 1;
    1509           pfile->print_version = 1;
    1510           break;
    1511         case OPT_version:
    1512           pfile->print_version = 1;
    1513           break;
    1514 
    1515         case OPT_C:
    1516           CPP_OPTION (pfile, discard_comments) = 0;
    1517           break;
    1518         case OPT_P:
    1519           CPP_OPTION (pfile, no_line_commands) = 1;
    1520           break;
    1521         case OPT_dollar:        /* Don't include $ in identifiers.  */
    1522           CPP_OPTION (pfile, dollars_in_ident) = 0;
    1523           break;
    1524         case OPT_H:
    1525           CPP_OPTION (pfile, print_include_names) = 1;
    1526           break;
     1339
    15271340        case OPT_D:
    15281341          new_pending_directive (pend, arg, cpp_define);
    1529           break;
    1530         case OPT_pedantic_errors:
    1531           CPP_OPTION (pfile, pedantic_errors) = 1;
    1532           /* fall through */
    1533         case OPT_pedantic:
    1534           CPP_OPTION (pfile, pedantic) = 1;
    1535           break;
    1536         case OPT_trigraphs:
    1537           CPP_OPTION (pfile, trigraphs) = 1;
    1538           break;
    1539         case OPT_plus:
    1540           CPP_OPTION (pfile, cplusplus) = 1;
    1541           CPP_OPTION (pfile, cplusplus_comments) = 1;
    1542           break;
    1543         case OPT_remap:
    1544           CPP_OPTION (pfile, remap) = 1;
    15451342          break;
    15461343        case OPT_iprefix:
     
    15481345          CPP_OPTION (pfile, include_prefix_len) = strlen (arg);
    15491346          break;
    1550         case OPT_lang_c:
    1551           set_lang (pfile, CLK_GNUC89);
    1552           break;
    1553         case OPT_lang_cplusplus:
    1554           set_lang (pfile, CLK_GNUCXX);
    1555           break;
    1556         case OPT_lang_objc:
    1557           set_lang (pfile, CLK_OBJC);
    1558           break;
    1559         case OPT_lang_objcplusplus:
    1560           set_lang (pfile, CLK_OBJCXX);
    1561           break;
    1562         case OPT_lang_asm:
    1563           set_lang (pfile, CLK_ASM);
    1564           break;
    1565         case OPT_std_cplusplus98:
    1566           set_lang (pfile, CLK_CXX98);
    1567           break;
    1568         case OPT_std_gnu89:
    1569           set_lang (pfile, CLK_GNUC89);
    1570           break;
    1571         case OPT_std_gnu9x:
    1572         case OPT_std_gnu99:
    1573           set_lang (pfile, CLK_GNUC99);
    1574           break;
    1575         case OPT_std_iso9899_199409:
    1576           set_lang (pfile, CLK_STDC94);
    1577           break;
    1578         case OPT_std_iso9899_1990:
    1579         case OPT_std_c89:
    1580         case OPT_lang_c89:
    1581           set_lang (pfile, CLK_STDC89);
    1582           break;
    1583         case OPT_std_iso9899_199x:
    1584         case OPT_std_iso9899_1999:
    1585         case OPT_std_c9x:
    1586         case OPT_std_c99:
    1587           set_lang (pfile, CLK_STDC99);
    1588           break;
    1589         case OPT_nostdinc:
    1590           /* -nostdinc causes no default include directories.
    1591              You must specify all include-file directories with -I.  */
    1592           CPP_OPTION (pfile, no_standard_includes) = 1;
    1593           break;
    1594         case OPT_nostdincplusplus:
    1595           /* -nostdinc++ causes no default C++-specific include directories.  */
    1596           CPP_OPTION (pfile, no_standard_cplusplus_includes) = 1;
    1597           break;
    1598         case OPT_o:
    1599           if (CPP_OPTION (pfile, out_fname) == NULL)
    1600             CPP_OPTION (pfile, out_fname) = arg;
    1601           else
    1602             {
    1603               cpp_fatal (pfile, "output filename specified twice");
    1604               return argc;
    1605             }
    1606           break;
    1607         case OPT_d:
    1608           /* Args to -d specify what parts of macros to dump.
    1609              Silently ignore unrecognised options; they may
    1610              be aimed at the compiler proper.  */
    1611           {
    1612             char c;
    1613 
    1614             while ((c = *arg++) != '\0')
    1615               switch (c)
    1616                 {
    1617                 case 'M':
    1618                   CPP_OPTION (pfile, dump_macros) = dump_only;
    1619                   break;
    1620                 case 'N':
    1621                   CPP_OPTION (pfile, dump_macros) = dump_names;
    1622                   break;
    1623                 case 'D':
    1624                   CPP_OPTION (pfile, dump_macros) = dump_definitions;
    1625                   break;
    1626                 case 'I':
    1627                   CPP_OPTION (pfile, dump_includes) = 1;
    1628                   break;
    1629                 }
    1630           }
    1631           break;
    1632 
    1633         case OPT_MG:
    1634           CPP_OPTION (pfile, print_deps_missing_files) = 1;
    1635           break;
    1636         case OPT_M:
    1637           /* When doing dependencies with -M or -MM, suppress normal
    1638              preprocessed output, but still do -dM etc. as software
    1639              depends on this.  Preprocessed output occurs if -MD, -MMD
    1640              or environment var dependency generation is used.  */
    1641           CPP_OPTION (pfile, print_deps) = 2;
    1642           CPP_OPTION (pfile, no_output) = 1;
    1643           break;
    1644         case OPT_MM:
    1645           CPP_OPTION (pfile, print_deps) = 1;
    1646           CPP_OPTION (pfile, no_output) = 1;
    1647           break;
    1648         case OPT_MF:
    1649           CPP_OPTION (pfile, deps_file) = arg;
    1650           break;
    1651         case OPT_MP:
    1652           CPP_OPTION (pfile, deps_phony_targets) = 1;
    1653           break;
    1654         case OPT_MQ:
    1655         case OPT_MT:
    1656           /* Add a target.  -MQ quotes for Make.  */
    1657           deps_add_target (pfile->deps, arg, opt_code == OPT_MQ);
    1658           break;
    1659 
    1660         case OPT_MD:
    1661           CPP_OPTION (pfile, print_deps) = 2;
    1662           CPP_OPTION (pfile, deps_file) = arg;
    1663           break;
    1664         case OPT_MMD:
    1665           CPP_OPTION (pfile, print_deps) = 1;
    1666           CPP_OPTION (pfile, deps_file) = arg;
     1347
     1348        case OPT_isysroot:
     1349          CPP_OPTION (pfile, sysroot) = arg;
    16671350          break;
    16681351
    16691352        case OPT_A:
    16701353          if (arg[0] == '-')
    1671             {
    1672               /* -A with an argument beginning with '-' acts as
    1673                  #unassert on whatever immediately follows the '-'.
    1674                  If "-" is the whole argument, we eliminate all
    1675                  predefined macros and assertions, including those
    1676                  that were specified earlier on the command line.
    1677                  That way we can get rid of any that were passed
    1678                  automatically in from GCC.  */
    1679 
    1680               if (arg[1] == '\0')
    1681                 {
    1682                   free_chain (pend->directive_head);
    1683                   pend->directive_head = NULL;
    1684                   pend->directive_tail = NULL;
    1685                 }
    1686               else
    1687                 new_pending_directive (pend, arg + 1, cpp_unassert);
    1688             }
     1354            new_pending_directive (pend, arg + 1, cpp_unassert);
    16891355          else
    16901356            new_pending_directive (pend, arg, cpp_assert);
     
    16951361        case OPT_I:           /* Add directory to path for includes.  */
    16961362          if (!strcmp (arg, "-"))
    1697             {
     1363            {
    16981364              /* -I- means:
    16991365                 Use the preceding -I directories for #include "..."
     
    17121378              else
    17131379                {
    1714                   cpp_fatal (pfile, "-I- specified twice");
     1380                  cpp_error (pfile, DL_ERROR, "-I- specified twice");
    17151381                  return argc;
    17161382                }
    1717             }
    1718           else
     1383            }
     1384          else
    17191385            append_include_chain (pfile, xstrdup (arg), BRACKET, 0);
    17201386          break;
     
    17751441          append_include_chain (pfile, xstrdup (arg), AFTER, 0);
    17761442          break;
    1777         case OPT_W:
    1778           /* Silently ignore unrecognised options.  */
    1779           if (!strcmp (argv[i], "-Wall"))
    1780             {
    1781               CPP_OPTION (pfile, warn_trigraphs) = 1;
    1782               CPP_OPTION (pfile, warn_comments) = 1;
    1783             }
    1784           else if (!strcmp (argv[i], "-Wtraditional"))
    1785             CPP_OPTION (pfile, warn_traditional) = 1;
    1786           else if (!strcmp (argv[i], "-Wtrigraphs"))
    1787             CPP_OPTION (pfile, warn_trigraphs) = 1;
    1788           else if (!strcmp (argv[i], "-Wcomment"))
    1789             CPP_OPTION (pfile, warn_comments) = 1;
    1790           else if (!strcmp (argv[i], "-Wcomments"))
    1791             CPP_OPTION (pfile, warn_comments) = 1;
    1792           else if (!strcmp (argv[i], "-Wundef"))
    1793             CPP_OPTION (pfile, warn_undef) = 1;
    1794           else if (!strcmp (argv[i], "-Wimport"))
    1795             CPP_OPTION (pfile, warn_import) = 1;
    1796           else if (!strcmp (argv[i], "-Werror"))
    1797             CPP_OPTION (pfile, warnings_are_errors) = 1;
    1798           else if (!strcmp (argv[i], "-Wsystem-headers"))
    1799             CPP_OPTION (pfile, warn_system_headers) = 1;
    1800           else if (!strcmp (argv[i], "-Wno-traditional"))
    1801             CPP_OPTION (pfile, warn_traditional) = 0;
    1802           else if (!strcmp (argv[i], "-Wno-trigraphs"))
    1803             CPP_OPTION (pfile, warn_trigraphs) = 0;
    1804           else if (!strcmp (argv[i], "-Wno-comment"))
    1805             CPP_OPTION (pfile, warn_comments) = 0;
    1806           else if (!strcmp (argv[i], "-Wno-comments"))
    1807             CPP_OPTION (pfile, warn_comments) = 0;
    1808           else if (!strcmp (argv[i], "-Wno-undef"))
    1809             CPP_OPTION (pfile, warn_undef) = 0;
    1810           else if (!strcmp (argv[i], "-Wno-import"))
    1811             CPP_OPTION (pfile, warn_import) = 0;
    1812           else if (!strcmp (argv[i], "-Wno-error"))
    1813             CPP_OPTION (pfile, warnings_are_errors) = 0;
    1814           else if (!strcmp (argv[i], "-Wno-system-headers"))
    1815             CPP_OPTION (pfile, warn_system_headers) = 0;
    1816           else if (! ignore)
    1817             return i;
    1818           break;
    1819         }
     1443        }
    18201444    }
    18211445  return i + 1;
     
    18371461  for (i = 0; i < argc; i += strings_processed)
    18381462    {
    1839       strings_processed = cpp_handle_option (pfile, argc - i, argv + i, 1);
     1463      strings_processed = cpp_handle_option (pfile, argc - i, argv + i);
    18401464      if (strings_processed == 0)
    18411465        break;
     
    18451469}
    18461470
    1847 /* Extra processing when all options are parsed, after all calls to
    1848    cpp_handle_option[s].  Consistency checks etc.  */
    1849 void
    1850 cpp_post_options (pfile)
    1851      cpp_reader *pfile;
    1852 {
    1853   if (pfile->print_version)
    1854     {
    1855       fprintf (stderr, _("GNU CPP version %s (cpplib)"), version_string);
    1856 #ifdef TARGET_VERSION
    1857       TARGET_VERSION;
    1858 #endif
    1859       fputc ('\n', stderr);
    1860     }
    1861 
    1862   /* Canonicalize in_fname and out_fname.  We guarantee they are not
    1863      NULL, and that the empty string represents stdin / stdout.  */
    1864   if (CPP_OPTION (pfile, in_fname) == NULL
    1865       || !strcmp (CPP_OPTION (pfile, in_fname), "-"))
    1866     CPP_OPTION (pfile, in_fname) = "";
    1867 
    1868   if (CPP_OPTION (pfile, out_fname) == NULL
    1869       || !strcmp (CPP_OPTION (pfile, out_fname), "-"))
    1870     CPP_OPTION (pfile, out_fname) = "";
    1871 
     1471static void
     1472post_options (pfile)
     1473     cpp_reader *pfile;
     1474{
    18721475  /* -Wtraditional is not useful in C++ mode.  */
    18731476  if (CPP_OPTION (pfile, cplusplus))
    18741477    CPP_OPTION (pfile, warn_traditional) = 0;
    18751478
    1876   /* Set this if it hasn't been set already.  */
    1877   if (CPP_OPTION (pfile, user_label_prefix) == NULL)
    1878     CPP_OPTION (pfile, user_label_prefix) = USER_LABEL_PREFIX;
    1879 
    18801479  /* Permanently disable macro expansion if we are rescanning
    1881      preprocessed text.  */
     1480     preprocessed text.  Read preprocesed source in ISO mode.  */
    18821481  if (CPP_OPTION (pfile, preprocessed))
    1883     pfile->state.prevent_expansion = 1;
    1884 
    1885   /* -dM makes no normal output.  This is set here so that -dM -dD
    1886      works as expected.  */
    1887   if (CPP_OPTION (pfile, dump_macros) == dump_only)
    1888     CPP_OPTION (pfile, no_output) = 1;
    1889 
    1890   /* Disable -dD, -dN and -dI if we should make no normal output
    1891      (such as with -M). Allow -M -dM since some software relies on
    1892      this.  */
    1893   if (CPP_OPTION (pfile, no_output))
    1894     {
    1895       if (CPP_OPTION (pfile, dump_macros) != dump_only)
    1896         CPP_OPTION (pfile, dump_macros) = dump_none;
    1897       CPP_OPTION (pfile, dump_includes) = 0;
    1898     }
    1899 
    1900   /* We need to do this after option processing and before
    1901      cpp_start_read, as cppmain.c relies on the options->no_output to
    1902      set its callbacks correctly before calling cpp_start_read.  */
    1903   init_dependency_output (pfile);
    1904 
    1905   /* After checking the environment variables, check if -M or -MM has
    1906      not been specified, but other -M options have.  */
    1907   if (CPP_OPTION (pfile, print_deps) == 0 &&
    1908       (CPP_OPTION (pfile, print_deps_missing_files)
    1909        || CPP_OPTION (pfile, deps_file)
    1910        || CPP_OPTION (pfile, deps_phony_targets)))
    1911     cpp_fatal (pfile, "you must additionally specify either -M or -MM");
    1912 }
    1913 
    1914 /* Set up dependency-file output.  On exit, if print_deps is non-zero
    1915    then deps_file is not NULL; stdout is the empty string.  */
    1916 static void
    1917 init_dependency_output (pfile)
    1918      cpp_reader *pfile;
    1919 {
    1920   char *spec, *s, *output_file;
    1921 
    1922   /* Either of two environment variables can specify output of deps.
    1923      Its value is either "OUTPUT_FILE" or "OUTPUT_FILE DEPS_TARGET",
    1924      where OUTPUT_FILE is the file to write deps info to
    1925      and DEPS_TARGET is the target to mention in the deps.  */
    1926 
    1927   if (CPP_OPTION (pfile, print_deps) == 0)
    1928     {
    1929       spec = getenv ("DEPENDENCIES_OUTPUT");
    1930       if (spec)
    1931         CPP_OPTION (pfile, print_deps) = 1;
    1932       else
    1933         {
    1934           spec = getenv ("SUNPRO_DEPENDENCIES");
    1935           if (spec)
    1936             {
    1937               CPP_OPTION (pfile, print_deps) = 2;
    1938               CPP_OPTION (pfile, deps_ignore_main_file) = 1;
    1939             }
    1940           else
    1941             return;
    1942         }
    1943 
    1944       /* Find the space before the DEPS_TARGET, if there is one.  */
    1945       s = strchr (spec, ' ');
    1946       if (s)
    1947         {
    1948           /* Let the caller perform MAKE quoting.  */
    1949           deps_add_target (pfile->deps, s + 1, 0);
    1950           output_file = (char *) xmalloc (s - spec + 1);
    1951           memcpy (output_file, spec, s - spec);
    1952           output_file[s - spec] = 0;
    1953         }
    1954       else
    1955         output_file = spec;
    1956 
    1957       /* Command line -MF overrides environment variables and default.  */
    1958       if (CPP_OPTION (pfile, deps_file) == 0)
    1959         CPP_OPTION (pfile, deps_file) = output_file;
    1960 
    1961       CPP_OPTION (pfile, print_deps_append) = 1;
    1962     }
    1963   else if (CPP_OPTION (pfile, deps_file) == 0)
    1964     /* If -M or -MM was seen without -MF, default output to wherever
    1965        was specified with -o.  out_fname is non-NULL here.  */
    1966     CPP_OPTION (pfile, deps_file) = CPP_OPTION (pfile, out_fname);
    1967 }
    1968 
    1969 /* Handle --help output.  */
    1970 static void
    1971 print_help ()
    1972 {
    1973   /* To keep the lines from getting too long for some compilers, limit
    1974      to about 500 characters (6 lines) per chunk.  */
    1975   fputs (_("\
    1976 Switches:\n\
    1977   -include <file>           Include the contents of <file> before other files\n\
    1978   -imacros <file>           Accept definition of macros in <file>\n\
    1979   -iprefix <path>           Specify <path> as a prefix for next two options\n\
    1980   -iwithprefix <dir>        Add <dir> to the end of the system include path\n\
    1981   -iwithprefixbefore <dir>  Add <dir> to the end of the main include path\n\
    1982   -isystem <dir>            Add <dir> to the start of the system include path\n\
    1983 "), stdout);
    1984   fputs (_("\
    1985   -idirafter <dir>          Add <dir> to the end of the system include path\n\
    1986   -I <dir>                  Add <dir> to the end of the main include path\n\
    1987   -I-                       Fine-grained include path control; see info docs\n\
    1988   -nostdinc                 Do not search system include directories\n\
    1989                              (dirs specified with -isystem will still be used)\n\
    1990   -nostdinc++               Do not search system include directories for C++\n\
    1991   -o <file>                 Put output into <file>\n\
    1992 "), stdout);
    1993   fputs (_("\
    1994   -pedantic                 Issue all warnings demanded by strict ISO C\n\
    1995   -pedantic-errors          Issue -pedantic warnings as errors instead\n\
    1996   -trigraphs                Support ISO C trigraphs\n\
    1997   -lang-c                   Assume that the input sources are in C\n\
    1998   -lang-c89                 Assume that the input sources are in C89\n\
    1999 "), stdout);
    2000   fputs (_("\
    2001   -lang-c++                 Assume that the input sources are in C++\n\
    2002   -lang-objc                Assume that the input sources are in ObjectiveC\n\
    2003   -lang-objc++              Assume that the input sources are in ObjectiveC++\n\
    2004   -lang-asm                 Assume that the input sources are in assembler\n\
    2005 "), stdout);
    2006   fputs (_("\
    2007   -std=<std name>           Specify the conformance standard; one of:\n\
    2008                             gnu89, gnu99, c89, c99, iso9899:1990,\n\
    2009                             iso9899:199409, iso9899:1999\n\
    2010   -+                        Allow parsing of C++ style features\n\
    2011   -w                        Inhibit warning messages\n\
    2012   -Wtrigraphs               Warn if trigraphs are encountered\n\
    2013   -Wno-trigraphs            Do not warn about trigraphs\n\
    2014   -Wcomment{s}              Warn if one comment starts inside another\n\
    2015 "), stdout);
    2016   fputs (_("\
    2017   -Wno-comment{s}           Do not warn about comments\n\
    2018   -Wtraditional             Warn about features not present in traditional C\n\
    2019   -Wno-traditional          Do not warn about traditional C\n\
    2020   -Wundef                   Warn if an undefined macro is used by #if\n\
    2021   -Wno-undef                Do not warn about testing undefined macros\n\
    2022   -Wimport                  Warn about the use of the #import directive\n\
    2023 "), stdout);
    2024   fputs (_("\
    2025   -Wno-import               Do not warn about the use of #import\n\
    2026   -Werror                   Treat all warnings as errors\n\
    2027   -Wno-error                Do not treat warnings as errors\n\
    2028   -Wsystem-headers          Do not suppress warnings from system headers\n\
    2029   -Wno-system-headers       Suppress warnings from system headers\n\
    2030   -Wall                     Enable all preprocessor warnings\n\
    2031 "), stdout);
    2032   fputs (_("\
    2033   -M                        Generate make dependencies\n\
    2034   -MM                       As -M, but ignore system header files\n\
    2035   -MD                       Generate make dependencies and compile\n\
    2036   -MMD                      As -MD, but ignore system header files\n\
    2037   -MF <file>                Write dependency output to the given file\n\
    2038   -MG                       Treat missing header file as generated files\n\
    2039 "), stdout);
    2040   fputs (_("\
    2041   -MP                       Generate phony targets for all headers\n\
    2042   -MQ <target>              Add a MAKE-quoted target\n\
    2043   -MT <target>              Add an unquoted target\n\
    2044 "), stdout);
    2045   fputs (_("\
    2046   -D<macro>                 Define a <macro> with string '1' as its value\n\
    2047   -D<macro>=<val>           Define a <macro> with <val> as its value\n\
    2048   -A<question>=<answer>     Assert the <answer> to <question>\n\
    2049   -A-<question>=<answer>    Disable the <answer> to <question>\n\
    2050   -U<macro>                 Undefine <macro> \n\
    2051   -v                        Display the version number\n\
    2052 "), stdout);
    2053   fputs (_("\
    2054   -H                        Print the name of header files as they are used\n\
    2055   -C                        Do not discard comments\n\
    2056   -dM                       Display a list of macro definitions active at end\n\
    2057   -dD                       Preserve macro definitions in output\n\
    2058   -dN                       As -dD except that only the names are preserved\n\
    2059   -dI                       Include #include directives in the output\n\
    2060 "), stdout);
    2061   fputs (_("\
    2062   -fpreprocessed            Treat the input file as already preprocessed\n\
    2063   -ftabstop=<number>        Distance between tab stops for column reporting\n\
    2064   -P                        Do not generate #line directives\n\
    2065   -$                        Do not allow '$' in identifiers\n\
    2066   -remap                    Remap file names when including files\n\
    2067   --version                 Display version information\n\
    2068   -h or --help              Display this information\n\
    2069 "), stdout);
    2070 }
     1482    {
     1483      pfile->state.prevent_expansion = 1;
     1484      CPP_OPTION (pfile, traditional) = 0;
     1485    }
     1486
     1487  /* Traditional CPP does not accurately track column information.  */
     1488  if (CPP_OPTION (pfile, traditional))
     1489    CPP_OPTION (pfile, show_column) = 0;
     1490}
Note: See TracChangeset for help on using the changeset viewer.