Add __STDC_xxx test features related to ISO/IEC C11 when -std=c11 is passed.

This commit is contained in:
Christian Jullien 2019-01-11 14:26:17 +01:00
parent 065a3b35fc
commit 8482f9e54b

View File

@ -1608,7 +1608,7 @@ static int args_parser_make_argv(const char *r, int *argc, char ***argv)
CString str; CString str;
for(;;) { for(;;) {
while (c = (unsigned char)*r, c && c <= ' ') while (c = (unsigned char)*r, c && c <= ' ')
++r; ++r;
if (c == 0) if (c == 0)
break; break;
q = 0; q = 0;
@ -1681,7 +1681,7 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int *pargc, char ***pargv, int optind)
r = argv[optind]; r = argv[optind];
if (r[0] == '@' && r[1] != '\0') { if (r[0] == '@' && r[1] != '\0') {
args_parser_listfile(s, r + 1, optind, &argc, &argv); args_parser_listfile(s, r + 1, optind, &argc, &argv);
continue; continue;
} }
optind++; optind++;
if (tool) { if (tool) {
@ -1792,15 +1792,42 @@ reparse:
break; break;
case TCC_OPTION_std: case TCC_OPTION_std:
if (*optarg == '=') { if (*optarg == '=') {
++optarg; if (strcmp(optarg, "=c11") == 0) {
if (strcmp(optarg, "c11") == 0) {
tcc_undefine_symbol(s, "__STDC_VERSION__"); tcc_undefine_symbol(s, "__STDC_VERSION__");
tcc_define_symbol(s, "__STDC_VERSION__", "201112L"); tcc_define_symbol(s, "__STDC_VERSION__", "201112L");
/*
* The integer constant 1, intended to indicate
* that the implementation does not support atomic
* types (including the _Atomic type qualifier) and
* the <stdatomic.h> header.
*/
tcc_define_symbol(s, "__STDC_NO_ATOMICS__", "1");
/*
* The integer constant 1, intended to indicate
* that the implementation does not support complex
* types or the <complex.h> header.
*/
tcc_define_symbol(s, "__STDC_NO_COMPLEX__", "1");
/*
* The integer constant 1, intended to indicate
* that the implementation does not support the
* <threads.h> header.
*/
tcc_define_symbol(s, "__STDC_NO_THREADS__", "1");
/*
* __STDC_NO_VLA__, tcc supports VLA.
* The integer constant 1, intended to indicate
* that the implementation does not support
* variable length arrays or variably modified
* types.
*/
s->cversion = 201112; s->cversion = 201112;
} }
} }
/* silently ignore other values, a current purpose: /*
allow to use a tcc as a reference compiler for "make test" */ * silently ignore other values, a current purpose:
* allow to use a tcc as a reference compiler for "make test"
*/
break; break;
case TCC_OPTION_shared: case TCC_OPTION_shared:
x = TCC_OUTPUT_DLL; x = TCC_OUTPUT_DLL;
@ -1823,10 +1850,10 @@ reparse:
case TCC_OPTION_isystem: case TCC_OPTION_isystem:
tcc_add_sysinclude_path(s, optarg); tcc_add_sysinclude_path(s, optarg);
break; break;
case TCC_OPTION_include: case TCC_OPTION_include:
dynarray_add(&s->cmd_include_files, dynarray_add(&s->cmd_include_files,
&s->nb_cmd_include_files, tcc_strdup(optarg)); &s->nb_cmd_include_files, tcc_strdup(optarg));
break; break;
case TCC_OPTION_nostdinc: case TCC_OPTION_nostdinc:
s->nostdinc = 1; s->nostdinc = 1;
break; break;
@ -1886,9 +1913,9 @@ reparse:
if (tcc_set_linker(s, linker_arg.data)) if (tcc_set_linker(s, linker_arg.data))
cstr_free(&linker_arg); cstr_free(&linker_arg);
break; break;
case TCC_OPTION_Wp: case TCC_OPTION_Wp:
r = optarg; r = optarg;
goto reparse; goto reparse;
case TCC_OPTION_E: case TCC_OPTION_E:
x = TCC_OUTPUT_PREPROCESS; x = TCC_OUTPUT_PREPROCESS;
goto set_output_type; goto set_output_type;