| @@ -986,6 +986,27 @@ LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type) · 985 unmodified lines |
| 986 | 986 | if (s->char_is_unsigned) |
| 987 | 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 | 1010 | if (!s->nostdinc) { |
| 990 | 1011 | /* default include paths */ |
| 991 | 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 | 1740 | const TCCOption *popt; |
| 1720 | 1741 | const char *optarg, *r; |
| 1721 | 1742 | const char *run = NULL; |
| 1722 | | − int last_o = -1; |
| 1723 | 1743 | int x; |
| 1724 | 1744 | CString linker_arg; /* collect -Wl options */ |
| 1725 | 1745 | int tool = 0, arg_start = 0, noaction = optind; |
| 1726 | 1746 | char **argv = *pargv; |
| 1727 | 1747 | int argc = *pargc; |
| 1728 | | − int help = 0; /* remember if -h/--help has been seen */ |
| 1729 | 1748 | |
| 1730 | 1749 | cstr_new(&linker_arg); |
| 1731 | 1750 | |
| @@ -1776,13 +1795,11 @@ reparse: · 44 unmodified lines |
| 1776 | 1795 | |
| 1777 | 1796 | switch(popt->index) { |
| 1778 | 1797 | case TCC_OPTION_HELP: |
| 1779 | | − /* help is requested, postpone return to check for -v */ |
| 1780 | | − help = OPT_HELP; |
| 1781 | | − break; |
| 1798 | + x = OPT_HELP; |
| 1799 | + goto extra_action; |
| 1782 | 1800 | case TCC_OPTION_HELP2: |
| 1783 | | − /* help is requested, postpone return to check for -v */ |
| 1784 | | − help = OPT_HELP2; |
| 1785 | | − break; |
| 1801 | + x = OPT_HELP2; |
| 1802 | + goto extra_action; |
| 1786 | 1803 | case TCC_OPTION_I: |
| 1787 | 1804 | tcc_add_include_path(s, optarg); |
| 1788 | 1805 | break; |
| @@ -1804,7 +1821,6 @@ reparse: · 15 unmodified lines |
| 1804 | 1821 | s->nb_libraries++; |
| 1805 | 1822 | break; |
| 1806 | 1823 | case TCC_OPTION_pthread: |
| 1807 | | − parse_option_D(s, "_REENTRANT"); |
| 1808 | 1824 | s->option_pthread = 1; |
| 1809 | 1825 | break; |
| 1810 | 1826 | case TCC_OPTION_bench: |
| @@ -1850,76 +1866,8 @@ reparse: · 39 unmodified lines |
| 1850 | 1866 | s->static_link = 1; |
| 1851 | 1867 | break; |
| 1852 | 1868 | case TCC_OPTION_std: |
| 1853 | | − if (*optarg == '=') { |
| 1854 | | − if (strcmp(optarg, "=c11") == 0) { |
| 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 | | − */ |
| 1869 | + if (strcmp(optarg, "=c11") == 0) |
| 1870 | + s->cversion = 201112; |
| 1923 | 1871 | break; |
| 1924 | 1872 | case TCC_OPTION_shared: |
| 1925 | 1873 | x = TCC_OUTPUT_DLL; |
| @@ -2039,7 +1987,7 @@ reparse: · 113 unmodified lines |
| 2039 | 1987 | s->filetype = x | (s->filetype & ~AFF_TYPE_MASK); |
| 2040 | 1988 | break; |
| 2041 | 1989 | case TCC_OPTION_O: |
| 2042 | | − last_o = atoi(optarg); |
| 1990 | + s->optimize = atoi(optarg); |
| 2043 | 1991 | break; |
| 2044 | 1992 | case TCC_OPTION_print_search_dirs: |
| 2045 | 1993 | x = OPT_PRINT_DIRS; |
| @@ -2068,16 +2016,6 @@ unsupported_option: · 22 unmodified lines |
| 2068 | 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 | 2019 | if (linker_arg.size) { |
| 2082 | 2020 | r = linker_arg.data; |
| 2083 | 2021 | goto arg_err; |