OSDN Git Service

* Makefile.in ($(srcdir)/c-parse.y: c-parse.in): Enclose the whole
[pf3gnuchains/gcc-fork.git] / gcc / cccp.c
index 6f9c36c..9a02333 100644 (file)
@@ -1,5 +1,6 @@
 /* C Compatible Compiler Preprocessor (CCCP)
-   Copyright (C) 1986, 87, 89, 92-98, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997,
+   1998, 1999, 2000 Free Software Foundation, Inc.
    Written by Paul Rubin, June 1986
    Adapted to ANSI C, Richard Stallman, Jan 1987
 
@@ -32,6 +33,7 @@ typedef unsigned char U_CHAR;
 #include "pcp.h"
 #include "intl.h"
 #include "prefix.h"
+#include "version.h"
 
 #ifdef MULTIBYTE_CHARS
 #include "mbchar.h"
@@ -46,16 +48,6 @@ typedef unsigned char U_CHAR;
 # define STANDARD_INCLUDE_DIR "/usr/include"
 #endif
 
-/* By default, colon separates directories in a path.  */
-#ifndef PATH_SEPARATOR
-# define PATH_SEPARATOR ':'
-#endif
-
-/* By default, a slash separates directory names.  */
-#ifndef DIR_SEPARATOR
-# define DIR_SEPARATOR '/'
-#endif
-
 /* By default, the suffix for object files is ".o".  */
 #ifdef OBJECT_SUFFIX
 # define HAVE_OBJECT_SUFFIX
@@ -84,8 +76,9 @@ static void hack_vms_include_specification ();
 #define INCLUDE_LEN_FUDGE 12   /* leave room for VMS syntax conversion */
 #endif /* VMS */
 
-/* Windows does not natively support inodes, and neither does MSDOS.  */
-#if (defined (_WIN32) && ! defined (__CYGWIN__) && ! defined (_UWIN)) \
+/* Windows does not natively support inodes, and neither does MSDOS. 
+   Cygwin's emulation can generate non-unique inodes, so don't use it. */
+#if (defined (_WIN32) && ! defined (_UWIN)) \
   || defined (__MSDOS__)
 #define INO_T_EQ(a, b) 0
 #endif
@@ -104,9 +97,8 @@ static void hack_vms_include_specification ();
 
 /* External declarations.  */
 
-extern char *version_string;
-HOST_WIDEST_INT parse_escape PROTO((char **, HOST_WIDEST_INT));
-HOST_WIDEST_INT parse_c_expression PROTO((char *, int));
+HOST_WIDEST_INT parse_escape PARAMS ((char **, HOST_WIDEST_INT));
+HOST_WIDEST_INT parse_c_expression PARAMS ((char *, int));
 \f
 /* Name under which this program was invoked.  */
 
@@ -265,9 +257,9 @@ int traditional;
 
 int c89;
 
-/* Nonzero for the 199x C Standard.  */
+/* Nonzero for the 1999 C Standard.  */
 
-int c9x;
+int c99;
 
 /* Nonzero causes output not to be done,
    but directives such as #define that have side effects
@@ -590,7 +582,7 @@ static char rest_extension[] = "...";
 #define REST_EXTENSION_LENGTH  (sizeof (rest_extension) - 1)
 
 /* This is the implicit parameter name when using variable number of
-   parameters for macros using the ISO C 9x extension.  */
+   parameters for macros using the ISO C 99 extension.  */
 static char va_args_name[] = "__VA_ARGS__";
 #define VA_ARGS_NAME_LENGTH    (sizeof (va_args_name) - 1)
 
@@ -758,7 +750,7 @@ static int assertions_flag;
 \f
 /* `struct directive' defines one #-directive, including how to handle it.  */
 
-#define DO_PROTO PROTO((U_CHAR *, U_CHAR *, FILE_BUF *, struct directive *))
+#define DO_PROTO PARAMS ((U_CHAR *, U_CHAR *, FILE_BUF *, struct directive *))
 
 struct directive {
   int length;                  /* Length of name */
@@ -878,163 +870,165 @@ static int deps_column;
    so don't look for #include "foo" the source-file directory.  */
 static int ignore_srcdir;
 \f
-static int safe_read PROTO((int, char *, int));
-static void safe_write PROTO((int, const char *, int));
+static int safe_read PARAMS ((int, char *, int));
+static void safe_write PARAMS ((int, const char *, int));
 
-int main PROTO((int, char **));
+int main PARAMS ((int, char **));
 
-static void path_include PROTO((char *));
+static void path_include PARAMS ((char *));
 
-static const U_CHAR *index0 PROTO((const U_CHAR *, int, size_t));
+static const U_CHAR *index0 PARAMS ((const U_CHAR *, int, size_t));
 
-static void trigraph_pcp PROTO((FILE_BUF *));
-static void check_white_space PROTO((FILE_BUF *));
+static void trigraph_pcp PARAMS ((FILE_BUF *));
+static void check_white_space PARAMS ((FILE_BUF *));
 
-static void newline_fix PROTO((U_CHAR *));
-static void name_newline_fix PROTO((U_CHAR *));
+static void newline_fix PARAMS ((U_CHAR *));
+static void name_newline_fix PARAMS ((U_CHAR *));
 
-static const char *get_lintcmd PROTO((const U_CHAR *, const U_CHAR *,
-                                     const U_CHAR **, int *, int *));
+static const char *get_lintcmd PARAMS ((const U_CHAR *, const U_CHAR *,
+                                       const U_CHAR **, int *, int *));
 
-static void rescan PROTO((FILE_BUF *, int));
+static void rescan PARAMS ((FILE_BUF *, int));
 
-static FILE_BUF expand_to_temp_buffer PROTO((const U_CHAR *, const U_CHAR *,
-                                            int, int));
+static FILE_BUF expand_to_temp_buffer PARAMS ((const U_CHAR *, const U_CHAR *,
+                                              int, int));
 
-static int handle_directive PROTO((FILE_BUF *, FILE_BUF *));
+static int handle_directive PARAMS ((FILE_BUF *, FILE_BUF *));
 
-static struct tm *timestamp PROTO((void));
-static void special_symbol PROTO((HASHNODE *, FILE_BUF *));
+static struct tm *timestamp PARAMS ((void));
+static void special_symbol PARAMS ((HASHNODE *, FILE_BUF *));
 
-static int is_system_include PROTO((const char *));
-static char *base_name PROTO((const char *));
-static int absolute_filename PROTO((const char *));
-static size_t simplify_filename PROTO((char *));
+static int is_system_include PARAMS ((const char *));
+static char *base_name PARAMS ((const char *));
+static int absolute_filename PARAMS ((const char *));
+static size_t simplify_filename PARAMS ((char *));
 
-static char *read_filename_string PROTO((int, FILE *));
-static struct file_name_map *read_name_map PROTO((const char *));
-static int open_include_file PROTO((char *, struct file_name_list *,
-                                   const U_CHAR *, struct include_file **));
-static char *remap_include_file PROTO((char *, struct file_name_list *));
-static int lookup_ino_include PROTO((struct include_file *));
+static char *read_filename_string PARAMS ((int, FILE *));
+static struct file_name_map *read_name_map PARAMS ((const char *));
+static int open_include_file PARAMS ((char *, struct file_name_list *,
+                                     const U_CHAR *, struct include_file **));
+static char *remap_include_file PARAMS ((char *, struct file_name_list *));
+static int lookup_ino_include PARAMS ((struct include_file *));
 
-static void finclude PROTO((int, struct include_file *, FILE_BUF *, int, struct file_name_list *));
-static void record_control_macro PROTO((struct include_file *, const U_CHAR *));
+static void finclude PARAMS ((int, struct include_file *, FILE_BUF *, int,
+                             struct file_name_list *));
+static void record_control_macro PARAMS ((struct include_file *,
+                                         const U_CHAR *));
 
-static char *check_precompiled PROTO((int, struct stat *, const char *,
-                                     const char **));
-static int check_preconditions PROTO((const char *));
-static void pcfinclude PROTO((U_CHAR *, const U_CHAR *, FILE_BUF *));
-static void pcstring_used PROTO((HASHNODE *));
-static void write_output PROTO((void));
-static void pass_thru_directive PROTO((const U_CHAR *, const U_CHAR *,
-                                      FILE_BUF *, struct directive *));
+static char *check_precompiled PARAMS ((int, struct stat *, const char *,
+                                       const char **));
+static int check_preconditions PARAMS ((const char *));
+static void pcfinclude PARAMS ((U_CHAR *, const U_CHAR *, FILE_BUF *));
+static void pcstring_used PARAMS ((HASHNODE *));
+static void write_output PARAMS ((void));
+static void pass_thru_directive PARAMS ((const U_CHAR *, const U_CHAR *,
+                                        FILE_BUF *, struct directive *));
 
-static MACRODEF create_definition PROTO((const U_CHAR *, const U_CHAR *,
-                                        FILE_BUF *));
+static MACRODEF create_definition PARAMS ((const U_CHAR *, const U_CHAR *,
+                                          FILE_BUF *));
 
-static int check_macro_name PROTO((const U_CHAR *, int));
-static int compare_defs PROTO((DEFINITION *, DEFINITION *));
-static int comp_def_part PROTO((int, const U_CHAR *, int, const U_CHAR *,
-                               int, int));
+static int check_macro_name PARAMS ((const U_CHAR *, int));
+static int compare_defs PARAMS ((DEFINITION *, DEFINITION *));
+static int comp_def_part PARAMS ((int, const U_CHAR *, int, const U_CHAR *,
+                                 int, int));
 
-static DEFINITION *collect_expansion  PROTO((const U_CHAR *, const U_CHAR *,
-                                            int, struct arglist *));
+static DEFINITION *collect_expansion  PARAMS ((const U_CHAR *, const U_CHAR *,
+                                              int, struct arglist *));
 
-int check_assertion PROTO((const U_CHAR *, int, int, struct arglist *));
-static int compare_token_lists PROTO((struct arglist *, struct arglist *));
+int check_assertion PARAMS ((const U_CHAR *, int, int, struct arglist *));
+static int compare_token_lists PARAMS ((struct arglist *, struct arglist *));
 
-static struct arglist *read_token_list PROTO((const U_CHAR **, const U_CHAR *,
-                                             int *));
-static void free_token_list PROTO((struct arglist *));
+static struct arglist *read_token_list PARAMS ((const U_CHAR **,
+                                               const U_CHAR *, int *));
+static void free_token_list PARAMS ((struct arglist *));
 
-static ASSERTION_HASHNODE *assertion_install PROTO((const U_CHAR *, int, int));
-static ASSERTION_HASHNODE *assertion_lookup PROTO((const U_CHAR *, int, int));
-static void delete_assertion PROTO((ASSERTION_HASHNODE *));
+static ASSERTION_HASHNODE *assertion_install PARAMS ((const U_CHAR *, int, int));
+static ASSERTION_HASHNODE *assertion_lookup PARAMS ((const U_CHAR *, int, int));
+static void delete_assertion PARAMS ((ASSERTION_HASHNODE *));
 
-static void do_once PROTO((void));
+static void do_once PARAMS ((void));
 
-static HOST_WIDEST_INT eval_if_expression PROTO((const U_CHAR *, int));
-static void conditional_skip PROTO((FILE_BUF *, int, enum node_type,
-                                   const U_CHAR *, FILE_BUF *));
-static void skip_if_group PROTO((FILE_BUF *, int, FILE_BUF *));
-static void validate_else PROTO((const U_CHAR *, const U_CHAR *));
+static HOST_WIDEST_INT eval_if_expression PARAMS ((const U_CHAR *, int));
+static void conditional_skip PARAMS ((FILE_BUF *, int, enum node_type,
+                                     const U_CHAR *, FILE_BUF *));
+static void skip_if_group PARAMS ((FILE_BUF *, int, FILE_BUF *));
+static void validate_else PARAMS ((const U_CHAR *, const U_CHAR *));
 
-static U_CHAR *skip_to_end_of_comment PROTO((FILE_BUF *, int *, int));
-static U_CHAR *skip_quoted_string PROTO((const U_CHAR *, const U_CHAR *,
-                                        int, int *, int *, int *));
-static char *quote_string PROTO((char *, const char *, size_t));
-static U_CHAR *skip_paren_group PROTO((FILE_BUF *));
+static U_CHAR *skip_to_end_of_comment PARAMS ((FILE_BUF *, int *, int));
+static U_CHAR *skip_quoted_string PARAMS ((const U_CHAR *, const U_CHAR *,
+                                          int, int *, int *, int *));
+static char *quote_string PARAMS ((char *, const char *, size_t));
+static U_CHAR *skip_paren_group PARAMS ((FILE_BUF *));
 
 /* Last arg to output_line_directive.  */
 enum file_change_code {same_file, enter_file, leave_file};
-static void output_line_directive PROTO((FILE_BUF *, FILE_BUF *, int, enum file_change_code));
+static void output_line_directive PARAMS ((FILE_BUF *, FILE_BUF *, int, enum file_change_code));
 
-static void macroexpand PROTO((HASHNODE *, FILE_BUF *));
+static void macroexpand PARAMS ((HASHNODE *, FILE_BUF *));
 
 struct argdata;
-static int macarg PROTO((struct argdata *, int));
+static int macarg PARAMS ((struct argdata *, int));
 
-static U_CHAR *macarg1 PROTO((U_CHAR *, const U_CHAR *, struct hashnode *, int *, int *, int *, int));
+static U_CHAR *macarg1 PARAMS ((U_CHAR *, const U_CHAR *, struct hashnode *, int *, int *, int *, int));
 
-static int discard_comments PROTO((U_CHAR *, int, int));
+static int discard_comments PARAMS ((U_CHAR *, int, int));
 
-static void change_newlines PROTO((struct argdata *));
+static void change_newlines PARAMS ((struct argdata *));
 
-static void notice PVPROTO((const char *, ...)) ATTRIBUTE_PRINTF_1;
-static void vnotice PROTO((const char *, va_list));
-void error PVPROTO((const char *, ...)) ATTRIBUTE_PRINTF_1;
-void verror PROTO((const char *, va_list));
-static void error_from_errno PROTO((const char *));
-void warning PVPROTO((const char *, ...)) ATTRIBUTE_PRINTF_1;
-static void vwarning PROTO((const char *, va_list));
-static void error_with_line PVPROTO((int, const char *, ...)) ATTRIBUTE_PRINTF_2;
-static void verror_with_line PROTO((int, const char *, va_list));
-static void vwarning_with_line PROTO((int, const char *, va_list));
-static void warning_with_line PVPROTO((int, const char *, ...)) ATTRIBUTE_PRINTF_2;
-void pedwarn PVPROTO((const char *, ...)) ATTRIBUTE_PRINTF_1;
-void pedwarn_with_line PVPROTO((int, const char *, ...)) ATTRIBUTE_PRINTF_2;
-static void pedwarn_with_file_and_line PVPROTO((const char *, size_t, int, const char *, ...)) ATTRIBUTE_PRINTF_4;
-static void pedwarn_strange_white_space PROTO((int));
+static void notice PARAMS ((const char *, ...)) ATTRIBUTE_PRINTF_1;
+static void vnotice PARAMS ((const char *, va_list));
+void error PARAMS ((const char *, ...)) ATTRIBUTE_PRINTF_1;
+void verror PARAMS ((const char *, va_list));
+static void error_from_errno PARAMS ((const char *));
+void warning PARAMS ((const char *, ...)) ATTRIBUTE_PRINTF_1;
+static void vwarning PARAMS ((const char *, va_list));
+static void error_with_line PARAMS ((int, const char *, ...)) ATTRIBUTE_PRINTF_2;
+static void verror_with_line PARAMS ((int, const char *, va_list));
+static void vwarning_with_line PARAMS ((int, const char *, va_list));
+static void warning_with_line PARAMS ((int, const char *, ...)) ATTRIBUTE_PRINTF_2;
+void pedwarn PARAMS ((const char *, ...)) ATTRIBUTE_PRINTF_1;
+void pedwarn_with_line PARAMS ((int, const char *, ...)) ATTRIBUTE_PRINTF_2;
+static void pedwarn_with_file_and_line PARAMS ((const char *, size_t, int, const char *, ...)) ATTRIBUTE_PRINTF_4;
+static void pedwarn_strange_white_space PARAMS ((int));
 
-static void print_containing_files PROTO((void));
+static void print_containing_files PARAMS ((void));
 
-static int line_for_error PROTO((int));
-static int grow_outbuf PROTO((FILE_BUF *, int));
+static int line_for_error PARAMS ((int));
+static int grow_outbuf PARAMS ((FILE_BUF *, int));
 
-static HASHNODE *install PROTO((const U_CHAR *, int, enum node_type,
-                               const char *, int));
-HASHNODE *lookup PROTO((const U_CHAR *, int, int));
-static void delete_macro PROTO((HASHNODE *));
-static int hashf PROTO((const U_CHAR *, int, int));
+static HASHNODE *install PARAMS ((const U_CHAR *, int, enum node_type,
+                                 const char *, int));
+HASHNODE *lookup PARAMS ((const U_CHAR *, int, int));
+static void delete_macro PARAMS ((HASHNODE *));
+static int hashf PARAMS ((const U_CHAR *, int, int));
 
-static void dump_single_macro PROTO((HASHNODE *, FILE *));
-static void dump_all_macros PROTO((void));
-static void dump_defn_1 PROTO((const U_CHAR *, int, int, FILE *));
-static void dump_arg_n PROTO((DEFINITION *, int, FILE *));
+static void dump_single_macro PARAMS ((HASHNODE *, FILE *));
+static void dump_all_macros PARAMS ((void));
+static void dump_defn_1 PARAMS ((const U_CHAR *, int, int, FILE *));
+static void dump_arg_n PARAMS ((DEFINITION *, int, FILE *));
 
-static void initialize_char_syntax PROTO((void));
-static void initialize_builtins PROTO((FILE_BUF *, FILE_BUF *));
+static void initialize_char_syntax PARAMS ((void));
+static void initialize_builtins PARAMS ((FILE_BUF *, FILE_BUF *));
 
-static void make_definition PROTO((char *));
-static void make_undef PROTO((char *, FILE_BUF *));
+static void make_definition PARAMS ((char *));
+static void make_undef PARAMS ((char *, FILE_BUF *));
 
-static void make_assertion PROTO((const char *, const char *));
+static void make_assertion PARAMS ((const char *, const char *));
 
-static struct file_name_list *new_include_prefix PROTO((struct file_name_list *, const char *, const char *, const char *));
-static void append_include_chain PROTO((struct file_name_list *, struct file_name_list *));
+static struct file_name_list *new_include_prefix PARAMS ((struct file_name_list *, const char *, const char *, const char *));
+static void append_include_chain PARAMS ((struct file_name_list *, struct file_name_list *));
 
-static int quote_string_for_make PROTO((char *, const char *));
-static void deps_output PROTO((const char *, int));
+static int quote_string_for_make PARAMS ((char *, const char *));
+static void deps_output PARAMS ((const char *, int));
 
-void fatal PVPROTO((const char *, ...)) ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
-void fancy_abort PROTO((void)) ATTRIBUTE_NORETURN;
-static void perror_with_name PROTO((const char *));
-static void pfatal_with_name PROTO((const char *)) ATTRIBUTE_NORETURN;
-static void pipe_closed PROTO((int)) ATTRIBUTE_NORETURN;
+void fatal PARAMS ((const char *, ...)) ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
+void fancy_abort PARAMS ((void)) ATTRIBUTE_NORETURN;
+static void perror_with_name PARAMS ((const char *));
+static void pfatal_with_name PARAMS ((const char *)) ATTRIBUTE_NORETURN;
+static void pipe_closed PARAMS ((int)) ATTRIBUTE_NORETURN;
 
-static void memory_full PROTO((void)) ATTRIBUTE_NORETURN;
-static void print_help PROTO((void));
+static void memory_full PARAMS ((void)) ATTRIBUTE_NORETURN;
+static void print_help PARAMS ((void));
 \f
 /* Read LEN bytes at PTR from descriptor DESC, for file FILENAME,
    retrying if necessary.  If MAX_READ_LEN is defined, read at most
@@ -1132,10 +1126,11 @@ print_help ()
   printf ("  -lang-objc                Assume that the input sources are in ObjectiveC\n");
   printf ("  -lang-objc++              Assume that the input sources are in ObjectiveC++\n");
   printf ("  -lang-asm                 Assume that the input sources are in assembler\n");
+  printf ("  -lang-fortran            Assume that the input sources are in Fortran\n");
   printf ("  -lang-chill               Assume that the input sources are in Chill\n");
   printf ("  -std=<std name>           Specify the conformance standard; one of:\n");
-  printf ("                            gnu89, gnu9x, c89, c9x, iso9899:1990,\n");
-  printf ("                            iso9899:199409, iso9899:199x\n");
+  printf ("                            gnu89, gnu99, c89, c99, iso9899:1990,\n");
+  printf ("                            iso9899:199409, iso9899:1999\n");
   printf ("  -+                        Allow parsing of C++ style features\n");
   printf ("  -w                        Inhibit warning messages\n");
   printf ("  -Wtrigraphs               Warn if trigraphs are encountered\n");
@@ -1263,7 +1258,7 @@ main (argc, argv)
      progname need to be set first, in case a diagnostic is issued.  */
      
   pend_files = (char **) xmalloc (argc * sizeof (char *));
-  pend_defs = (char **) xmalloc (argc * sizeof (char *));
+  pend_defs = (char **) xmalloc ((2 * argc) * sizeof (char *));
   pend_undefs = (char **) xmalloc (argc * sizeof (char *));
   pend_assertions = (char **) xmalloc (argc * sizeof (char *));
   pend_includes = (char **) xmalloc (argc * sizeof (char *));
@@ -1283,7 +1278,7 @@ main (argc, argv)
   cplusplus_comments = 1;
 
   bzero ((char *) pend_files, argc * sizeof (char *));
-  bzero ((char *) pend_defs, argc * sizeof (char *));
+  bzero ((char *) pend_defs, (2 * argc) * sizeof (char *));
   bzero ((char *) pend_undefs, argc * sizeof (char *));
   bzero ((char *) pend_assertions, argc * sizeof (char *));
   bzero ((char *) pend_includes, argc * sizeof (char *));
@@ -1451,17 +1446,23 @@ main (argc, argv)
 
       case 'l':
        if (! strcmp (argv[i], "-lang-c"))
-         cplusplus = 0, cplusplus_comments = 1, c89 = 0, c9x = 1, objc = 0;
+         cplusplus = 0, cplusplus_comments = 1, c89 = 0, c99 = 1, objc = 0;
        else if (! strcmp (argv[i], "-lang-c89"))
-         cplusplus = 0, cplusplus_comments = 0, c89 = 1, c9x = 0, objc = 0;
+         {
+           cplusplus = 0, cplusplus_comments = 0, c89 = 1, c99 = 0, objc = 0;
+           no_trigraphs = 0;
+           pend_defs[2*i] = "__STRICT_ANSI__";
+         }
        else if (! strcmp (argv[i], "-lang-c++"))
-         cplusplus = 1, cplusplus_comments = 1, c89 = 0, c9x = 0, objc = 0;
+         cplusplus = 1, cplusplus_comments = 1, c89 = 0, c99 = 0, objc = 0;
        else if (! strcmp (argv[i], "-lang-objc"))
-         cplusplus = 0, cplusplus_comments = 1, c89 = 0, c9x = 0, objc = 1;
+         cplusplus = 0, cplusplus_comments = 1, c89 = 0, c99 = 0, objc = 1;
        else if (! strcmp (argv[i], "-lang-objc++"))
-         cplusplus = 1, cplusplus_comments = 1, c89 = 0, c9x = 0, objc = 1;
+         cplusplus = 1, cplusplus_comments = 1, c89 = 0, c99 = 0, objc = 1;
        else if (! strcmp (argv[i], "-lang-asm"))
          lang_asm = 1;
+       else if (! strcmp (argv[i], "-lang-fortran"))
+         /* Doesn't actually do anything.  */ ;
        else if (! strcmp (argv[i], "-lint"))
          for_lint = 1;
        break;
@@ -1471,15 +1472,40 @@ main (argc, argv)
        break;
 
       case 's':
-       if (!strcmp (argv[i], "-std=iso9899:1990")
-           || !strcmp (argv[i], "-std=iso9899:199409")
-           || !strcmp (argv[i], "-std=c89")
-           || !strcmp (argv[i], "-std=gnu89"))
-         cplusplus = 0, cplusplus_comments = 0, c89 = 1, c9x = 0, objc = 0;
+       if (!strcmp (argv[i], "-std=gnu89"))
+         {
+           cplusplus = 0, cplusplus_comments = 0, c89 = 1, c99 = 0, objc = 0;
+         }
+       else if (!strcmp (argv[i], "-std=gnu9x")
+                || !strcmp (argv[i], "-std=gnu99"))
+         {
+           cplusplus = 0, cplusplus_comments = 1, c89 = 0, c99 = 1, objc = 0;
+           pend_defs[2*i+1] = "__STDC_VERSION__=199901L";
+         }
+       else if (!strcmp (argv[i], "-std=iso9899:1990")
+                || !strcmp (argv[i], "-std=c89"))
+         {
+           cplusplus = 0, cplusplus_comments = 0, c89 = 1, c99 = 0, objc = 0;
+           no_trigraphs = 0;
+           pend_defs[2*i] = "__STRICT_ANSI__";
+         }
+       else if (!strcmp (argv[i], "-std=iso9899:199409"))
+         {
+           cplusplus = 0, cplusplus_comments = 0, c89 = 1, c99 = 0, objc = 0;
+           no_trigraphs = 0;
+           pend_defs[2*i] = "__STRICT_ANSI__";
+           pend_defs[2*i+1] = "__STDC_VERSION__=199409L";
+         }
         else if (!strcmp (argv[i], "-std=iso9899:199x")
+                || !strcmp (argv[i], "-std=iso9899:1999")
                 || !strcmp (argv[i], "-std=c9x")
-                || !strcmp (argv[i], "-std=gnu9x"))
-         cplusplus = 0, cplusplus_comments = 1, c89 = 0, c9x = 1, objc = 0;
+                || !strcmp (argv[i], "-std=c99"))
+         {
+           cplusplus = 0, cplusplus_comments = 1, c89 = 0, c99 = 1, objc = 0;
+           no_trigraphs = 0;
+           pend_defs[2*i] = "__STRICT_ANSI__";
+           pend_defs[2*i+1] = "__STDC_VERSION__=199901L";
+         }
        break;
 
       case 'w':
@@ -1628,11 +1654,11 @@ main (argc, argv)
 
       case 'D':
        if (argv[i][2] != 0)
-         pend_defs[i] = argv[i] + 2;
+         pend_defs[2*i] = argv[i] + 2;
        else if (i + 1 == argc)
          fatal ("Macro name missing after -D option");
        else
-         i++, pend_defs[i] = argv[i];
+         i++, pend_defs[2*i] = argv[i];
        break;
 
       case 'A':
@@ -1653,7 +1679,7 @@ main (argc, argv)
               that were passed automatically in from GCC.  */
            int j;
            for (j = 0; j < i; j++)
-             pend_defs[j] = pend_assertions[j] = 0;
+             pend_defs[2*j] = pend_assertions[j] = 0;
          } else {
            pend_assertions[i] = p;
            pend_assertion_options[i] = "-A";
@@ -1690,7 +1716,7 @@ main (argc, argv)
          struct file_name_list *dirtmp;
          char *dir = argv[i][2] ? argv[i] + 2 : argv[++i];
 
-         if (! ignore_srcdir && !strcmp (dir, "-")) {
+         if (! ignore_srcdir && dir && !strcmp (dir, "-")) {
            ignore_srcdir = 1;
            /* Don't use any preceding -I directories for #include <...>.  */
            first_bracket_include = 0;
@@ -1760,11 +1786,6 @@ main (argc, argv)
   fp->nominal_fname_len = strlen (in_fname);
   fp->lineno = 0;
 
-  /* In C++, wchar_t is a distinct basic type, and we can expect
-     __wchar_t to be defined by cc1plus.  */
-  if (cplusplus)
-    wchar_type = "__wchar_t";
-
   /* Install __LINE__, etc.  Must follow initialize_char_syntax
      and option processing.  */
   initialize_builtins (fp, &outbuf);
@@ -1778,10 +1799,15 @@ main (argc, argv)
         output_line_directive (fp, &outbuf, 0, same_file);
       make_undef (pend_undefs[i], &outbuf);
     }
-    if (pend_defs[i]) {
+    if (pend_defs[2*i]) {
+      if (debug_output)
+        output_line_directive (fp, &outbuf, 0, same_file);
+      make_definition (pend_defs[2*i]);
+    }
+    if (pend_defs[2*i+1]) {
       if (debug_output)
         output_line_directive (fp, &outbuf, 0, same_file);
-      make_definition (pend_defs[i]);
+      make_definition (pend_defs[2*i+1]);
     }
     if (pend_assertions[i])
       make_assertion (pend_assertion_options[i], pend_assertions[i]);
@@ -2239,7 +2265,7 @@ index0 (s, c, n)
   for (;;) {
     const char *q = index (p, c);
     if (q)
-      return q;
+      return (const U_CHAR *) q;
     else {
       size_t l = strlen (p);
       if (l == n)
@@ -4021,7 +4047,7 @@ handle_directive (ip, op)
          case '\'':
          case '\"':
            {
-             int backslash_newlines_p;
+             int backslash_newlines_p = 0;
 
              register const U_CHAR *bp1
                = skip_quoted_string (xp - 1, bp, ip->lineno,
@@ -4242,9 +4268,11 @@ special_symbol (hp, op)
     break;
 #endif
 
+#ifndef NO_BUILTIN_WCHAR_TYPE
   case T_WCHAR_TYPE:
     buf = wchar_type;
     break;
+#endif
 
   case T_USER_LABEL_PREFIX_TYPE:
     buf = user_label_prefix;
@@ -4554,7 +4582,9 @@ get_filename:
         since it would put extra spaces in include file names.  */
       U_CHAR *src;
       int errors_before_expansion = errors;
-      FILE_BUF trybuf = expand_to_temp_buffer (buf, limit, 1, 0);
+      FILE_BUF trybuf;
+
+      trybuf = expand_to_temp_buffer (buf, limit, 1, 0);
       if (errors != errors_before_expansion) {
        free (trybuf.buf);
        goto invalid_include_file_name;
@@ -4882,7 +4912,7 @@ absolute_filename (filename)
 
 /* Returns whether or not a given character is a directory separator.
    Used by simplify_filename.  */
-static inline int is_dir_separator PROTO ((int));
+static inline int is_dir_separator PARAMS ((int));
 
 static inline
 int
@@ -5813,10 +5843,10 @@ create_definition (buf, limit, op)
 
       if (!is_idstart[*bp])
        {
-         if (c9x && limit - bp > (long) REST_EXTENSION_LENGTH
+         if (c99 && limit - bp > (long) REST_EXTENSION_LENGTH
              && bcmp (rest_extension, bp, REST_EXTENSION_LENGTH) == 0)
            {
-             /* This is the ISO C 9x way to write macros with variable
+             /* This is the ISO C 99 way to write macros with variable
                 number of arguments.  */
              rest_args = 1;
              temp->rest_args = 1;
@@ -5840,7 +5870,7 @@ create_definition (buf, limit, op)
       }
       if (bp == temp->name && rest_args == 1)
        {
-         /* This is the ISO C 9x style.  */
+         /* This is the ISO C 99 style.  */
          temp->name = (U_CHAR *) va_args_name;
          temp->length = VA_ARGS_NAME_LENGTH;
        }
@@ -5859,7 +5889,7 @@ create_definition (buf, limit, op)
        SKIP_WHITE_SPACE (bp);
        /* A comma at this point can only be followed by an identifier.  */
        if (!is_idstart[*bp]
-           && !(c9x && limit - bp > (long) REST_EXTENSION_LENGTH
+           && !(c99 && limit - bp > (long) REST_EXTENSION_LENGTH
                &&  bcmp (rest_extension, bp, REST_EXTENSION_LENGTH) == 0)) {
          error ("badly punctuated parameter list in `#define'");
          goto nope;
@@ -6064,13 +6094,20 @@ check_macro_name (symname, assertion)
   sym_length = p - symname;
   if (sym_length == 0
       || (sym_length == 1 && *symname == 'L' && (*p == '\'' || *p == '"')))
-    error (assertion ? "invalid assertion name" : "invalid macro name");
+    {
+      if (assertion)
+       error ("invalid assertion name");
+      else
+       error ("invalid macro name");
+    }
   else if (!is_idstart[*symname]
           || (sym_length == 7 && ! bcmp (symname, "defined", 7)))
-    error ((assertion
-           ? "invalid assertion name `%.*s'"
-           : "invalid macro name `%.*s'"),
-          sym_length, symname);
+    {
+      if (assertion)
+       error ("invalid assertion name `%.*s'", sym_length, symname);
+      else
+       error ("invalid macro name `%.*s'", sym_length, symname);
+    }
   return sym_length;
 }
 
@@ -7174,7 +7211,7 @@ do_pragma (buf, limit, op, keyword)
     do_once ();
   }
 
-  if (!strncmp (buf, "poison", 6)) {
+  if (!strncmp ((char *) buf, "poison", 6)) {
     /* Poison these symbols so that all subsequent usage produces an
        error message.  */
     U_CHAR *p = buf + 6;
@@ -7419,9 +7456,12 @@ do_xifdef (buf, limit, op, keyword)
   if (end == buf) {
     skip = (keyword->type == T_IFDEF);
     if (! traditional)
-      pedwarn (end == limit ? "`#%s' with no argument"
-              : "`#%s' argument starts with punctuation",
-              keyword->name);
+      {
+       if (end == limit)
+         pedwarn ("`#%s' with no argument", keyword->name);
+       else
+         pedwarn ("`#%s' argument starts with punctuation", keyword->name);
+      }
   } else {
     HASHNODE *hp;
 
@@ -8431,14 +8471,20 @@ output_line_directive (ip, op, conditional, file_change)
    into the macro.  If the actual use count exceeds 10, 
    the value stored is 10.
    `free1' and `free2', if nonzero, point to blocks to be freed
-   when the macro argument data is no longer needed.  */
+   when the macro argument data is no longer needed.
+   `free_ptr', if nonzero, points to a value of instack[i].free_ptr
+   where the raw field points somewhere into this string.  The purpose
+   of this is to hold onto instack[i].buf for macro arguments, even
+   when the element has been popped off the input stack.
+*/
 
 struct argdata {
   U_CHAR *raw, *expanded;
   int raw_length, expand_length, expand_size;
   int stringified_length_bound;
   U_CHAR *free1, *free2;
-  char newlines;
+  U_CHAR *free_ptr;
+  int newlines;
   char use_count;
 };
 
@@ -8490,6 +8536,7 @@ macroexpand (hp, op)
       args[i].raw_length = args[i].expand_length = args[i].expand_size
        = args[i].stringified_length_bound = 0;
       args[i].free1 = args[i].free2 = 0;
+      args[i].free_ptr = 0;
       args[i].use_count = 0;
     }
 
@@ -8581,7 +8628,12 @@ macroexpand (hp, op)
         Also count number of times each arg is used.  */
       xbuf_len = defn->length;
       for (ap = defn->pattern; ap != NULL; ap = ap->next) {
-       if (ap->stringify)
+       if (ap->stringify && args[ap->argno].stringified_length_bound == 0)
+         /* macarg is not called for omitted arguments, as a result
+            stringified_length_bound will be zero.  We need to make
+            enough space for "".  */
+         xbuf_len += 2;
+       else if (ap->stringify)
          xbuf_len += args[ap->argno].stringified_length_bound;
        else if (ap->raw_before != 0 || ap->raw_after != 0 || traditional)
          /* Add 4 for two newline-space markers to prevent
@@ -8828,6 +8880,18 @@ macroexpand (hp, op)
       xbuf_len = totlen;
 
       for (i = 0; i < nargs; i++) {
+        if (args[i].free_ptr != 0) {
+          U_CHAR *buf = args[i].free_ptr;
+          int d;
+          for (d = indepth; d >= 0; --d) {
+            if (instack[d].buf == buf) {
+              instack[d].free_ptr = buf; /* Give ownership back to instack */
+              goto no_free;
+            }
+          }
+          free (buf); /* buf is not on the stack; must have been popped */
+        no_free:;
+        }
        if (args[i].free1 != 0)
          free (args[i].free1);
        if (args[i].free2 != 0)
@@ -8898,6 +8962,11 @@ macarg (argptr, rest_args)
       argptr->raw = ip->bufp;
       argptr->raw_length = bp - ip->bufp;
       argptr->newlines = ip->lineno - lineno0;
+      /* The next two statements transfer ownership of the the buffer
+        from ip to argptr.  Note that the second statement ensures that
+        a given free_ptr is owned by at most one macro argument. */
+      argptr->free_ptr = ip->free_ptr;
+      ip->free_ptr     = 0;
     }
     ip->bufp = bp;
   } else {
@@ -9376,7 +9445,7 @@ change_newlines (arg)
 /* notice - output message to stderr */
 
 static void
-notice VPROTO ((const char * msgid, ...))
+notice VPARAMS ((const char * msgid, ...))
 {
 #ifndef ANSI_PROTOTYPES
   const char * msgid;
@@ -9404,7 +9473,7 @@ vnotice (msgid, args)
 /* error - print error message and increment count of errors.  */
 
 void
-error VPROTO ((const char * msgid, ...))
+error VPARAMS ((const char * msgid, ...))
 {
 #ifndef ANSI_PROTOTYPES
   const char * msgid;
@@ -9479,7 +9548,7 @@ error_from_errno (name)
 /* Print error message but don't count it.  */
 
 void
-warning VPROTO ((const char * msgid, ...))
+warning VPARAMS ((const char * msgid, ...))
 {
 #ifndef ANSI_PROTOTYPES
   const char * msgid;
@@ -9529,7 +9598,7 @@ vwarning (msgid, args)
 }
 
 static void
-error_with_line VPROTO ((int line, const char * msgid, ...))
+error_with_line VPARAMS ((int line, const char * msgid, ...))
 {
 #ifndef ANSI_PROTOTYPES
   int line;
@@ -9577,7 +9646,7 @@ verror_with_line (line, msgid, args)
 }
 
 static void
-warning_with_line VPROTO ((int line, const char * msgid, ...))
+warning_with_line VPARAMS ((int line, const char * msgid, ...))
 {
 #ifndef ANSI_PROTOTYPES
   int line;
@@ -9622,7 +9691,10 @@ vwarning_with_line (line, msgid, args)
   if (ip != NULL) {
     fwrite (ip->nominal_fname, sizeof ip->nominal_fname[0],
            ip->nominal_fname_len, stderr);
-    fprintf (stderr, line ? ":%d: " : ": ", line);
+    if (line)
+      fprintf (stderr, ":%d: ", line);
+    else
+      fputs (": ", stderr);
   }
   notice ("warning: ");
   vnotice (msgid, args);
@@ -9632,7 +9704,7 @@ vwarning_with_line (line, msgid, args)
 /* Print an error message and maybe count it.  */
 
 void
-pedwarn VPROTO ((const char * msgid, ...))
+pedwarn VPARAMS ((const char * msgid, ...))
 {
 #ifndef ANSI_PROTOTYPES
   const char * msgid;
@@ -9653,7 +9725,7 @@ pedwarn VPROTO ((const char * msgid, ...))
 }
 
 void
-pedwarn_with_line VPROTO ((int line, const char * msgid, ...))
+pedwarn_with_line VPARAMS ((int line, const char * msgid, ...))
 {
 #ifndef ANSI_PROTOTYPES
   int line;
@@ -9679,8 +9751,8 @@ pedwarn_with_line VPROTO ((int line, const char * msgid, ...))
    giving specified file name and line number, not current.  */
 
 static void
-pedwarn_with_file_and_line VPROTO ((const char *file, size_t file_len, int line,
-                                   const char * msgid, ...))
+pedwarn_with_file_and_line VPARAMS ((const char *file, size_t file_len,
+                                    int line, const char * msgid, ...))
 {
 #ifndef ANSI_PROTOTYPES
   const char *file;
@@ -10177,10 +10249,13 @@ initialize_char_syntax ()
    * refer to them.
    */
   for (i = 'a'; i <= 'z'; i++) {
-    is_idchar[TOUPPER(i)] = 1;
-    is_idchar[i] = 1;
-    is_idstart[TOUPPER(i)] = 1;
-    is_idstart[i] = 1;
+    /* SKIP EBCIDIC holes, char must be a valid low case char */
+    if (ISLOWER(i)) {
+      is_idchar[TOUPPER(i)] = 1;
+      is_idchar[i] = 1;
+      is_idstart[TOUPPER(i)] = 1;
+      is_idstart[i] = 1;
+    }
   }
   for (i = '0'; i <= '9'; i++)
     is_idchar[i] = 1;
@@ -10223,7 +10298,9 @@ initialize_builtins (inp, outp)
 #ifndef NO_BUILTIN_PTRDIFF_TYPE
   install ((const U_CHAR *) "__PTRDIFF_TYPE__ ", -1, T_PTRDIFF_TYPE, NULL_PTR, -1);
 #endif
+#ifndef NO_BUILTIN_WCHAR_TYPE
   install ((const U_CHAR *) "__WCHAR_TYPE__", -1, T_WCHAR_TYPE, NULL_PTR, -1);
+#endif
   install ((const U_CHAR *) "__USER_LABEL_PREFIX__", -1, T_USER_LABEL_PREFIX_TYPE,
           NULL_PTR, -1);
   install ((const U_CHAR *) "__REGISTER_PREFIX__", -1, T_REGISTER_PREFIX_TYPE,
@@ -10272,10 +10349,12 @@ initialize_builtins (inp, outp)
                           outp, dp);
 #endif
 
+#ifndef NO_BUILTIN_WCHAR_TYPE
       sprintf (directive, " __WCHAR_TYPE__ %s\n", wchar_type);
       output_line_directive (inp, outp, 0, same_file);
       pass_thru_directive (udirective, &udirective[strlen (directive)],
                           outp, dp);
+#endif
 
       sprintf (directive, " __DATE__ \"%s %2d %4d\"\n",
               monthnames[timebuf->tm_mon],
@@ -10733,7 +10812,7 @@ deps_output (string, spacer)
 }
 \f
 void
-fatal VPROTO ((const char * msgid, ...))
+fatal VPARAMS ((const char * msgid, ...))
 {
 #ifndef ANSI_PROTOTYPES
   const char * msgid;