OSDN Git Service

* Makefile.in ($(srcdir)/c-parse.y: c-parse.in): Enclose the whole
[pf3gnuchains/gcc-fork.git] / gcc / cccp.c
index 910a98d..9a02333 100644 (file)
@@ -1,5 +1,6 @@
 /* C Compatible Compiler Preprocessor (CCCP)
-   Copyright (C) 1986, 87, 89, 92-99, 2000 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"
@@ -95,7 +97,6 @@ static void hack_vms_include_specification ();
 
 /* External declarations.  */
 
-extern char *version_string;
 HOST_WIDEST_INT parse_escape PARAMS ((char **, HOST_WIDEST_INT));
 HOST_WIDEST_INT parse_c_expression PARAMS ((char *, int));
 \f
@@ -256,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
@@ -581,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)
 
@@ -1128,8 +1129,8 @@ print_help ()
   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");
@@ -1445,19 +1446,19 @@ 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"))
@@ -1473,24 +1474,24 @@ main (argc, argv)
       case 's':
        if (!strcmp (argv[i], "-std=gnu89"))
          {
-           cplusplus = 0, cplusplus_comments = 0, c89 = 1, c9x = 0, objc = 0;
+           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, c9x = 1, objc = 0;
+           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, 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], "-std=iso9899:199409"))
          {
-           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__";
            pend_defs[2*i+1] = "__STDC_VERSION__=199409L";
@@ -1500,7 +1501,7 @@ main (argc, argv)
                 || !strcmp (argv[i], "-std=c9x")
                 || !strcmp (argv[i], "-std=c99"))
          {
-           cplusplus = 0, cplusplus_comments = 1, c89 = 0, c9x = 1, objc = 0;
+           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";
@@ -1715,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;
@@ -1785,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);
@@ -4051,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,
@@ -4272,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;
@@ -5845,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;
@@ -5872,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;
        }
@@ -5891,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;
@@ -8486,7 +8484,7 @@ struct argdata {
   int stringified_length_bound;
   U_CHAR *free1, *free2;
   U_CHAR *free_ptr;
-  char newlines;
+  int newlines;
   char use_count;
 };
 
@@ -10251,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;
@@ -10297,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,
@@ -10346,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],