Commit 223dca6a by Richard Henderson

cppp.c (main): Set trigraphs and __STRICT_ANSI__ as appropriate for -lang-c89 and -std=*.

        * cppp.c (main): Set trigraphs and __STRICT_ANSI__ as
        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.

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