| @@ -986,6 +986,27 @@ LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type) · 985 unmodified lines |
| 986 | if (s->char_is_unsigned) | 986 | if (s->char_is_unsigned) |
| 987 | tcc_define_symbol(s, "__CHAR_UNSIGNED__", NULL); | 987 | tcc_define_symbol(s, "__CHAR_UNSIGNED__", NULL); |
| 988 | | 988 | |
| | 989 | if (s->cversion == 201112) { |
| | 990 | tcc_undefine_symbol(s, "__STDC_VERSION__"); |
| | 991 | tcc_define_symbol(s, "__STDC_VERSION__", "201112L"); |
| | 992 | tcc_define_symbol(s, "__STDC_NO_ATOMICS__", NULL); |
| | 993 | tcc_define_symbol(s, "__STDC_NO_COMPLEX__", NULL); |
| | 994 | tcc_define_symbol(s, "__STDC_NO_THREADS__", NULL); |
| | 995 | #ifndef TCC_TARGET_PE |
| | 996 | /* on Linux, this conflicts with a define introduced by |
| | 997 | /usr/include/stdc-predef.h included by glibc libs |
| | 998 | tcc_define_symbol(s, "__STDC_ISO_10646__", "201605L"); */ |
| | 999 | tcc_define_symbol(s, "__STDC_UTF_16__", NULL); |
| | 1000 | tcc_define_symbol(s, "__STDC_UTF_32__", NULL); |
| | 1001 | #endif |
| | 1002 | } |
| | 1003 | |
| | 1004 | if (s->optimize > 0) |
| | 1005 | tcc_define_symbol(s, "__OPTIMIZE__", NULL); |
| | 1006 | |
| | 1007 | if (s->option_pthread) |
| | 1008 | tcc_define_symbol(s, "_REENTRANT", NULL); |
| | 1009 | |
| 989 | if (!s->nostdinc) { | 1010 | if (!s->nostdinc) { |
| 990 | /* default include paths */ | 1011 | /* default include paths */ |
| 991 | /* -isystem paths have already been handled */ | 1012 | /* -isystem paths have already been handled */ |
| @@ -1719,13 +1740,11 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int *pargc, char ***pargv, int optind) · 727 unmodified lines |
| 1719 | const TCCOption *popt; | 1740 | const TCCOption *popt; |
| 1720 | const char *optarg, *r; | 1741 | const char *optarg, *r; |
| 1721 | const char *run = NULL; | 1742 | const char *run = NULL; |
| 1722 | int last_o = -1; | | |
| 1723 | int x; | 1743 | int x; |
| 1724 | CString linker_arg; /* collect -Wl options */ | 1744 | CString linker_arg; /* collect -Wl options */ |
| 1725 | int tool = 0, arg_start = 0, noaction = optind; | 1745 | int tool = 0, arg_start = 0, noaction = optind; |
| 1726 | char **argv = *pargv; | 1746 | char **argv = *pargv; |
| 1727 | int argc = *pargc; | 1747 | int argc = *pargc; |
| 1728 | int help = 0; /* remember if -h/--help has been seen */ | | |
| 1729 | | 1748 | |
| 1730 | cstr_new(&linker_arg); | 1749 | cstr_new(&linker_arg); |
| 1731 | | 1750 | |
| @@ -1776,13 +1795,11 @@ reparse: · 44 unmodified lines |
| 1776 | | 1795 | |
| 1777 | switch(popt->index) { | 1796 | switch(popt->index) { |
| 1778 | case TCC_OPTION_HELP: | 1797 | case TCC_OPTION_HELP: |
| 1779 | /* help is requested, postpone return to check for -v */ | 1798 | x = OPT_HELP; |
| 1780 | help = OPT_HELP; | 1799 | goto extra_action; |
| 1781 | break; | | |
| 1782 | case TCC_OPTION_HELP2: | 1800 | case TCC_OPTION_HELP2: |
| 1783 | /* help is requested, postpone return to check for -v */ | 1801 | x = OPT_HELP2; |
| 1784 | help = OPT_HELP2; | 1802 | goto extra_action; |
| 1785 | break; | | |
| 1786 | case TCC_OPTION_I: | 1803 | case TCC_OPTION_I: |
| 1787 | tcc_add_include_path(s, optarg); | 1804 | tcc_add_include_path(s, optarg); |
| 1788 | break; | 1805 | break; |
| @@ -1804,7 +1821,6 @@ reparse: · 15 unmodified lines |
| 1804 | s->nb_libraries++; | 1821 | s->nb_libraries++; |
| 1805 | break; | 1822 | break; |
| 1806 | case TCC_OPTION_pthread: | 1823 | case TCC_OPTION_pthread: |
| 1807 | parse_option_D(s, "_REENTRANT"); | | |
| 1808 | s->option_pthread = 1; | 1824 | s->option_pthread = 1; |
| 1809 | break; | 1825 | break; |
| 1810 | case TCC_OPTION_bench: | 1826 | case TCC_OPTION_bench: |
| @@ -1850,76 +1866,8 @@ reparse: · 39 unmodified lines |
| 1850 | s->static_link = 1; | 1866 | s->static_link = 1; |
| 1851 | break; | 1867 | break; |
| 1852 | case TCC_OPTION_std: | 1868 | case TCC_OPTION_std: |
| 1853 | if (*optarg == '=') { | 1869 | if (strcmp(optarg, "=c11") == 0) |
| 1854 | if (strcmp(optarg, "=c11") == 0) { | 1870 | s->cversion = 201112; |
| 1855 | tcc_undefine_symbol(s, "__STDC_VERSION__"); | | |
| 1856 | tcc_define_symbol(s, "__STDC_VERSION__", "201112L"); | | |
| 1857 | /* | | |
| 1858 | * The integer constant 1, intended to indicate | | |
| 1859 | * that the implementation does not support atomic | | |
| 1860 | * types (including the _Atomic type qualifier) and | | |
| 1861 | * the <stdatomic.h> header. | | |
| 1862 | */ | | |
| 1863 | tcc_define_symbol(s, "__STDC_NO_ATOMICS__", "1"); | | |
| 1864 | /* | | |
| 1865 | * The integer constant 1, intended to indicate | | |
| 1866 | * that the implementation does not support complex | | |
| 1867 | * types or the <complex.h> header. | | |
| 1868 | */ | | |
| 1869 | tcc_define_symbol(s, "__STDC_NO_COMPLEX__", "1"); | | |
| 1870 | /* | | |
| 1871 | * The integer constant 1, intended to indicate | | |
| 1872 | * that the implementation does not support the | | |
| 1873 | * <threads.h> header. | | |
| 1874 | */ | | |
| 1875 | tcc_define_symbol(s, "__STDC_NO_THREADS__", "1"); | | |
| 1876 | /* | | |
| 1877 | * __STDC_NO_VLA__, tcc supports VLA. | | |
| 1878 | * The integer constant 1, intended to indicate | | |
| 1879 | * that the implementation does not support | | |
| 1880 | * variable length arrays or variably modified | | |
| 1881 | * types. | | |
| 1882 | */ | | |
| 1883 | #if !defined(TCC_TARGET_PE) | | |
| 1884 | /* | | |
| 1885 | * An integer constant of the form yyyymmL (for | | |
| 1886 | * example, 199712L). If this symbol is defined, | | |
| 1887 | * then every character in the Unicode required | | |
| 1888 | * set, when stored in an object of type | | |
| 1889 | * wchar_t, has the same value as the short | | |
| 1890 | * identifier of that character. | | |
| 1891 | */ | | |
| 1892 | #if 0 | | |
| 1893 | /* on Linux, this conflicts with a define introduced by | | |
| 1894 | * /usr/include/stdc-predef.h included by glibc libs; | | |
| 1895 | * clang doesn't define it at all so it's probably not necessary | | |
| 1896 | */ | | |
| 1897 | tcc_define_symbol(s, "__STDC_ISO_10646__", "201605L"); | | |
| 1898 | #endif | | |
| 1899 | /* | | |
| 1900 | * The integer constant 1, intended to indicate | | |
| 1901 | * that values of type char16_t are UTF−16 | | |
| 1902 | * encoded. If some other encoding is used, the | | |
| 1903 | * macro shall not be defined and the actual | | |
| 1904 | * encoding used is implementation defined. | | |
| 1905 | */ | | |
| 1906 | tcc_define_symbol(s, "__STDC_UTF_16__", "1"); | | |
| 1907 | /* | | |
| 1908 | * The integer constant 1, intended to indicate | | |
| 1909 | * that values of type char32_t are UTF−32 | | |
| 1910 | * encoded. If some other encoding is used, the | | |
| 1911 | * macro shall not be defined and the actual | | |
| 1912 | * encoding used is implementationdefined. | | |
| 1913 | */ | | |
| 1914 | tcc_define_symbol(s, "__STDC_UTF_32__", "1"); | | |
| 1915 | #endif /* !TCC_TARGET_PE */ | | |
| 1916 | s->cversion = 201112; | | |
| 1917 | } | | |
| 1918 | } | | |
| 1919 | /* | | |
| 1920 | * silently ignore other values, a current purpose: | | |
| 1921 | * allow to use a tcc as a reference compiler for "make test" | | |
| 1922 | */ | | |
| 1923 | break; | 1871 | break; |
| 1924 | case TCC_OPTION_shared: | 1872 | case TCC_OPTION_shared: |
| 1925 | x = TCC_OUTPUT_DLL; | 1873 | x = TCC_OUTPUT_DLL; |
| @@ -2039,7 +1987,7 @@ reparse: · 113 unmodified lines |
| 2039 | s->filetype = x | (s->filetype & ~AFF_TYPE_MASK); | 1987 | s->filetype = x | (s->filetype & ~AFF_TYPE_MASK); |
| 2040 | break; | 1988 | break; |
| 2041 | case TCC_OPTION_O: | 1989 | case TCC_OPTION_O: |
| 2042 | last_o = atoi(optarg); | 1990 | s->optimize = atoi(optarg); |
| 2043 | break; | 1991 | break; |
| 2044 | case TCC_OPTION_print_search_dirs: | 1992 | case TCC_OPTION_print_search_dirs: |
| 2045 | x = OPT_PRINT_DIRS; | 1993 | x = OPT_PRINT_DIRS; |
| @@ -2068,16 +2016,6 @@ unsupported_option: · 22 unmodified lines |
| 2068 | break; | 2016 | break; |
| 2069 | } | 2017 | } |
| 2070 | } | 2018 | } |
| 2071 | | | |
| 2072 | if (help) { | | |
| 2073 | if (s->verbose > 0) | | |
| 2074 | return OPT_VERBOSE_HELP; | | |
| 2075 | else | | |
| 2076 | return help; | | |
| 2077 | } | | |
| 2078 | | | |
| 2079 | if (last_o > 0) | | |
| 2080 | tcc_define_symbol(s, "__OPTIMIZE__", NULL); | | |
| 2081 | if (linker_arg.size) { | 2019 | if (linker_arg.size) { |
| 2082 | r = linker_arg.data; | 2020 | r = linker_arg.data; |
| 2083 | goto arg_err; | 2021 | goto arg_err; |