* cppp.c (main): Set trigraphs and __STRICT_ANSI__ as
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 14 Dec 1999 16:05:23 +0000 (16:05 +0000)
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 14 Dec 1999 16:05:23 +0000 (16:05 +0000)
        appropriate for -lang-c89 and -std=*.
        * cppinit.c (cpp_handle_option): Likewise.
        (new_pending_define): New, split out from cpp_handle_option.
        * gcc.c (default_compilers): Don't define __STRICT_ANSI__
        or enable trigraphs for -ansi/-std=*.

        * ginclude/stdarg.h (__va_copy): New.
        (va_copy): Don't define for C89.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@30921 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cccp.c
gcc/cppinit.c
gcc/gcc.c
gcc/ginclude/stdarg.h

index a21daf1..4acc214 100644 (file)
@@ -1454,7 +1454,11 @@ main (argc, argv)
        if (! strcmp (argv[i], "-lang-c"))
          cplusplus = 0, cplusplus_comments = 1, c89 = 0, c9x = 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, c9x = 0, objc = 0;
+           no_trigraphs = 0;
+           pend_defs[i] = "__STRICT_ANSI__=199000";
+         }
        else if (! strcmp (argv[i], "-lang-c++"))
          cplusplus = 1, cplusplus_comments = 1, c89 = 0, c9x = 0, objc = 0;
        else if (! strcmp (argv[i], "-lang-objc"))
@@ -1472,15 +1476,37 @@ 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, c9x = 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;
+         }
+       else if (!strcmp (argv[i], "-std=iso9899:1990")
+                || !strcmp (argv[i], "-std=c89"))
+         {
+           cplusplus = 0, cplusplus_comments = 0, c89 = 1, c9x = 0, objc = 0;
+           no_trigraphs = 0;
+           pend_defs[i] = "__STRICT_ANSI__=199000";
+         }
+       else if (!strcmp (argv[i], "-std=iso9899:199409"))
+         {
+           cplusplus = 0, cplusplus_comments = 0, c89 = 1, c9x = 0, objc = 0;
+           no_trigraphs = 0;
+           pend_defs[i] = "__STRICT_ANSI__=199409";
+         }
         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, c9x = 1, objc = 0;
+           no_trigraphs = 0;
+           pend_defs[i] = "__STRICT_ANSI__=199900";
+         }
        break;
 
       case 'w':
index 4343b23..3ffda8a 100644 (file)
@@ -1069,6 +1069,20 @@ cpp_finish (pfile)
     }
 }
 
+static void
+new_pending_define (opts, text)
+     struct cpp_options *opts;
+     const char *text;
+{
+  struct pending_option *o = (struct pending_option *)
+    xmalloc (sizeof (struct pending_option));
+
+  o->arg = text;
+  o->next = NULL;
+  o->undef = 0;
+  APPEND (opts->pending, define, o);
+}
+
 /* Handle one command-line option in (argc, argv).
    Can be called multiple times, to handle multiple sets of options.
    Returns number of strings consumed.  */
@@ -1313,8 +1327,12 @@ cpp_handle_option (pfile, argc, argv)
          opts->cplusplus = 0, opts->cplusplus_comments = 1, opts->c89 = 0,
            opts->c9x = 1, opts->objc = 0;
        if (! strcmp (argv[i], "-lang-c89"))
-         opts->cplusplus = 0, opts->cplusplus_comments = 0, opts->c89 = 1,
-           opts->c9x = 0, opts->objc = 0;
+         {
+           opts->cplusplus = 0, opts->cplusplus_comments = 0;
+           opts->c89 = 1, opts->c9x = 0, opts->objc = 0;
+           opts->trigraphs = 1;
+           new_pending_define (opts, "__STRICT_ANSI__=199000");
+         }
        if (! strcmp (argv[i], "-lang-c++"))
          opts->cplusplus = 1, opts->cplusplus_comments = 1, opts->c89 = 0,
            opts->c9x = 0, opts->objc = 0;
@@ -1338,17 +1356,41 @@ cpp_handle_option (pfile, 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"))
-         opts->cplusplus = 0, opts->cplusplus_comments = 0,
+       if (!strcmp (argv[i], "-std=gnu89"))
+         {
+           opts->cplusplus = 0, opts->cplusplus_comments = 0;
+           opts->c89 = 1, opts->c9x = 0, opts->objc = 0;
+         }
+       else if (!strcmp (argv[i], "-std=gnu9x"))
+         {
+           opts->cplusplus = 0, opts->cplusplus_comments = 1;
+           opts->c89 = 0, opts->c9x = 1, opts->objc = 0;
+         }
+       else if (!strcmp (argv[i], "-std=iso9899:1990")
+                || !strcmp (argv[i], "-std=c89"))
+         {
+           opts->cplusplus = 0, opts->cplusplus_comments = 0;
            opts->c89 = 1, opts->c9x = 0, opts->objc = 0;
+           opts->trigraphs = 1;
+           new_pending_define (opts, "__STRICT_ANSI__=199000");
+         }
+       else if (!strcmp (argv[i], "-std=iso9899:199409"))
+         {
+           opts->cplusplus = 0, opts->cplusplus_comments = 0;
+           opts->c89 = 1, opts->c9x = 0, opts->objc = 0;
+           opts->trigraphs = 1;
+           new_pending_define (opts, "__STRICT_ANSI__=199409");
+         }
        else if (!strcmp (argv[i], "-std=iso9899:199x")
+                || !strcmp (argv[i], "-std=iso9899:1999")
                 || !strcmp (argv[i], "-std=c9x")
-                || !strcmp (argv[i], "-std=gnu9x"))
-         opts->cplusplus = 0, opts->cplusplus_comments = 1, opts->c89 = 0,
-           opts->c9x = 1, opts->objc = 0;
+                || !strcmp (argv[i], "-std=c99"))
+         {
+           opts->cplusplus = 0, opts->cplusplus_comments = 1;
+           opts->c89 = 0, opts->c9x = 1, opts->objc = 0;
+           opts->trigraphs = 1;
+           new_pending_define (opts, "__STRICT_ANSI__=199900");
+         }
        break;
 
       case 'w':
@@ -1487,21 +1529,17 @@ cpp_handle_option (pfile, argc, argv)
       
       case 'D':
        {
-         struct pending_option *o = (struct pending_option *)
-           xmalloc (sizeof (struct pending_option));
+         const char *text;
          if (argv[i][2] != 0)
-           o->arg = argv[i] + 2;
+           text = argv[i] + 2;
          else if (i + 1 == argc)
            {
              cpp_fatal (pfile, "Macro name missing after -D option");
              return argc;
            }
          else
-           o->arg = argv[++i];
-
-         o->next = NULL;
-         o->undef = 0;
-         APPEND (opts->pending, define, o);
+           text = argv[++i];
+         new_pending_define (opts, text);
        }
        break;
       
index e6ae802..0230b49 100644 (file)
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -628,7 +628,6 @@ static struct compiler default_compilers[] =
        %{C:%{!E:%eGNU C does not support -C without using -E}}\
        %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\
         %{!no-gcc:-D__GNUC__=%v1 -D__GNUC_MINOR__=%v2}\
-       %{ansi|std=*:%{!std=gnu*:-trigraphs -D__STRICT_ANSI__}}\
        %{!undef:%{!ansi:%{!std=*:%p}%{std=gnu*:%p}} %P} %{trigraphs}\
         %c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\
        %{ffast-math:-D__FAST_MATH__}\
@@ -643,7 +642,6 @@ static struct compiler default_compilers[] =
                   %{!Q:-quiet} -dumpbase %b.c %{d*} %{m*} %{a*}\
                   %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\
                   %{!no-gcc:-D__GNUC__=%v1 -D__GNUC_MINOR__=%v2}\
-                 %{ansi|std=*:%{!std=gnu*:-trigraphs -D__STRICT_ANSI__}}\
                  %{!undef:%{!ansi:%{!std=*:%p}%{std=gnu*:%p}} %P} %{trigraphs}\
                   %c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\
                  %{ffast-math:-D__FAST_MATH__}\
@@ -667,7 +665,6 @@ static struct compiler default_compilers[] =
        %{C:%{!E:%eGNU C does not support -C without using -E}}\
        %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\
         %{!no-gcc:-D__GNUC__=%v1 -D__GNUC_MINOR__=%v2}\
-       %{ansi|std=*:%{!std=gnu*:-trigraphs -D__STRICT_ANSI__}}\
        %{!undef:%{!ansi:%{!std=*:%p}%{std=gnu*:%p}} %P} %{trigraphs}\
         %c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\
        %{ffast-math:-D__FAST_MATH__}\
@@ -696,7 +693,6 @@ static struct compiler default_compilers[] =
        %{C:%{!E:%eGNU C does not support -C without using -E}}\
        %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\
         %{!no-gcc:-D__GNUC__=%v1 -D__GNUC_MINOR__=%v2}\
-       %{ansi|std=*:%{!std=gnu*:-trigraphs -D__STRICT_ANSI__}}\
        %{!undef:%{!ansi:%{!std=*:%p}%{std=gnu*:%p}} %P} %{trigraphs}\
         %c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\
        %{ffast-math:-D__FAST_MATH__}\
@@ -714,7 +710,6 @@ static struct compiler default_compilers[] =
        %{C:%{!E:%eGNU C does not support -C without using -E}}\
        %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\
         %{!no-gcc:-D__GNUC__=%v1 -D__GNUC_MINOR__=%v2}\
-       %{std=*:%{!std=gnu*:-trigraphs -D__STRICT_ANSI__}}\
        %{!undef:%{!std=*:%p}%{std=gnu*:%p} %P} %{trigraphs}\
         %c %{Os:-D__OPTIMIZE_SIZE__} %{O*:%{!O0:-D__OPTIMIZE__}}\
        %{ffast-math:-D__FAST_MATH__}\
index 923ac3c..c74c80d 100644 (file)
@@ -54,7 +54,10 @@ typedef __builtin_va_list __gnuc_va_list;
 #define va_start(v,l)  __builtin_stdarg_start(&(v),l)
 #define va_end         __builtin_va_end
 #define va_arg         __builtin_va_arg
+#if defined(__STRICT_ANSI__) && __STRICT_ANSI__ + 0 < 199900
 #define va_copy(d,s)   __builtin_va_copy(&(d),(s))
+#endif
+#define __va_copy(d,s) __builtin_va_copy(&(d),(s))
 
 
 /* Define va_list, if desired, from __gnuc_va_list. */