History

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

Christian Jullien committed 7 years ago

Commit 8482f9e1 parent 065a3b31 file · +40 −13Browse files

Unified · Split

libtcc.c+40−13
@@ -1608,7 +1608,7 @@ static int args_parser_make_argv(const char *r, int *argc, char ***argv) · 1607 unmodified lines
16081608 CString str;
16091609 for(;;) {
16101610 while (c = (unsigned char)*r, c && c <= ' ')
1611− ++r;
1611+ ++r;
16121612 if (c == 0)
16131613 break;
16141614 q = 0;
@@ -1681,7 +1681,7 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int *pargc, char ***pargv, int optind) · 66 unmodified lines
16811681 r = argv[optind];
16821682 if (r[0] == '@' && r[1] != '\0') {
16831683 args_parser_listfile(s, r + 1, optind, &argc, &argv);
1684− continue;
1684+ continue;
16851685 }
16861686 optind++;
16871687 if (tool) {
@@ -1792,15 +1792,42 @@ reparse: · 104 unmodified lines
17921792 break;
17931793 case TCC_OPTION_std:
17941794 if (*optarg == '=') {
1795− ++optarg;
1796− if (strcmp(optarg, "c11") == 0) {
1795+ if (strcmp(optarg, "=c11") == 0) {
17971796 tcc_undefine_symbol(s, "__STDC_VERSION__");
17981797 tcc_define_symbol(s, "__STDC_VERSION__", "201112L");
1798+ /*
1799+ * The integer constant 1, intended to indicate
1800+ * that the implementation does not support atomic
1801+ * types (including the _Atomic type qualifier) and
1802+ * the <stdatomic.h> header.
1803+ */
1804+ tcc_define_symbol(s, "__STDC_NO_ATOMICS__", "1");
1805+ /*
1806+ * The integer constant 1, intended to indicate
1807+ * that the implementation does not support complex
1808+ * types or the <complex.h> header.
1809+ */
1810+ tcc_define_symbol(s, "__STDC_NO_COMPLEX__", "1");
1811+ /*
1812+ * The integer constant 1, intended to indicate
1813+ * that the implementation does not support the
1814+ * <threads.h> header.
1815+ */
1816+ tcc_define_symbol(s, "__STDC_NO_THREADS__", "1");
1817+ /*
1818+ * __STDC_NO_VLA__, tcc supports VLA.
1819+ * The integer constant 1, intended to indicate
1820+ * that the implementation does not support
1821+ * variable length arrays or variably modified
1822+ * types.
1823+ */
17991824 s->cversion = 201112;
18001825 }
18011826 }
1802− /* silently ignore other values, a current purpose:
1803− allow to use a tcc as a reference compiler for "make test" */
1827+ /*
1828+ * silently ignore other values, a current purpose:
1829+ * allow to use a tcc as a reference compiler for "make test"
1830+ */
18041831 break;
18051832 case TCC_OPTION_shared:
18061833 x = TCC_OUTPUT_DLL;
@@ -1823,10 +1850,10 @@ reparse: · 16 unmodified lines
18231850 case TCC_OPTION_isystem:
18241851 tcc_add_sysinclude_path(s, optarg);
18251852 break;
1826− case TCC_OPTION_include:
1827− dynarray_add(&s->cmd_include_files,
1828− &s->nb_cmd_include_files, tcc_strdup(optarg));
1829− break;
1853+ case TCC_OPTION_include:
1854+ dynarray_add(&s->cmd_include_files,
1855+ &s->nb_cmd_include_files, tcc_strdup(optarg));
1856+ break;
18301857 case TCC_OPTION_nostdinc:
18311858 s->nostdinc = 1;
18321859 break;
@@ -1886,9 +1913,9 @@ reparse: · 53 unmodified lines
18861913 if (tcc_set_linker(s, linker_arg.data))
18871914 cstr_free(&linker_arg);
18881915 break;
1889− case TCC_OPTION_Wp:
1890− r = optarg;
1891− goto reparse;
1916+ case TCC_OPTION_Wp:
1917+ r = optarg;
1918+ goto reparse;
18921919 case TCC_OPTION_E:
18931920 x = TCC_OUTPUT_PREPROCESS;
18941921 goto set_output_type;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t