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

@ -1792,15 +1792,42 @@ reparse:
break;
case TCC_OPTION_std:
if (*optarg == '=') {
++optarg;
if (strcmp(optarg, "c11") == 0) {
if (strcmp(optarg, "=c11") == 0) {
tcc_undefine_symbol(s, "__STDC_VERSION__");
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;
}
}
/* 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;
case TCC_OPTION_shared:
x = TCC_OUTPUT_DLL;