├── .gitignore ├── ChangeLog ├── ChangeLog.old ├── INSTALL ├── INSTALL-jp ├── LICENSE ├── Makefile.am ├── Makefile.in ├── NEWS ├── README ├── aclocal.m4 ├── config ├── compile ├── config.guess ├── config.sub ├── cygwin_root ├── depcomp ├── install-sh ├── ltmain.sh ├── mb_big5 ├── mb_jis ├── mb_sjis ├── mingw_root └── missing ├── configure ├── configure.ac ├── cpp-test ├── LICENSE ├── test-l │ ├── cpp-test.exp │ ├── ifdef127.h │ ├── ifdef255.h │ ├── l_37_1.h │ ├── l_37_2.c │ ├── l_37_3.c │ ├── l_37_4.c │ ├── l_37_5.c │ ├── l_37_6.c │ ├── l_37_7.c │ ├── l_37_8.c │ ├── l_37_9.c │ ├── longline.t │ ├── m8191.h │ ├── nest1.h │ ├── nest10.h │ ├── nest100.h │ ├── nest101.h │ ├── nest102.h │ ├── nest103.h │ ├── nest104.h │ ├── nest105.h │ ├── nest106.h │ ├── nest107.h │ ├── nest108.h │ ├── nest109.h │ ├── nest11.h │ ├── nest110.h │ ├── nest111.h │ ├── nest112.h │ ├── nest113.h │ ├── nest114.h │ ├── nest115.h │ ├── nest116.h │ ├── nest117.h │ ├── nest118.h │ ├── nest119.h │ ├── nest12.h │ ├── nest120.h │ ├── nest121.h │ ├── nest122.h │ ├── nest123.h │ ├── nest124.h │ ├── nest125.h │ ├── nest126.h │ ├── nest127.h │ ├── nest13.h │ ├── nest14.h │ ├── nest15.h │ ├── nest16.h │ ├── nest17.h │ ├── nest18.h │ ├── nest19.h │ ├── nest2.h │ ├── nest20.h │ ├── nest21.h │ ├── nest22.h │ ├── nest23.h │ ├── nest24.h │ ├── nest25.h │ ├── nest26.h │ ├── nest27.h │ ├── nest28.h │ ├── nest29.h │ ├── nest3.h │ ├── nest30.h │ ├── nest31.h │ ├── nest32.h │ ├── nest33.h │ ├── nest34.h │ ├── nest35.h │ ├── nest36.h │ ├── nest37.h │ ├── nest38.h │ ├── nest39.h │ ├── nest4.h │ ├── nest40.h │ ├── nest41.h │ ├── nest42.h │ ├── nest43.h │ ├── nest44.h │ ├── nest45.h │ ├── nest46.h │ ├── nest47.h │ ├── nest48.h │ ├── nest49.h │ ├── nest5.h │ ├── nest50.h │ ├── nest51.h │ ├── nest52.h │ ├── nest53.h │ ├── nest54.h │ ├── nest55.h │ ├── nest56.h │ ├── nest57.h │ ├── nest58.h │ ├── nest59.h │ ├── nest6.h │ ├── nest60.h │ ├── nest61.h │ ├── nest62.h │ ├── nest63.h │ ├── nest64.h │ ├── nest65.h │ ├── nest66.h │ ├── nest67.h │ ├── nest68.h │ ├── nest69.h │ ├── nest7.h │ ├── nest70.h │ ├── nest71.h │ ├── nest72.h │ ├── nest73.h │ ├── nest74.h │ ├── nest75.h │ ├── nest76.h │ ├── nest77.h │ ├── nest78.h │ ├── nest79.h │ ├── nest8.h │ ├── nest80.h │ ├── nest81.h │ ├── nest82.h │ ├── nest83.h │ ├── nest84.h │ ├── nest85.h │ ├── nest86.h │ ├── nest87.h │ ├── nest88.h │ ├── nest89.h │ ├── nest9.h │ ├── nest90.h │ ├── nest91.h │ ├── nest92.h │ ├── nest93.h │ ├── nest94.h │ ├── nest95.h │ ├── nest96.h │ ├── nest97.h │ ├── nest98.h │ └── nest99.h └── test-t │ ├── cpp-test.exp │ ├── e_12_8.c │ ├── e_14.c │ ├── e_14_10.c │ ├── e_14_2.c │ ├── e_14_3.c │ ├── e_14_7.c │ ├── e_14_9.c │ ├── e_15_3.c │ ├── e_16.c │ ├── e_17.c │ ├── e_17_5.c │ ├── e_18_4.c │ ├── e_19_3.c │ ├── e_23_3.c │ ├── e_24_6.c │ ├── e_25_6.c │ ├── e_27_7.c │ ├── e_29_3.c │ ├── e_31.c │ ├── e_31_3.c │ ├── e_32_5.c │ ├── e_33_2.c │ ├── e_35_2.c │ ├── e_4_3.c │ ├── e_7_4.c │ ├── e_intmax.c │ ├── e_operat.C │ ├── e_pragma.c │ ├── e_ucn.c │ ├── e_vargs.c │ ├── header.h │ ├── i_32_3.c │ ├── i_35.c │ ├── ifdef15.h │ ├── ifdef31.h │ ├── ifdef63.h │ ├── line.h │ ├── long4095.h │ ├── m4095.h │ ├── n_1.c │ ├── n_10.c │ ├── n_11.c │ ├── n_12.c │ ├── n_13.c │ ├── n_13_13.c │ ├── n_13_5.c │ ├── n_13_7.c │ ├── n_13_8.c │ ├── n_15.c │ ├── n_18.c │ ├── n_19.c │ ├── n_1_3_run.c │ ├── n_1_3_run.c.gcc2 │ ├── n_1_3_run.c.gcc3 │ ├── n_2.c │ ├── n_20.c │ ├── n_21.c │ ├── n_22.c │ ├── n_23.c │ ├── n_24.c │ ├── n_24_3_run.c │ ├── n_24_3_run.c.gcc2 │ ├── n_24_3_run.c.gcc3 │ ├── n_25.c │ ├── n_26.c │ ├── n_27.c │ ├── n_28.c │ ├── n_29.c │ ├── n_3.c │ ├── n_30.c │ ├── n_32.c │ ├── n_37.c │ ├── n_3_4.c │ ├── n_4.c │ ├── n_5.c │ ├── n_6.c │ ├── n_7.c │ ├── n_8.c │ ├── n_8_2.c │ ├── n_9.c │ ├── n_bool.C │ ├── n_cnvucn.C │ ├── n_cplus.C │ ├── n_dslcom.c │ ├── n_dslcom_cplus.C │ ├── n_line.c │ ├── n_llong.c │ ├── n_nularg.c │ ├── n_ppnum.c │ ├── n_pragma.c │ ├── n_stdmac.c │ ├── n_tlimit.c │ ├── n_token.C │ ├── n_ucn1.c │ ├── n_ucn1_cplus.C │ ├── n_ucn2.c │ ├── n_vargs.c │ ├── nest1.h │ ├── nest10.h │ ├── nest11.h │ ├── nest12.h │ ├── nest13.h │ ├── nest14.h │ ├── nest15.h │ ├── nest2.h │ ├── nest3.h │ ├── nest4.h │ ├── nest5.h │ ├── nest6.h │ ├── nest7.h │ ├── nest8.h │ ├── nest9.h │ ├── pragmas.h │ ├── u_1_1.c │ ├── u_1_11.c │ ├── u_1_12.c │ ├── u_1_13.c │ ├── u_1_14.c │ ├── u_1_17.c │ ├── u_1_17s.c │ ├── u_1_19.c │ ├── u_1_22.c │ ├── u_1_24.c │ ├── u_1_25.c │ ├── u_1_27.c │ ├── u_1_28.c │ ├── u_1_5.c │ ├── u_1_8.c │ ├── u_2.c │ ├── u_concat.c │ ├── u_cplus.C │ ├── u_line.c │ ├── u_line_s.c │ ├── unbal1.h │ ├── unbal2.h │ ├── unbal3.h │ ├── unbal4.h │ ├── unbal5.h │ ├── unbal6.h │ ├── unspcs.c │ ├── vers2.h │ ├── warn_1_1.c │ ├── warn_1_2.c │ ├── warn_2.c │ └── warn_3.c ├── doc-jp ├── LICENSE ├── cpp-test.html ├── mcpp-manual.html ├── mcpp-porting.html └── mcpp-summary.pdf ├── doc ├── LICENSE ├── cpp-test.html ├── cpp_test.sum ├── mcpp-manual.html ├── mcpp-porting.html └── mcpp-summary.pdf ├── mcpp-gcc.1 ├── mcpp.1 ├── noconfig ├── bc55.dif ├── bc59.dif ├── borlandc.mak ├── cyg1310.dif ├── cyg1518.dif ├── cygwin.mak ├── freebsd.mak ├── lcc0308.dif ├── lcc0603.dif ├── lcc_w32.mak ├── linux.mak ├── linux_gcc2953.dif ├── linux_gcc32.dif ├── linux_gcc336.dif ├── linux_gcc343.dif ├── linux_gcc412.dif ├── mac_gcc401_i686.dif ├── mac_gcc401_powerpc.dif ├── mac_osx.mak ├── mingw.mak ├── mingw345.dif ├── vc2002.dif ├── vc2003.dif ├── vc2005.dif ├── vc2008.dif ├── vc6.dif └── visualc.mak ├── src ├── Makefile.am ├── Makefile.in ├── cc1.c ├── config.h.in ├── configed.H ├── directive.c ├── eval.c ├── expand.c ├── internal.H ├── main.c ├── main_libmcpp.c ├── mbchar.c ├── mcpp_lib.def ├── mcpp_lib.h ├── mcpp_out.h ├── noconfig.H ├── preproc.c ├── set_mcpp.sh ├── support.c ├── system.H ├── system.c ├── testmain.c └── unset_mcpp.sh ├── test-c ├── LICENSE ├── defs.h ├── e_12_8.c ├── e_14.c ├── e_14_10.c ├── e_14_7.c ├── e_14_9.c ├── e_15_3.c ├── e_16.c ├── e_17.c ├── e_18_4.c ├── e_19_3.c ├── e_23_3.c ├── e_24_6.c ├── e_25_6.c ├── e_27_7.c ├── e_29_3.c ├── e_31.c ├── e_31_3.c ├── e_32_5.c ├── e_33_2.c ├── e_35_2.c ├── e_4_3.c ├── e_7_4.c ├── e_std.c ├── header.h ├── i_32_3.c ├── i_35.c ├── i_35_3.c ├── ifdef15.h ├── line.h ├── m1024.h ├── m_33_big5.c ├── m_33_eucjp.c ├── m_33_gb.c ├── m_33_jis.c ├── m_33_ksc.c ├── m_33_sjis.c ├── m_33_utf8.c ├── m_34_big5.c ├── m_34_eucjp.c ├── m_34_gb.c ├── m_34_jis.c ├── m_34_ksc.c ├── m_34_sjis.c ├── m_34_utf8.c ├── m_36_big5.c ├── m_36_jis.c ├── m_36_sjis.c ├── n_1.c ├── n_10.c ├── n_11.c ├── n_12.c ├── n_13.c ├── n_13_13.c ├── n_13_5.c ├── n_13_7.c ├── n_13_8.c ├── n_15.c ├── n_18.c ├── n_19.c ├── n_2.c ├── n_20.c ├── n_21.c ├── n_22.c ├── n_23.c ├── n_24.c ├── n_25.c ├── n_26.c ├── n_27.c ├── n_28.c ├── n_29.c ├── n_3.c ├── n_30.c ├── n_32.c ├── n_37.c ├── n_3_4.c ├── n_4.c ├── n_5.c ├── n_6.c ├── n_7.c ├── n_8.c ├── n_8_2.c ├── n_9.c ├── n_i_.lst ├── n_std.c ├── nest1.h ├── nest10.h ├── nest11.h ├── nest12.h ├── nest13.h ├── nest14.h ├── nest15.h ├── nest2.h ├── nest3.h ├── nest4.h ├── nest5.h ├── nest6.h ├── nest7.h ├── nest8.h ├── nest9.h ├── side_cpp ├── u_1_1.c ├── u_1_11.c ├── u_1_12.c ├── u_1_13.c ├── u_1_14.c ├── u_1_17.c ├── u_1_19.c ├── u_1_22.c ├── u_1_23.c ├── u_1_24.c ├── u_1_25.c ├── u_1_27.c ├── u_1_28.c ├── u_1_5.c ├── u_1_7_big5.c ├── u_1_7_eucjp.c ├── u_1_7_gb.c ├── u_1_7_jis.c ├── u_1_7_ksc.c ├── u_1_7_sjis.c ├── u_1_7_utf8.c ├── u_1_8.c ├── u_2.c ├── unbal1.h ├── unbal2.h ├── unbal3.h ├── unbal4.h ├── unbal5.h ├── unbal6.h ├── undefs.c ├── unspcs.c └── warns.c ├── test-l ├── LICENSE ├── defs.h ├── ifdef127.h ├── ifdef255.h ├── l_37_1.t ├── l_37_2.t ├── l_37_3.c ├── l_37_3.t ├── l_37_4.t ├── l_37_5.t ├── l_37_6.c ├── l_37_6.t ├── l_37_7.c ├── l_37_7.t ├── l_37_8.c ├── l_37_9.t ├── longline.c ├── m8191.h ├── nest1.h ├── nest10.h ├── nest100.h ├── nest101.h ├── nest102.h ├── nest103.h ├── nest104.h ├── nest105.h ├── nest106.h ├── nest107.h ├── nest108.h ├── nest109.h ├── nest11.h ├── nest110.h ├── nest111.h ├── nest112.h ├── nest113.h ├── nest114.h ├── nest115.h ├── nest116.h ├── nest117.h ├── nest118.h ├── nest119.h ├── nest12.h ├── nest120.h ├── nest121.h ├── nest122.h ├── nest123.h ├── nest124.h ├── nest125.h ├── nest126.h ├── nest127.h ├── nest13.h ├── nest14.h ├── nest15.h ├── nest16.h ├── nest17.h ├── nest18.h ├── nest19.h ├── nest2.h ├── nest20.h ├── nest21.h ├── nest22.h ├── nest23.h ├── nest24.h ├── nest25.h ├── nest26.h ├── nest27.h ├── nest28.h ├── nest29.h ├── nest3.h ├── nest30.h ├── nest31.h ├── nest32.h ├── nest33.h ├── nest34.h ├── nest35.h ├── nest36.h ├── nest37.h ├── nest38.h ├── nest39.h ├── nest4.h ├── nest40.h ├── nest41.h ├── nest42.h ├── nest43.h ├── nest44.h ├── nest45.h ├── nest46.h ├── nest47.h ├── nest48.h ├── nest49.h ├── nest5.h ├── nest50.h ├── nest51.h ├── nest52.h ├── nest53.h ├── nest54.h ├── nest55.h ├── nest56.h ├── nest57.h ├── nest58.h ├── nest59.h ├── nest6.h ├── nest60.h ├── nest61.h ├── nest62.h ├── nest63.h ├── nest64.h ├── nest65.h ├── nest66.h ├── nest67.h ├── nest68.h ├── nest69.h ├── nest7.h ├── nest70.h ├── nest71.h ├── nest72.h ├── nest73.h ├── nest74.h ├── nest75.h ├── nest76.h ├── nest77.h ├── nest78.h ├── nest79.h ├── nest8.h ├── nest80.h ├── nest81.h ├── nest82.h ├── nest83.h ├── nest84.h ├── nest85.h ├── nest86.h ├── nest87.h ├── nest88.h ├── nest89.h ├── nest9.h ├── nest90.h ├── nest91.h ├── nest92.h ├── nest93.h ├── nest94.h ├── nest95.h ├── nest96.h ├── nest97.h ├── nest98.h └── nest99.h ├── test-t ├── LICENSE ├── e_12_8.t ├── e_14.t ├── e_14_10.t ├── e_14_7.t ├── e_14_9.t ├── e_15_3.t ├── e_16.t ├── e_17.t ├── e_18_4.t ├── e_19_3.t ├── e_23_3.t ├── e_24_6.t ├── e_25_6.t ├── e_27_7.t ├── e_29_3.t ├── e_31.t ├── e_31_3.t ├── e_32_5.t ├── e_33_2.t ├── e_35_2.t ├── e_4_3.t ├── e_7_4.t ├── e_intmax.t ├── e_operat.cc ├── e_operat.t ├── e_post.t ├── e_pragma.t ├── e_std.t ├── e_std99.t ├── e_ucn.t ├── e_vargs.t ├── header.h ├── i_32_3.t ├── i_35.t ├── i_35_3.t ├── i_mbident.t ├── ifdef15.h ├── ifdef31.h ├── ifdef63.h ├── line.h ├── long4095.h ├── m4095.h ├── m_33_big5.t ├── m_33_eucjp.t ├── m_33_gb.t ├── m_33_jis.t ├── m_33_ksc.t ├── m_33_sjis.t ├── m_33_utf8.t ├── m_34_big5.t ├── m_34_eucjp.t ├── m_34_gb.t ├── m_34_jis.t ├── m_34_ksc.t ├── m_34_sjis.t ├── m_34_utf8.t ├── m_36_big5.t ├── m_36_jis.t ├── m_36_sjis.t ├── misc.t ├── n_1.t ├── n_10.t ├── n_11.t ├── n_12.t ├── n_13.t ├── n_13_13.t ├── n_13_5.t ├── n_13_7.t ├── n_13_8.t ├── n_15.t ├── n_18.t ├── n_19.t ├── n_2.t ├── n_20.t ├── n_21.t ├── n_22.t ├── n_23.t ├── n_24.t ├── n_25.t ├── n_26.t ├── n_27.t ├── n_28.t ├── n_29.t ├── n_3.t ├── n_30.t ├── n_32.t ├── n_37.t ├── n_3_4.t ├── n_4.t ├── n_5.t ├── n_6.t ├── n_7.t ├── n_8.t ├── n_8_2.t ├── n_9.t ├── n_bool.cc ├── n_bool.t ├── n_cnvucn.cc ├── n_cnvucn.t ├── n_cplus.cc ├── n_cplus.t ├── n_dslcom.cc ├── n_dslcom.t ├── n_line.t ├── n_llong.t ├── n_nularg.t ├── n_post.t ├── n_post99.t ├── n_ppnum.t ├── n_pragma.t ├── n_std.t ├── n_std99.t ├── n_stdmac.t ├── n_tlim_2.t ├── n_tlim_3.t ├── n_tlim_4.t ├── n_tlim_5.t ├── n_tlim_6.t ├── n_tlim_7.t ├── n_tlim_8.t ├── n_tlim_9.t ├── n_tlimit.t ├── n_token.cc ├── n_token.t ├── n_ucn1.cc ├── n_ucn1.t ├── n_ucn2.t ├── n_vargs.t ├── nest1.h ├── nest10.h ├── nest11.h ├── nest12.h ├── nest13.h ├── nest14.h ├── nest15.h ├── nest2.h ├── nest3.h ├── nest4.h ├── nest5.h ├── nest6.h ├── nest7.h ├── nest8.h ├── nest9.h ├── pragmas.h ├── recurs.t ├── trad.t ├── u_1_1.t ├── u_1_11.t ├── u_1_12.t ├── u_1_13.t ├── u_1_14.t ├── u_1_17.t ├── u_1_19.t ├── u_1_22.t ├── u_1_24.t ├── u_1_25.t ├── u_1_27.t ├── u_1_28.t ├── u_1_5.t ├── u_1_7_big5.t ├── u_1_7_eucjp.t ├── u_1_7_gb.t ├── u_1_7_jis.t ├── u_1_7_ksc.t ├── u_1_7_sjis.t ├── u_1_7_utf8.t ├── u_1_8.t ├── u_1_9.t ├── u_2.t ├── u_concat.t ├── u_cplus.cc ├── u_cplus.t ├── u_line.t ├── unbal1.h ├── unbal2.h ├── unbal3.h ├── unbal4.h ├── unbal5.h ├── unbal6.h ├── undefs.t ├── unspcs.t ├── vers2.h └── warns.t ├── tests ├── Makefile.am ├── Makefile.in ├── after_test.sh └── set_test.sh └── tool ├── LICENSE ├── app_once.bat ├── clock_of.c ├── cpp_test.c ├── ins_once.c ├── once.txt ├── rm_once.c └── total.c /.gitignore: -------------------------------------------------------------------------------- 1 | /Makefile 2 | /config.log 3 | /config.status 4 | /libtool 5 | /src/Makefile 6 | /src/config.h 7 | /src/stamp-h1 8 | tests/Makefile 9 | /src/*.o 10 | /src/mcpp 11 | /autom4te.cache 12 | -------------------------------------------------------------------------------- /INSTALL-jp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/INSTALL-jp -------------------------------------------------------------------------------- /config/cygwin_root: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # split from configure.ac to work around a problem of backslash handling 3 | mount | grep ' on / ' | sed 's, on / .*,,' | tr '\\' '/' 4 | -------------------------------------------------------------------------------- /config/mb_big5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/config/mb_big5 -------------------------------------------------------------------------------- /config/mb_jis: -------------------------------------------------------------------------------- 1 | AC_CHECK_MBCHAR_IS_ESCAPE_FREE( [ISO2022_JP], [iso2022_jp], [$B0\F0(B]) 2 | 3 | -------------------------------------------------------------------------------- /config/mb_sjis: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/config/mb_sjis -------------------------------------------------------------------------------- /config/mingw_root: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # split from configure.ac to work around a problem of backslash handling 3 | /tmp/a.exe | tr '\\' '/' 4 | -------------------------------------------------------------------------------- /cpp-test/test-l/cpp-test.exp: -------------------------------------------------------------------------------- 1 | # cpp-test.exp 2002/12 2 | # to test cpp-test 3 | # imported from dg.exp of GNU C 4 | 5 | # Load support procs. 6 | load_lib gcc-dg.exp 7 | 8 | # If a testcase doesn't have special options, use these. 9 | global DEFAULT_CFLAGS 10 | if ![info exists DEFAULT_CFLAGS] then { 11 | set DEFAULT_CFLAGS " -ansi -pedantic-errors" 12 | } 13 | 14 | # Initialize `dg'. 15 | dg-init 16 | 17 | # Main loop. 18 | dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] \ 19 | "" $DEFAULT_CFLAGS 20 | 21 | # All done. 22 | dg-finish 23 | -------------------------------------------------------------------------------- /cpp-test/test-l/l_37_4.c: -------------------------------------------------------------------------------- 1 | /* l_37_4.c: Translation limits larger than C99 / 4. */ 2 | 3 | /* 37.4L: Nested conditional inclusion. */ 4 | /* 5 | * Define one of the macros X7F or XFF, or 255 nesting of #ifdef will be 6 | * tested. 7 | */ 8 | #include "ifdef127.h" 9 | 10 | /* { dg-do preprocess } 11 | { dg-options "-std=c99 -pedantic" } 12 | { dg-warning "| More than 63 nesting of #if" "translation limit" { target *-*-* } 0 } 13 | { dg-final { if ![file exist l_37_4_.i] { return } } } 14 | { dg-final { if \{ [grep l_37_4_.i "ifdef_nest = 0xff"] != "" \} \{ } } 15 | { dg-final { return \} } } 16 | { dg-final { fail "l_37_4_.c: more than 63 nesting of #if" } } 17 | */ 18 | 19 | -------------------------------------------------------------------------------- /cpp-test/test-l/l_37_5.c: -------------------------------------------------------------------------------- 1 | /* l_37_5.c: Translation limits larger than C99 / 5. */ 2 | 3 | /* 37.5L: Nested source file inclusion. */ 4 | /* Define one of the macros X1F, X3F or it will test 127 levels of 5 | #include */ 6 | #include "nest1.h" 7 | 8 | /* { dg-do preprocess } 9 | { dg-options "-std=c99 -pedantic" } 10 | { dg-warning "| More than 15 nesting of #include" "translation limit" { target *-*-* } 0 } 11 | { dg-final { if ![file exist l_37_5_.i] { return } } } 12 | { dg-final { if \{ [grep l_37_5_.i "nest = 0x7f"] != "" \} \{ } } 13 | { dg-final { return \} } } 14 | { dg-final { fail "l_37_5_.c: more than 15 nesting of #include" } } 15 | */ 16 | 17 | -------------------------------------------------------------------------------- /cpp-test/test-l/l_37_9.c: -------------------------------------------------------------------------------- 1 | /* l_37_9.c: Translation limits larger than C99 / 9. */ 2 | 3 | /* 37.9L: Number of macro definitions. */ 4 | 5 | #include "m8191.h" 6 | 7 | #ifdef X0FFF 8 | /* 0x0fff; */ 9 | GBM; 10 | #else 11 | /* 0x1fff; */ 12 | MDA; 13 | #endif 14 | 15 | /* { dg-do preprocess } 16 | { dg-options "-std=c99 -pedantic" } 17 | { dg-warning "| More than 4095 macros defined" "translation limit" { target *-*-* } 0 } 18 | { dg-final { if ![file exist l_37_9_.i] { return } } } 19 | { dg-final { if \{ [grep l_37_9_.i "0x1fff"] != "" \} \{ } } 20 | { dg-final { return \} } } 21 | { dg-final { fail "l_37_9_.c: defining more than 4095 macros" } } 22 | */ 23 | 24 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest1.h: -------------------------------------------------------------------------------- 1 | /* nest1.h */ 2 | #include "nest2.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest10.h: -------------------------------------------------------------------------------- 1 | /* nest10.h */ 2 | #include "nest11.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest100.h: -------------------------------------------------------------------------------- 1 | /* nest100.h */ 2 | #include "nest101.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest101.h: -------------------------------------------------------------------------------- 1 | /* nest101.h */ 2 | #include "nest102.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest102.h: -------------------------------------------------------------------------------- 1 | /* nest102.h */ 2 | #include "nest103.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest103.h: -------------------------------------------------------------------------------- 1 | /* nest103.h */ 2 | #include "nest104.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest104.h: -------------------------------------------------------------------------------- 1 | /* nest104.h */ 2 | #include "nest105.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest105.h: -------------------------------------------------------------------------------- 1 | /* nest105.h */ 2 | #include "nest106.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest106.h: -------------------------------------------------------------------------------- 1 | /* nest106.h */ 2 | #include "nest107.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest107.h: -------------------------------------------------------------------------------- 1 | /* nest107.h */ 2 | #include "nest108.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest108.h: -------------------------------------------------------------------------------- 1 | /* nest108.h */ 2 | #include "nest109.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest109.h: -------------------------------------------------------------------------------- 1 | /* nest109.h */ 2 | #include "nest110.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest11.h: -------------------------------------------------------------------------------- 1 | /* nest11.h */ 2 | #include "nest12.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest110.h: -------------------------------------------------------------------------------- 1 | /* nest110.h */ 2 | #include "nest111.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest111.h: -------------------------------------------------------------------------------- 1 | /* nest111.h */ 2 | #include "nest112.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest112.h: -------------------------------------------------------------------------------- 1 | /* nest112.h */ 2 | #include "nest113.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest113.h: -------------------------------------------------------------------------------- 1 | /* nest113.h */ 2 | #include "nest114.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest114.h: -------------------------------------------------------------------------------- 1 | /* nest114.h */ 2 | #include "nest115.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest115.h: -------------------------------------------------------------------------------- 1 | /* nest115.h */ 2 | #include "nest116.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest116.h: -------------------------------------------------------------------------------- 1 | /* nest116.h */ 2 | #include "nest117.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest117.h: -------------------------------------------------------------------------------- 1 | /* nest117.h */ 2 | #include "nest118.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest118.h: -------------------------------------------------------------------------------- 1 | /* nest118.h */ 2 | #include "nest119.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest119.h: -------------------------------------------------------------------------------- 1 | /* nest119.h */ 2 | #include "nest120.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest12.h: -------------------------------------------------------------------------------- 1 | /* nest12.h */ 2 | #include "nest13.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest120.h: -------------------------------------------------------------------------------- 1 | /* nest120.h */ 2 | #include "nest121.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest121.h: -------------------------------------------------------------------------------- 1 | /* nest121.h */ 2 | #include "nest122.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest122.h: -------------------------------------------------------------------------------- 1 | /* nest122.h */ 2 | #include "nest123.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest123.h: -------------------------------------------------------------------------------- 1 | /* nest123.h */ 2 | #include "nest124.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest124.h: -------------------------------------------------------------------------------- 1 | /* nest124.h */ 2 | #include "nest125.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest125.h: -------------------------------------------------------------------------------- 1 | /* nest125.h */ 2 | #include "nest126.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest126.h: -------------------------------------------------------------------------------- 1 | /* nest126.h */ 2 | #include "nest127.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest127.h: -------------------------------------------------------------------------------- 1 | /* nest127.h */ 2 | nest = 0x7f; 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest13.h: -------------------------------------------------------------------------------- 1 | /* nest13.h */ 2 | #include "nest14.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest14.h: -------------------------------------------------------------------------------- 1 | /* nest14.h */ 2 | #include "nest15.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest15.h: -------------------------------------------------------------------------------- 1 | /* nest15.h */ 2 | #ifdef X0F 3 | nest = 0x0f; 4 | #else 5 | #include "nest16.h" 6 | #endif 7 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest16.h: -------------------------------------------------------------------------------- 1 | /* nest16.h */ 2 | #include "nest17.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest17.h: -------------------------------------------------------------------------------- 1 | /* nest17.h */ 2 | #include "nest18.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest18.h: -------------------------------------------------------------------------------- 1 | /* nest18.h */ 2 | #include "nest19.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest19.h: -------------------------------------------------------------------------------- 1 | /* nest19.h */ 2 | #include "nest20.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest2.h: -------------------------------------------------------------------------------- 1 | /* nest2.h */ 2 | #include "nest3.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest20.h: -------------------------------------------------------------------------------- 1 | /* nest20.h */ 2 | #include "nest21.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest21.h: -------------------------------------------------------------------------------- 1 | /* nest21.h */ 2 | #include "nest22.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest22.h: -------------------------------------------------------------------------------- 1 | /* nest22.h */ 2 | #include "nest23.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest23.h: -------------------------------------------------------------------------------- 1 | /* nest23.h */ 2 | #include "nest24.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest24.h: -------------------------------------------------------------------------------- 1 | /* nest24.h */ 2 | #include "nest25.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest25.h: -------------------------------------------------------------------------------- 1 | /* nest25.h */ 2 | #include "nest26.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest26.h: -------------------------------------------------------------------------------- 1 | /* nest26.h */ 2 | #include "nest27.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest27.h: -------------------------------------------------------------------------------- 1 | /* nest27.h */ 2 | #include "nest28.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest28.h: -------------------------------------------------------------------------------- 1 | /* nest28.h */ 2 | #include "nest29.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest29.h: -------------------------------------------------------------------------------- 1 | /* nest29.h */ 2 | #include "nest30.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest3.h: -------------------------------------------------------------------------------- 1 | /* nest3.h */ 2 | #include "nest4.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest30.h: -------------------------------------------------------------------------------- 1 | /* nest30.h */ 2 | #include "nest31.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest31.h: -------------------------------------------------------------------------------- 1 | /* nest31.h */ 2 | #ifdef X1F 3 | nest = 0x1f; 4 | #else 5 | #include "nest32.h" 6 | #endif 7 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest32.h: -------------------------------------------------------------------------------- 1 | /* nest32.h */ 2 | #include "nest33.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest33.h: -------------------------------------------------------------------------------- 1 | /* nest33.h */ 2 | #include "nest34.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest34.h: -------------------------------------------------------------------------------- 1 | /* nest34.h */ 2 | #include "nest35.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest35.h: -------------------------------------------------------------------------------- 1 | /* nest35.h */ 2 | #include "nest36.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest36.h: -------------------------------------------------------------------------------- 1 | /* nest36.h */ 2 | #include "nest37.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest37.h: -------------------------------------------------------------------------------- 1 | /* nest37.h */ 2 | #include "nest38.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest38.h: -------------------------------------------------------------------------------- 1 | /* nest38.h */ 2 | #include "nest39.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest39.h: -------------------------------------------------------------------------------- 1 | /* nest39.h */ 2 | #include "nest40.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest4.h: -------------------------------------------------------------------------------- 1 | /* nest4.h */ 2 | #include "nest5.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest40.h: -------------------------------------------------------------------------------- 1 | /* nest40.h */ 2 | #include "nest41.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest41.h: -------------------------------------------------------------------------------- 1 | /* nest41.h */ 2 | #include "nest42.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest42.h: -------------------------------------------------------------------------------- 1 | /* nest42.h */ 2 | #include "nest43.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest43.h: -------------------------------------------------------------------------------- 1 | /* nest43.h */ 2 | #include "nest44.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest44.h: -------------------------------------------------------------------------------- 1 | /* nest44.h */ 2 | #include "nest45.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest45.h: -------------------------------------------------------------------------------- 1 | /* nest45.h */ 2 | #include "nest46.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest46.h: -------------------------------------------------------------------------------- 1 | /* nest46.h */ 2 | #include "nest47.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest47.h: -------------------------------------------------------------------------------- 1 | /* nest47.h */ 2 | #include "nest48.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest48.h: -------------------------------------------------------------------------------- 1 | /* nest48.h */ 2 | #include "nest49.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest49.h: -------------------------------------------------------------------------------- 1 | /* nest49.h */ 2 | #include "nest50.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest5.h: -------------------------------------------------------------------------------- 1 | /* nest5.h */ 2 | #include "nest6.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest50.h: -------------------------------------------------------------------------------- 1 | /* nest50.h */ 2 | #include "nest51.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest51.h: -------------------------------------------------------------------------------- 1 | /* nest51.h */ 2 | #include "nest52.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest52.h: -------------------------------------------------------------------------------- 1 | /* nest52.h */ 2 | #include "nest53.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest53.h: -------------------------------------------------------------------------------- 1 | /* nest53.h */ 2 | #include "nest54.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest54.h: -------------------------------------------------------------------------------- 1 | /* nest54.h */ 2 | #include "nest55.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest55.h: -------------------------------------------------------------------------------- 1 | /* nest55.h */ 2 | #include "nest56.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest56.h: -------------------------------------------------------------------------------- 1 | /* nest56.h */ 2 | #include "nest57.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest57.h: -------------------------------------------------------------------------------- 1 | /* nest57.h */ 2 | #include "nest58.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest58.h: -------------------------------------------------------------------------------- 1 | /* nest58.h */ 2 | #include "nest59.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest59.h: -------------------------------------------------------------------------------- 1 | /* nest59.h */ 2 | #include "nest60.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest6.h: -------------------------------------------------------------------------------- 1 | /* nest6.h */ 2 | #include "nest7.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest60.h: -------------------------------------------------------------------------------- 1 | /* nest60.h */ 2 | #include "nest61.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest61.h: -------------------------------------------------------------------------------- 1 | /* nest61.h */ 2 | #include "nest62.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest62.h: -------------------------------------------------------------------------------- 1 | /* nest62.h */ 2 | #include "nest63.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest63.h: -------------------------------------------------------------------------------- 1 | /* nest63.h */ 2 | #ifdef X3F 3 | nest = 0x3f; 4 | #else 5 | #include "nest64.h" 6 | #endif 7 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest64.h: -------------------------------------------------------------------------------- 1 | /* nest64.h */ 2 | #include "nest65.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest65.h: -------------------------------------------------------------------------------- 1 | /* nest65.h */ 2 | #include "nest66.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest66.h: -------------------------------------------------------------------------------- 1 | /* nest66.h */ 2 | #include "nest67.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest67.h: -------------------------------------------------------------------------------- 1 | /* nest67.h */ 2 | #include "nest68.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest68.h: -------------------------------------------------------------------------------- 1 | /* nest68.h */ 2 | #include "nest69.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest69.h: -------------------------------------------------------------------------------- 1 | /* nest69.h */ 2 | #include "nest70.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest7.h: -------------------------------------------------------------------------------- 1 | /* nest7.h */ 2 | #include "nest8.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest70.h: -------------------------------------------------------------------------------- 1 | /* nest70.h */ 2 | #include "nest71.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest71.h: -------------------------------------------------------------------------------- 1 | /* nest71.h */ 2 | #include "nest72.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest72.h: -------------------------------------------------------------------------------- 1 | /* nest72.h */ 2 | #include "nest73.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest73.h: -------------------------------------------------------------------------------- 1 | /* nest73.h */ 2 | #include "nest74.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest74.h: -------------------------------------------------------------------------------- 1 | /* nest74.h */ 2 | #include "nest75.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest75.h: -------------------------------------------------------------------------------- 1 | /* nest75.h */ 2 | #include "nest76.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest76.h: -------------------------------------------------------------------------------- 1 | /* nest76.h */ 2 | #include "nest77.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest77.h: -------------------------------------------------------------------------------- 1 | /* nest77.h */ 2 | #include "nest78.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest78.h: -------------------------------------------------------------------------------- 1 | /* nest78.h */ 2 | #include "nest79.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest79.h: -------------------------------------------------------------------------------- 1 | /* nest79.h */ 2 | #include "nest80.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest8.h: -------------------------------------------------------------------------------- 1 | /* nest8.h */ 2 | #include "nest9.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest80.h: -------------------------------------------------------------------------------- 1 | /* nest80.h */ 2 | #include "nest81.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest81.h: -------------------------------------------------------------------------------- 1 | /* nest81.h */ 2 | #include "nest82.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest82.h: -------------------------------------------------------------------------------- 1 | /* nest82.h */ 2 | #include "nest83.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest83.h: -------------------------------------------------------------------------------- 1 | /* nest83.h */ 2 | #include "nest84.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest84.h: -------------------------------------------------------------------------------- 1 | /* nest84.h */ 2 | #include "nest85.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest85.h: -------------------------------------------------------------------------------- 1 | /* nest85.h */ 2 | #include "nest86.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest86.h: -------------------------------------------------------------------------------- 1 | /* nest86.h */ 2 | #include "nest87.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest87.h: -------------------------------------------------------------------------------- 1 | /* nest87.h */ 2 | #include "nest88.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest88.h: -------------------------------------------------------------------------------- 1 | /* nest88.h */ 2 | #include "nest89.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest89.h: -------------------------------------------------------------------------------- 1 | /* nest89.h */ 2 | #include "nest90.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest9.h: -------------------------------------------------------------------------------- 1 | /* nest9.h */ 2 | #include "nest10.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest90.h: -------------------------------------------------------------------------------- 1 | /* nest90.h */ 2 | #include "nest91.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest91.h: -------------------------------------------------------------------------------- 1 | /* nest91.h */ 2 | #include "nest92.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest92.h: -------------------------------------------------------------------------------- 1 | /* nest92.h */ 2 | #include "nest93.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest93.h: -------------------------------------------------------------------------------- 1 | /* nest93.h */ 2 | #include "nest94.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest94.h: -------------------------------------------------------------------------------- 1 | /* nest94.h */ 2 | #include "nest95.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest95.h: -------------------------------------------------------------------------------- 1 | /* nest95.h */ 2 | #include "nest96.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest96.h: -------------------------------------------------------------------------------- 1 | /* nest96.h */ 2 | #include "nest97.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest97.h: -------------------------------------------------------------------------------- 1 | /* nest97.h */ 2 | #include "nest98.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest98.h: -------------------------------------------------------------------------------- 1 | /* nest98.h */ 2 | #include "nest99.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-l/nest99.h: -------------------------------------------------------------------------------- 1 | /* nest99.h */ 2 | #include "nest100.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-t/cpp-test.exp: -------------------------------------------------------------------------------- 1 | # cpp-test.exp 2002/12 2 | # to test cpp-test 3 | # imported and modified from dg.exp of GNU C 4 | 5 | # Load support procs. 6 | load_lib gcc-dg.exp 7 | 8 | # If a testcase doesn't have special options, use these. 9 | global DEFAULT_CFLAGS 10 | if ![info exists DEFAULT_CFLAGS] then { 11 | set DEFAULT_CFLAGS " -ansi -pedantic-errors" 12 | } 13 | 14 | # Initialize `dg'. 15 | dg-init 16 | 17 | # Main loop. 18 | dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cSC\]]] \ 19 | "" $DEFAULT_CFLAGS 20 | 21 | # All done. 22 | dg-finish 23 | -------------------------------------------------------------------------------- /cpp-test/test-t/e_12_8.c: -------------------------------------------------------------------------------- 1 | /* e_12_8.c: Out of range of integer pp-token in #if expression. */ 2 | 3 | /* { dg-do preprocess } */ 4 | 5 | /* 12.8: Preprocessing number perhaps out of range of unsigned long. */ 6 | #if 123456789012345678901 /* { dg-error "(C|c)onstant (\"\[0-9\]*\" is |)(out of range|is too large for its type)" } */ 7 | #endif 8 | 9 | -------------------------------------------------------------------------------- /cpp-test/test-t/e_14.c: -------------------------------------------------------------------------------- 1 | /* e_14.c: Illegal #if expressions. */ 2 | 3 | /* { dg-do preprocess } */ 4 | /* { dg-options "-ansi -pedantic-errors -w" } */ 5 | 6 | #define A 1 7 | #define B 1 8 | 9 | /* 14.1: String literal is not allowed in #if expression. */ 10 | #if "string" /* { dg-error "not (valid|allowed) in (#if|preprocessor)( expressions|)| Can't use a string literal" } */ 11 | #endif /* The second error ? */ 12 | 13 | -------------------------------------------------------------------------------- /cpp-test/test-t/e_14_2.c: -------------------------------------------------------------------------------- 1 | /* e_14_2.c: Illegal #if expressions-2. */ 2 | 3 | /* { dg-do preprocess } */ 4 | /* { dg-options "-ansi -pedantic-errors -w" } */ 5 | 6 | #define A 1 7 | #define B 1 8 | 9 | /* 14.2: Operators =, +=, ++, etc. are not allowed in #if expression.*/ 10 | 11 | #if A = B /* { dg-error "is not valid| (parse|syntax) error| Can't use the operator" } */ 12 | #endif 13 | #if A++ B /* { dg-error "is not (valid|allowed)| Can't use the operator" } */ 14 | #endif 15 | #if A.B /* { dg-error "is not valid| (parse|syntax) error| empty #if expression| Can't use the operator" } */ 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /cpp-test/test-t/e_14_7.c: -------------------------------------------------------------------------------- 1 | /* e_14_7.c: There is no keyword in #if expression. */ 2 | 3 | /* { dg-do preprocess } 4 | { dg-options "-ansi -w" } 5 | */ 6 | 7 | /* 14.7: sizeof operator is disallowed. */ 8 | /* Evaluated as: 0 (0) 9 | Constant expression syntax error. */ 10 | #if sizeof (int) /* { dg-error "missing binary operator|(parse|syntax) error| Operator \"\\(\" in incorrect context" } */ 11 | #endif 12 | 13 | /* 14.8: type cast is disallowed. */ 14 | /* Evaluated as: (0)0x8000 15 | Also a constant expression error. */ 16 | #if (int)0x8000 < 0 /* { dg-error "missing binary operator|(parse|syntax) error| Misplaced constant" } */ 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /cpp-test/test-t/e_14_9.c: -------------------------------------------------------------------------------- 1 | /* e_14_9.c: Out of range in #if expression (division by 0). */ 2 | 3 | /* { dg-do preprocess } */ 4 | 5 | /* 14.9: Divided by 0. */ 6 | #if 1 / 0 /* { dg-error "(D|d)ivision by zero" } */ 7 | #endif 8 | 9 | -------------------------------------------------------------------------------- /cpp-test/test-t/e_15_3.c: -------------------------------------------------------------------------------- 1 | /* e_15_3.c: #ifdef, #ifndef syntax errors. */ 2 | 3 | /* { dg-do preprocess } */ 4 | 5 | /* 15.3: Not an identifier. */ 6 | #ifdef "string" /* { dg-error "macro names must be identifiers|argument starts with punctuation| Not an identifier" } */ 7 | #endif 8 | #ifdef 123 /* { dg-error "macro names must be identifiers|argument starts with a digit| Not an identifier" } */ 9 | #endif 10 | 11 | /* 15.4: Excessive token sequence. */ 12 | #ifdef MACRO Junk /* { dg-error "extra tokens|garbage at end| Excessive token sequence" } */ 13 | #endif 14 | 15 | /* 15.5: No argument. */ 16 | #ifndef /* { dg-error "no macro name given| (N|n)o argument" } */ 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /cpp-test/test-t/e_16.c: -------------------------------------------------------------------------------- 1 | /* e_16.c: Trailing junk of #else, #endif. */ 2 | 3 | /* { dg-do preprocess } */ 4 | 5 | /* 16.1: Trailing junk of #else. */ 6 | #define MACRO_0 0 7 | #if MACRO_0 8 | #else MACRO_0 /* { dg-error "extra tokens|text following| Excessive token sequence" } */ 9 | 10 | /* 16.2: Trailing junk of #endif. */ 11 | #endif MACRO_0 /* { dg-error "extra tokens|text following| Excessive token sequence" } */ 12 | 13 | -------------------------------------------------------------------------------- /cpp-test/test-t/e_17_5.c: -------------------------------------------------------------------------------- 1 | /* e_17_5.c: Imbalance of #if - #endif in included files. */ 2 | 3 | /* { dg-do preprocess } */ 4 | 5 | /* 17.5: Error of #endif without #if in an included file. */ 6 | #if 1 7 | #include "unbal1.h" 8 | /* { dg-error "e_17_5.c:7:\n\[\^ \]*( error:|) (#endif without #if|unbalanced `#endif')| Not in a #if \\(#ifdef\\) section in a source file" "" { target *-*-* } 0 } */ 9 | 10 | /* 17.6: Error of unterminated #if section in an included file. */ 11 | #include "unbal2.h" 12 | /* { dg-error "e_17_5.c:11:\n\[\^ \]*( error:|) unterminated (#else|`#else')| End of file within #if \\(#ifdef\\) section" "" { target *-*-* } 0 } */ 13 | #endif 14 | 15 | -------------------------------------------------------------------------------- /cpp-test/test-t/e_24_6.c: -------------------------------------------------------------------------------- 1 | /* e_24_6.c: Operand of # operator in function-like macro definition shall 2 | be a parameter name. */ 3 | 4 | /* { dg-do preprocess } */ 5 | 6 | /* 24.6: */ 7 | #define FUNC( a) # b /* { dg-error "not followed by a macro parameter| should be followed by a macro argument name| Not a formal parameter" } */ 8 | 9 | -------------------------------------------------------------------------------- /cpp-test/test-t/e_25_6.c: -------------------------------------------------------------------------------- 1 | /* e_25_6.c: Macro arguments are pre-expanded separately. */ 2 | 3 | /* { dg-do preprocess } */ 4 | 5 | #define sub( x, y) (x - y) 6 | 7 | /* 25.6: */ 8 | #define head sub( 9 | #define body(x,y) x,y 10 | #define tail ) 11 | #define head_body_tail( a, b, c) a b c 12 | /* "head" is once replaced to "sub(", then rescanning of "sub(" causes an 13 | uncompleted macro call. Expansion of an argument should complete 14 | within the argument. */ 15 | head_body_tail( head, body(a,b), tail); 16 | /* { dg-error "unterminated argument list| (U|u)nterminated macro call" "" { target *-*-* } 15 } */ 17 | 18 | -------------------------------------------------------------------------------- /cpp-test/test-t/e_27_7.c: -------------------------------------------------------------------------------- 1 | /* e_27_7.c: Error of rescanning. */ 2 | 3 | /* { dg-do preprocess } */ 4 | 5 | #define sub( x, y) (x - y) 6 | 7 | /* 27.7: */ 8 | #define TWO_TOKENS a,b 9 | #define SUB( x, y) sub( x, y) 10 | /* Too many arguments error while rescanning after once replaced to: 11 | sub( a,b, 1); */ 12 | SUB( TWO_TOKENS, 1); 13 | /* { dg-error "passed 3 arguments, but takes just 2| used with too many \\(3\\) args| More than necessary 2 argument\\(s\\) in macro call" "too many arguments in rescanning" { target *-*-* } 12 } */ 14 | 15 | -------------------------------------------------------------------------------- /cpp-test/test-t/e_29_3.c: -------------------------------------------------------------------------------- 1 | /* e_29_3.c: #undef errors. */ 2 | 3 | /* { dg-do preprocess } */ 4 | 5 | /* 29.3: Not an identifier. */ 6 | #undef "string" /* { dg-error "macro names must be identifiers| invalid macro name| Not an identifier" } */ 7 | #undef 123 /* { dg-error "macro names must be identifiers| invalid macro name| Not an identifier" } */ 8 | 9 | /* 29.4: Excessive token sequence. */ 10 | #undef MACRO_0 Junk /* { dg-error "extra tokens| garbage after| Excessive token sequence" } */ 11 | 12 | /* 29.5: No argument. */ 13 | #undef /* { dg-error "no macro name| invalid macro name| No identifier" } */ 14 | 15 | -------------------------------------------------------------------------------- /cpp-test/test-t/e_31.c: -------------------------------------------------------------------------------- 1 | /* e_31.c: Illegal macro calls. */ 2 | 3 | /* { dg-do preprocess } */ 4 | 5 | #define sub( a, b) (a - b) 6 | 7 | /* 31.1: Too many arguments error. */ 8 | sub( x, y, z); /* { dg-error "passed 3 arguments, but takes just 2| used with too many \\(3\\) args| More than necessary 2 argument\\(s\\) in macro call" } */ 9 | 10 | /* 31.2: Too few arguments error. */ 11 | sub( x); /* { dg-error "requires 2 arguments, but only 1 given| used with just one arg| Less than necessary 2 argument\\(s\\) in macro call" } */ 12 | 13 | -------------------------------------------------------------------------------- /cpp-test/test-t/e_31_3.c: -------------------------------------------------------------------------------- 1 | /* e_31_3.c: Macro call in control line should complete in the line. */ 2 | 3 | /* { dg-do preprocess } */ 4 | 5 | #define glue( a, b) a ## b 6 | #define str( s) # s 7 | #define xstr( s) str( s) 8 | 9 | /* 31.3: Unterminated macro call. */ 10 | #include xstr( glue( header, 11 | .h)) 12 | /* [ dg-error "unterminated argument list| (U|u)nterminated macro call" "" { target *-*-* } 10 } */ 13 | /* { dg-excess-errors "" } */ 14 | 15 | -------------------------------------------------------------------------------- /cpp-test/test-t/e_32_5.c: -------------------------------------------------------------------------------- 1 | /* e_32_5.c: Range error of character constant. */ 2 | 3 | /* { dg-do preprocess } */ 4 | 5 | /* 32.5: Value of a numerical escape sequence in character constant should 6 | be in the range of char. */ 7 | /* Out of range */ 8 | #if '\x123' == 0x123 /* { dg-error "escape sequence out of range| hex character constant does not fit in a byte| 8 bits can't represent escape sequence" } */ 9 | #endif 10 | 11 | -------------------------------------------------------------------------------- /cpp-test/test-t/e_33_2.c: -------------------------------------------------------------------------------- 1 | /* e_33_2.c: Out of range of numerical escape sequence in wide-char. */ 2 | 3 | /* { dg-do preprocess } */ 4 | /* { dg-options "-ansi -pedantic-errors -Wall" } */ 5 | 6 | /* 33.2: Value of a numerical escape sequence in wide-character constant 7 | should be in the range of wchar_t. */ 8 | #if L'\xabcdef012' == 0xbcdef012 /* Perhaps out of range. */ 9 | /* { dg-error "escape sequence out of range| (16|32) bits can't represent escape sequence" "" { target *-*-* } 8 } */ 10 | #endif 11 | 12 | -------------------------------------------------------------------------------- /cpp-test/test-t/e_35_2.c: -------------------------------------------------------------------------------- 1 | /* e_35_2.c: Out of range of character constant. */ 2 | 3 | /* { dg-do preprocess } */ 4 | 5 | /* 35.2: */ 6 | /* Perhaps out of range. */ 7 | #if 'abcdefghi' /* { dg-error "character constant too long| out of range" } */ 8 | #endif 9 | 10 | -------------------------------------------------------------------------------- /cpp-test/test-t/e_4_3.c: -------------------------------------------------------------------------------- 1 | /* e_4_3.c: Illegal pp-token. */ 2 | 3 | /* { dg-do preprocess } */ 4 | 5 | /* 4.3: Empty character constant is an error. */ 6 | #if '' == 0 /* { dg-error "empty character constant| Empty character constant '', skipped the line\n\[^ \]* error:" "" } */ 7 | #endif /* Maybe the second error */ 8 | 9 | -------------------------------------------------------------------------------- /cpp-test/test-t/e_7_4.c: -------------------------------------------------------------------------------- 1 | /* e_7_4.c: #line error. */ 2 | 3 | /* { dg-do preprocess } */ 4 | 5 | /* 7.4: string literal in #line directive shall be a character string 6 | literal. */ 7 | 8 | #line 123 L"wide" /* { dg-error "not a valid filename| invalid format| Not a file name" } */ 9 | /* 10; "e_7_4.c"; */ 10 | __LINE__; __FILE__; 11 | 12 | -------------------------------------------------------------------------------- /cpp-test/test-t/e_operat.C: -------------------------------------------------------------------------------- 1 | /* e_operat.C */ 2 | /* 3 | * In C++98 the 11 identifier-like tokens are operators, not identifiers. 4 | * Note: in C95 these are defined as macros by . 5 | */ 6 | 7 | /* { dg-do preprocess } */ 8 | /* { dg-options "-std=c++98 -pedantic-errors" } */ 9 | 10 | /* Cannot define operator as a macro. */ 11 | #define and && /* { dg-error "cannot be used as a macro name| is defined as macro" } */ 12 | #define xor_eq ^= /* { dg-error "cannot be used as a macro name| is defined as macro" } */ 13 | 14 | -------------------------------------------------------------------------------- /cpp-test/test-t/e_pragma.c: -------------------------------------------------------------------------------- 1 | /* e_pragma.c: Erroneous use of _Pragma() operator */ 2 | 3 | /* { dg-do preprocess } */ 4 | /* { dg-options "-std=c99 -pedantic-errors" } */ 5 | 6 | /* Operand of _Pragma() should be a string literal */ 7 | _Pragma( This is not a string literal) 8 | /* { dg-error "_Pragma takes a parenthesized string literal| Operand of _Pragma\\(\\) is not a string literal" "" { target *-*-* } 7 } */ 9 | 10 | -------------------------------------------------------------------------------- /cpp-test/test-t/header.h: -------------------------------------------------------------------------------- 1 | /* header.h */ 2 | 3 | #define MACRO_xyz xyz 4 | #define MACRO_zyx zyx 5 | 6 | -------------------------------------------------------------------------------- /cpp-test/test-t/i_32_3.c: -------------------------------------------------------------------------------- 1 | /* i_32_3.c: Character constant in #if expression. */ 2 | 3 | /* In ASCII character set. */ 4 | /* 32.3: */ 5 | #if 'a' != 0x61 6 | #error Not ASCII character set, or bad evaluation of character constant. 7 | #endif 8 | 9 | /* 32.4: '\a' and '\v' */ 10 | #if '\a' != 7 || '\v' != 11 11 | #error Not ASCII character set, or bad evaluation of escape sequences. 12 | #endif 13 | 14 | /* { dg-do preprocess } */ 15 | 16 | -------------------------------------------------------------------------------- /cpp-test/test-t/i_35.c: -------------------------------------------------------------------------------- 1 | /* i_35.c: Multi-character character constant. */ 2 | 3 | /* In ASCII character set. */ 4 | /* 35.1: */ 5 | #if ('ab' != '\x61\x62') || ('\aa' != '\7\x61') 6 | #error Bad handling of multi-character character constant. 7 | #endif 8 | 9 | /* { dg-do preprocess } 10 | { dg-options -w } */ 11 | 12 | -------------------------------------------------------------------------------- /cpp-test/test-t/line.h: -------------------------------------------------------------------------------- 1 | /* line.h */ 2 | 3 | __LINE__; __FILE__; 4 | -------------------------------------------------------------------------------- /cpp-test/test-t/n_1.c: -------------------------------------------------------------------------------- 1 | /* n_1.c: Conversion of trigraph sequences. */ 2 | 3 | /* 1.1: The following 9 sequences are valid trigraph sequences. */ 4 | /* [ ] \ ^ { } | ~ #; */ 5 | ??( ??) ??/ ??' ??< ??> ??! ??- ??=; 6 | 7 | /* 1.2: In directive line. */ 8 | /* ab | cd; */ 9 | ??= define OR( a, b) a ??! b 10 | OR( ab, cd); 11 | 12 | /* { dg-do preprocess } 13 | { dg-final { if ![file exist n_1.i] { return } } } 14 | { dg-final { if \{ [grep n_1.i "\[ \] \\ \^ \{ \} \| ~ #"] != "" \} \{ } } 15 | { dg-final { if \{ [grep n_1.i "ab *\| *cd"] != "" \} \{ } } 16 | { dg-final { return \} \} \} } } 17 | { dg-final { fail "n_1.c: trigraphs conversion" } } 18 | */ 19 | 20 | -------------------------------------------------------------------------------- /cpp-test/test-t/n_13_5.c: -------------------------------------------------------------------------------- 1 | /* n_13_5.c: Arithmetic conversion in #if expressions. */ 2 | 3 | /* 13.5: The usual arithmetic conversion is not performed on bit shift. */ 4 | #if -1 << 3U > 0 5 | #error Bad conversion of bit shift operands. 6 | #endif 7 | 8 | /* 13.6: Usual arithmetic conversions. */ 9 | #if -1 <= 0U /* -1 is converted to unsigned long. */ 10 | #error Bad arithmetic conversion. 11 | #endif 12 | 13 | #if -1 * 1U <= 0 14 | #error Bad arithmetic conversion. 15 | #endif 16 | 17 | /* Second and third operands of conditional operator are converted to the 18 | #error same type, thus -1 is converted to unsigned long. */ 19 | #if (1 ? -1 : 0U) <= 0 20 | #error Bad arithmetic conversion. 21 | #endif 22 | 23 | /* { dg-do preprocess } 24 | { dg-options "-ansi -w" } 25 | */ 26 | -------------------------------------------------------------------------------- /cpp-test/test-t/n_20.c: -------------------------------------------------------------------------------- 1 | /* n_20.c: Definition of macro lexically identical to keyword. */ 2 | 3 | /* 20.1: */ 4 | /* double fl; */ 5 | #define float double 6 | float fl; 7 | 8 | /* { dg-do preprocess } 9 | { dg-final { if ![file exist n_20.i] { return } } } 10 | { dg-final { if \{ [grep n_20.i "double +fl"] != "" \} \{ } } 11 | { dg-final { return \} } } 12 | { dg-final { fail "n_20.c: macro identical to keyword" } } 13 | */ 14 | 15 | -------------------------------------------------------------------------------- /cpp-test/test-t/n_21.c: -------------------------------------------------------------------------------- 1 | /* n_21.c: Tokenization (No preprocessing tokens are merged implicitly). */ 2 | 3 | /* 21.1: */ 4 | /* - - -a; */ 5 | #define MINUS - 6 | -MINUS-a; 7 | 8 | /* 21.2: */ 9 | #define sub( a, b) a-b /* '(a)-(b)' is better */ 10 | #define Y -y /* '(-y)' is better */ 11 | /* x- -y; */ 12 | sub( x, Y); 13 | 14 | /* { dg-do preprocess } 15 | { dg-final { if ![file exist n_21.i] { return } } } 16 | { dg-final { if \{ [grep n_21.i "- +- +- *a"] != "" \} \{ } } 17 | { dg-final { if \{ [grep n_21.i "x *- +- *y"] != "" \} \{ } } 18 | { dg-final { return \} \} } } 19 | { dg-final { fail "n_21.c: tokenization of expanded macro" } } 20 | */ 21 | 22 | -------------------------------------------------------------------------------- /cpp-test/test-t/n_23.c: -------------------------------------------------------------------------------- 1 | /* n_23.c: ## operator in macro definition. */ 2 | 3 | #define glue( a, b) a ## b 4 | #define xglue( a, b) glue( a, b) 5 | 6 | /* 23.1: */ 7 | /* xy; */ 8 | glue( x, y); 9 | 10 | /* 23.2: Generate a preprocessing number. */ 11 | /* .12e+2; */ 12 | #define EXP 2 13 | xglue( .12e+, EXP); 14 | 15 | /* { dg-do preprocess } 16 | { dg-final { if ![file exist n_23.i] { return } } } 17 | { dg-final { if \{ [grep n_23.i "xy"] != "" \} \{ } } 18 | { dg-final { if \{ [grep n_23.i "\.12e\\+2"] != "" \} \{ } } 19 | { dg-final { return \} \} } } 20 | { dg-final { fail "n_23.c: ## operator" } } 21 | */ 22 | 23 | -------------------------------------------------------------------------------- /cpp-test/test-t/n_29.c: -------------------------------------------------------------------------------- 1 | /* n_29.c: #undef directive. */ 2 | 3 | /* 29.1: Undefined macro is not a macro. */ 4 | /* DEFINED; */ 5 | #define DEFINED 6 | #undef DEFINED 7 | DEFINED; 8 | 9 | /* 29.2: Undefining undefined name is not an error. */ 10 | #undef UNDEFINED 11 | 12 | /* { dg-do preprocess } 13 | { dg-final { if ![file exist n_29.i] { return } } } 14 | { dg-final { if \{ [grep n_29.i "DEFINED"] != "" \} \{ } } 15 | { dg-final { return \} } } 16 | { dg-final { fail "n_29.c: #undef" } } 17 | */ 18 | 19 | -------------------------------------------------------------------------------- /cpp-test/test-t/n_32.c: -------------------------------------------------------------------------------- 1 | /* n_32.c: Escape sequence in character constant in #if expression. */ 2 | 3 | /* 32.1: Character octal escape sequence. */ 4 | #if '\123' != 83 5 | #error Bad evaluation of octal escape sequence. 6 | #endif 7 | 8 | /* 32.2: Character hexadecimal escape sequence. */ 9 | #if '\x1b' != '\033' 10 | #error Bad evaluation of hexadecimal escape sequence. 11 | #endif 12 | 13 | /* { dg-do preprocess } */ 14 | 15 | -------------------------------------------------------------------------------- /cpp-test/test-t/n_3_4.c: -------------------------------------------------------------------------------- 1 | /* n_3_4.c: Handling of comment and . */ 2 | 3 | /* 3.4: Comment and in #error line. */ 4 | #error Message of first physical line. \ 5 | Message of second physical and first logical line. /* 6 | this comment splices the lines 7 | */ Message of forth physical and third logical line. 8 | 9 | /* { dg-do preprocess } 10 | { dg-options "-ansi -w" } 11 | { dg-error "Message of first physical line\. *Message of second physical and first logical line\. *Message of forth physical and third logical line\." "n_3_4.c" { target *-*-* } 0 } 12 | */ 13 | 14 | -------------------------------------------------------------------------------- /cpp-test/test-t/n_4.c: -------------------------------------------------------------------------------- 1 | /* n_4.c: Special tokens. */ 2 | 3 | /* 4.1: Digraph spellings in directive line. */ 4 | /* "abc"; */ 5 | %: define stringize( a) %: a 6 | 7 | stringize( abc); 8 | 9 | /* 4.2: Digraph spellings are retained in stringization. */ 10 | /* "<:"; */ 11 | stringize( <:); 12 | 13 | /* { dg-do preprocess } 14 | { dg-options "-std=iso9899:199409" } 15 | { dg-final { if ![file exist n_4.i] { return } } } 16 | { dg-final { if \{ [grep n_4.i "\"abc\""] != "" \} \{ } } 17 | { dg-final { if \{ [grep n_4.i "\"<:\""] != "" \} \{ } } 18 | { dg-final { return \} \} } } 19 | { dg-final { fail "n_4.c: digraphs conversion" } } 20 | */ 21 | 22 | -------------------------------------------------------------------------------- /cpp-test/test-t/n_5.c: -------------------------------------------------------------------------------- 1 | /* n_5.t: Spaces or tabs are allowed at any place in pp-directive line, 2 | including between the top of a pp-directive line and '#', and between 3 | the '#' and the directive. */ 4 | 5 | /* 5.1: */ 6 | /* |**|[TAB]# |**|[TAB]define |**| MACRO_abcde[TAB]|**| abcde |**| */ 7 | /**/ # /**/ define /**/ MACRO_abcde /**/ abcde /**/ 8 | /* abcde */ 9 | MACRO_abcde 10 | 11 | /* { dg-do preprocess } 12 | { dg-final { if ![file exist n_5.i] { return } } } 13 | { dg-final { if \{ [grep n_5.i "abcde"] != "" \} \{ } } 14 | { dg-final { return \} } } 15 | { dg-final { fail "n_5.c: spaces and tabs in directive line" } } 16 | */ 17 | 18 | -------------------------------------------------------------------------------- /cpp-test/test-t/n_8.c: -------------------------------------------------------------------------------- 1 | /* n_8.c: #error directive. */ 2 | 3 | /* 8.1: Argument of #error directive is not a subject of macro expansion. 4 | Output to stderr as an example: 5 | Preprocessing error directive: MACRO is not a positive number. 6 | from line 10 of file "n_8.c" 7 | */ 8 | #define MACRO 0 9 | #if MACRO <= 0 10 | #error MACRO is not a positive number. 11 | #endif 12 | 13 | /* { dg-do preprocess } 14 | { dg-error "MACRO is not a positive number." "n_8.c" { target *-*-* } 10 } 15 | */ 16 | 17 | -------------------------------------------------------------------------------- /cpp-test/test-t/n_8_2.c: -------------------------------------------------------------------------------- 1 | /* n_8_2.c: Argument of #error is optional. */ 2 | /* { dg-do preprocess } */ 3 | 4 | /* 8.2: #error should be executed. */ 5 | #error /* { dg-error "#error" } */ 6 | 7 | -------------------------------------------------------------------------------- /cpp-test/test-t/n_9.c: -------------------------------------------------------------------------------- 1 | /* n_9.t: #pragma directive. */ 2 | 3 | /* 9.1: Any #pragma directive should be processed or ignored, should not 4 | be diagnosed as an error. */ 5 | #pragma __once 6 | #pragma who knows ? 7 | 8 | /* { dg-do preprocess } */ 9 | 10 | -------------------------------------------------------------------------------- /cpp-test/test-t/n_cnvucn.C: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/cpp-test/test-t/n_cnvucn.C -------------------------------------------------------------------------------- /cpp-test/test-t/n_cplus.C: -------------------------------------------------------------------------------- 1 | /* n_cplus.C: C++98 pre-defined macro __cplusplus. */ 2 | 3 | /* 199711L */ 4 | #if __cplusplus < 199711L 5 | #error __cplusplus not conforms to C++98 6 | #endif 7 | 8 | /* { dg-do preprocess } 9 | { dg-options "-std=c++98" } 10 | */ 11 | 12 | -------------------------------------------------------------------------------- /cpp-test/test-t/n_dslcom.c: -------------------------------------------------------------------------------- 1 | /* n_dslcom.c: // is a comment of C++ and C99. */ 2 | /* a; */ 3 | a; // is a comment of C++ and C99 4 | 5 | /* { dg-do preprocess } 6 | { dg-options "-std=c99" } 7 | { dg-final { if ![file exist n_dslcom.i] { return } } } 8 | { dg-final { if \{ [grep n_dslcom.i "^\[ \]*a;\[ \]*$"] != "" \} \{ } } 9 | { dg-final { return \} } } 10 | { dg-final { fail "n_dslcom.c: double slash comment" } } 11 | */ 12 | 13 | -------------------------------------------------------------------------------- /cpp-test/test-t/n_dslcom_cplus.C: -------------------------------------------------------------------------------- 1 | /* n_dslcom_cplus.C: // is a comment of C++ and C99. */ 2 | /* a; */ 3 | a; // is a comment of C++ and C99 4 | 5 | /* { dg-do preprocess } 6 | { dg-options "-std=c++98" } 7 | { dg-final { if ![file exist n_dslcom_cplus.i] { return } } } 8 | { dg-final { if \{ [grep n_dslcom_cplus.i "^\[ \]*a;\[ \]*$"] != "" \} \{ } } 9 | { dg-final { return \} } } 10 | { dg-final { fail "n_dslcom_cplus.C: double slash comment" } } 11 | */ 12 | 13 | -------------------------------------------------------------------------------- /cpp-test/test-t/n_line.c: -------------------------------------------------------------------------------- 1 | /* n_line.c: line number argument of #line */ 2 | /* C99: Range of line number in #line directive is [1..2147483647] */ 3 | 4 | /* 2147483647; */ 5 | #line 2147483647 6 | __LINE__; 7 | 8 | /* { dg-do preprocess } 9 | { dg-options "-std=c99 -w" } 10 | { dg-final { if ![file exist n_line.i] { return } } } 11 | { dg-final { if \{ [grep n_line.i "2147483647"] != "" \} \{ } } 12 | { dg-final { return \} } } 13 | { dg-final { fail "n_line.c: line number in C99" } } 14 | */ 15 | 16 | -------------------------------------------------------------------------------- /cpp-test/test-t/n_llong.c: -------------------------------------------------------------------------------- 1 | /* n_llong.c: long long in #if expression */ 2 | 3 | #if 12345678901234567890U < 13345678901234567890U 4 | "long long #if expression is implemented." 5 | #else 6 | "long long #if expression is not implemented." 7 | #endif 8 | 9 | #if 12345678901234567890ULL < 13345678901234567890ULL 10 | Valid block 11 | #else 12 | Block to be skipped 13 | #endif 14 | 15 | #if (0x7FFFFFFFFFFFFFFFULL - 0x6FFFFFFFFFFFFFFFULL) >> 60 == 1 16 | Valid block 17 | #else 18 | Block to be skipped 19 | #endif 20 | 21 | /* { dg-do preprocess } 22 | { dg-options "-std=c99" } 23 | */ 24 | 25 | -------------------------------------------------------------------------------- /cpp-test/test-t/n_ppnum.c: -------------------------------------------------------------------------------- 1 | /* n_ppnum.c: Preprocessing number token *p+* */ 2 | /* Undefined on C90, because '+A' is not a valid pp-token. */ 3 | 4 | #define A 3 5 | #define glue( a, b) a ## b 6 | /* 12p+A; */ 7 | glue( 12p+, A); 8 | 9 | /* { dg-do preprocess } 10 | { dg-options "-std=c99" } 11 | { dg-final { if ![file exist n_ppnum.i] { return } } } 12 | { dg-final { if \{ [grep n_ppnum.i "12p\\+A"] != "" \} \{ } } 13 | { dg-final { return \} } } 14 | { dg-final { fail "n_ppnum.c: pp-number including p+" } } 15 | */ 16 | 17 | -------------------------------------------------------------------------------- /cpp-test/test-t/n_stdmac.c: -------------------------------------------------------------------------------- 1 | /* n_stdmac.c: C99 Standard pre-defined macros. */ 2 | 3 | /* 199901L */ 4 | __STDC_VERSION__ 5 | 6 | /* 1 or 0 */ 7 | __STDC_HOSTED__ 8 | 9 | /* { dg-do preprocess } 10 | { dg-options "-std=c99" } 11 | { dg-final { if ![file exist n_stdmac.i] { return } } } 12 | { dg-final { if \{ [grep n_stdmac.i "199901L"] != "" \} \{ } } 13 | { dg-final { if \{ [grep n_stdmac.i "1|0"] != "" \} \{ } } 14 | { dg-final { if \{ [grep n_stdmac.i "__STDC_HOSTED__"] == "" \} \{ } } 15 | { dg-final { return \} \} \} } } 16 | { dg-final { fail "n_stdmac.c: standard pre-defined macro in C99" } } 17 | */ 18 | 19 | -------------------------------------------------------------------------------- /cpp-test/test-t/n_ucn1.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/cpp-test/test-t/n_ucn1.c -------------------------------------------------------------------------------- /cpp-test/test-t/n_ucn1_cplus.C: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/cpp-test/test-t/n_ucn1_cplus.C -------------------------------------------------------------------------------- /cpp-test/test-t/n_ucn2.c: -------------------------------------------------------------------------------- 1 | /* n_ucn2.c: Universal-character-name */ 2 | 3 | /* UCN in pp-number */ 4 | 5 | #define mkint( a) a ## 1\u5B57 6 | 7 | int mkint( abc) = 0; /* int abc1\u5B57 = 0; */ 8 | 9 | /* { dg-do preprocess } 10 | { dg-options "-std=c99" } 11 | { dg-final { if ![file exist n_ucn2.i] { return } } } 12 | { dg-final { if \{ [grep n_ucn2.i "int *abc1\\\\u5\[Bb\]57 *= *0"] != "" \} \{ } } 13 | { dg-final { return \} } } 14 | { dg-final { fail "n_ucn2.c: UCN in pp-number" } } 15 | */ 16 | 17 | -------------------------------------------------------------------------------- /cpp-test/test-t/nest1.h: -------------------------------------------------------------------------------- 1 | /* nest1.h */ 2 | 3 | nest = 1; 4 | 5 | #include "nest2.h" 6 | -------------------------------------------------------------------------------- /cpp-test/test-t/nest10.h: -------------------------------------------------------------------------------- 1 | /* nest10.h */ 2 | #include "nest11.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-t/nest11.h: -------------------------------------------------------------------------------- 1 | /* nest11.h */ 2 | #include "nest12.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-t/nest12.h: -------------------------------------------------------------------------------- 1 | /* nest12.h */ 2 | #include "nest13.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-t/nest13.h: -------------------------------------------------------------------------------- 1 | /* nest13.h */ 2 | #include "nest14.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-t/nest14.h: -------------------------------------------------------------------------------- 1 | /* nest14.h */ 2 | #include "nest15.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-t/nest15.h: -------------------------------------------------------------------------------- 1 | /* nest15.h */ 2 | #ifdef X0F 3 | nest = 0x0f; 4 | #endif 5 | -------------------------------------------------------------------------------- /cpp-test/test-t/nest2.h: -------------------------------------------------------------------------------- 1 | /* nest2.h */ 2 | 3 | nest = 2; 4 | 5 | #include "nest3.h" 6 | -------------------------------------------------------------------------------- /cpp-test/test-t/nest3.h: -------------------------------------------------------------------------------- 1 | /* nest3.h */ 2 | 3 | nest = 3; 4 | 5 | #include "nest4.h" 6 | -------------------------------------------------------------------------------- /cpp-test/test-t/nest4.h: -------------------------------------------------------------------------------- 1 | /* nest4.h */ 2 | 3 | nest = 4; 4 | 5 | #include "nest5.h" 6 | -------------------------------------------------------------------------------- /cpp-test/test-t/nest5.h: -------------------------------------------------------------------------------- 1 | /* nest5.h */ 2 | 3 | nest = 5; 4 | 5 | #include "nest6.h" 6 | -------------------------------------------------------------------------------- /cpp-test/test-t/nest6.h: -------------------------------------------------------------------------------- 1 | /* nest6.h */ 2 | 3 | nest = 6; 4 | 5 | #include "nest7.h" 6 | -------------------------------------------------------------------------------- /cpp-test/test-t/nest7.h: -------------------------------------------------------------------------------- 1 | /* nest7.h */ 2 | 3 | nest = 7; 4 | 5 | #include "nest8.h" 6 | -------------------------------------------------------------------------------- /cpp-test/test-t/nest8.h: -------------------------------------------------------------------------------- 1 | /* nest8.h */ 2 | 3 | nest = 8; 4 | #ifndef X8 5 | #include "nest9.h" 6 | #endif 7 | 8 | -------------------------------------------------------------------------------- /cpp-test/test-t/nest9.h: -------------------------------------------------------------------------------- 1 | /* nest9.h */ 2 | #include "nest10.h" 3 | -------------------------------------------------------------------------------- /cpp-test/test-t/pragmas.h: -------------------------------------------------------------------------------- 1 | /* pragmas.h based on the proposal to C99 by Bill Homer */ 2 | 3 | #if defined(Machine_A) 4 | /* Request fastest calling sequence for machine A */ 5 | # define Fast_call \ 6 | _Pragma("fast_call") 7 | #elif defined(Machine_B) 8 | /* Request fastest calling sequence for machine B */ 9 | # define Fast_call \ 10 | _Pragma("vfunction") 11 | #else 12 | # define Fast_call 13 | #endif 14 | 15 | #if defined(Machine_B) 16 | /* Vectorization hint (ignore vector dependencies) */ 17 | # define Independent _Pragma("ivdep") 18 | #elif defined(Machine_C) 19 | /* Parallelization hint (iterations are independent) */ 20 | # define Independent _Pragma("independent") 21 | #else 22 | # define Independent 23 | #endif 24 | 25 | -------------------------------------------------------------------------------- /cpp-test/test-t/u_1_11.c: -------------------------------------------------------------------------------- 1 | /* u_1_11.c: Undefined behaviors on undefined #include syntax or header- 2 | name. */ 3 | 4 | /* { dg-do preprocess } */ 5 | 6 | /* u.1.11: Header-name containing ', ", \ or / followed by *. */ 7 | /* Probably illegal filename and fails to open. */ 8 | #include "../*line.h" /* { dg-error "No such file or directory| Can't open include file" } */ 9 | /* \ is a legal path-delimiter in DOS/Windows or some other OS's. */ 10 | #include "..\test-t\line.h" /* { dg-error "No such file or directory| Can't open include file" } */ 11 | 12 | -------------------------------------------------------------------------------- /cpp-test/test-t/u_1_12.c: -------------------------------------------------------------------------------- 1 | /* u_1_12.c: Undefined behaviors on undefined #include syntax or header- 2 | name. */ 3 | 4 | /* { dg-do preprocess } */ 5 | 6 | /* u.1.12: Argument of #include other than header-name. */ 7 | #include filename /* { dg-error "(#include|`#include') expects | Not a header name" } */ 8 | 9 | -------------------------------------------------------------------------------- /cpp-test/test-t/u_1_13.c: -------------------------------------------------------------------------------- 1 | /* u_1_13.c: Undefined behaviors on undefined #include syntax or header- 2 | name. */ 3 | 4 | /* { dg-do preprocess } */ 5 | 6 | /* u.1.13: Excessive argument in #include directive. */ 7 | #include Junk /* { dg-error "extra tokens | `#include' expects | Excessive token sequence" } */ 8 | 9 | -------------------------------------------------------------------------------- /cpp-test/test-t/u_1_14.c: -------------------------------------------------------------------------------- 1 | /* u_1_14.c: Undefined behaviors on undefined #line syntax. */ 2 | 3 | /* { dg-do preprocess } */ 4 | 5 | /* u.1.14: #line directive without an argument of line number. */ 6 | #line "filename" /* { dg-error "not a positive integer| invalid format | Not a line number" } */ 7 | 8 | /* u.1.15: #line directive with the second argument of other than string 9 | literal. */ 10 | #line 1234 filename /* { dg-error "not a valid filename| invalid format | Not a file name" } */ 11 | 12 | /* u.1.16: Excessive argument in #line directive. */ 13 | #line 2345 "filename" Junk /* { dg-error "extra tokens| garbage | Excessive token sequence" } */ 14 | 15 | -------------------------------------------------------------------------------- /cpp-test/test-t/u_1_17.c: -------------------------------------------------------------------------------- 1 | /* u_1_17.c: Undefined behaviors on out-of-range #line number. */ 2 | 3 | /* { dg-do preprocess } */ 4 | 5 | /* u.1.17: Line number argument of #line directive should be in range of 6 | [1,32767]. */ 7 | #line 0 /* { dg-error "line number out of range| Line number \"0\" is out of range" } */ 8 | #line 32767 /* valid here */ 9 | /* line 32767 */ 10 | __LINE__; 11 | /* { dg-warning "line number out of range| got beyond range\n\[^ \]* warning: Line number" "" { target *-*-* } 0 } */ 12 | #line 13 /* Restore to correct line number */ 13 | 14 | /* u.1.18: Line number argument of #line directive should be written in 15 | decimal digits. */ 16 | #line 0x1000 /* { dg-error "not a decimal integer| invalid format | isn't a decimal digits sequence" } */ 17 | 18 | -------------------------------------------------------------------------------- /cpp-test/test-t/u_1_17s.c: -------------------------------------------------------------------------------- 1 | /* u_1_17s.c: Undefined behavior on out-of-range #line number. */ 2 | 3 | /* { dg-do preprocess } */ 4 | 5 | /* u.1.17s: Line number argument of #line directive should be in range of 6 | [1,32767]. */ 7 | #line 32768 /* { dg-error "line number out of range| Line number \"32768\" is out of range of \[^ \]*\n\[\^ \]* warning: Line number" } */ 8 | 9 | /* 10 | * Note: DejaGnu sometimes fails to handle one of the dg-error lines of 11 | * #line 0 and #line 32768, when those are tested in a single testcase file. 12 | * So, we separated this testcase from u_1_17.c. 13 | */ 14 | 15 | -------------------------------------------------------------------------------- /cpp-test/test-t/u_1_25.c: -------------------------------------------------------------------------------- 1 | /* u_1_25.c: Miscelaneous undefined macros. */ 2 | 3 | /* { dg-do preprocess } */ 4 | 5 | #define str( a) # a 6 | #define sub( x, y) (x - y) 7 | #define SUB sub 8 | 9 | /* u.1.25: Macro argument otherwise parsed as a directive. */ 10 | /* "#define NAME"; or other undefined behaviour. */ 11 | str( 12 | #define NAME 13 | /* { dg-error "directives may not be used \[a-z \]*\n\[\^ \]* unterminated| embedding a directive within macro arguments | directive-like line" "" { target *-*-* } 12 } */ 14 | ); 15 | 16 | #if 0 /* Added by C90: Corrigendum 1 (1994) and deleted by C99 */ 17 | /* u.1.26: Expanded macro replacement list end with name of function-like 18 | macro. */ 19 | SUB( a, b); 20 | #endif 21 | 22 | -------------------------------------------------------------------------------- /cpp-test/test-t/u_1_27.c: -------------------------------------------------------------------------------- 1 | /* u_1_27.c: Pseudo-directive-line. */ 2 | 3 | /* { dg-do preprocess } */ 4 | 5 | /* u.1.27: Unknown preprocessing directive (other than #pragma). */ 6 | #ifdefined MACRO /* { dg-error "invalid preprocessing directive| Unknown #directive" } */ 7 | /* The second error. */ 8 | #endif /* { dg-error "#endif without #if| unbalanced `#endif'| Not in a #if \\(#ifdef\\) section" } */ 9 | 10 | -------------------------------------------------------------------------------- /cpp-test/test-t/u_1_28.c: -------------------------------------------------------------------------------- 1 | /* u_1_28.c: Macro expanding to name identical to directive. */ 2 | 3 | /* { dg-do preprocess } */ 4 | 5 | #define D define 6 | /* u.1.28: There are following two ways of preprocessing. 7 | 1: "D" isn't expanded, because # is the first token of the line. 8 | Preprocessor reports that "D" is an unknown directive. 9 | 2: "D" is expanded, because that is not a directive. 10 | Compiler-phase will diagnose the output of preprocess. 11 | Anyway, preprocessor should not interprete this line as a preprocessing 12 | directive. 13 | */ 14 | #D A B /* { dg-error "invalid preprocessing directive| Unknown #directive" } */ 15 | 16 | -------------------------------------------------------------------------------- /cpp-test/test-t/u_2.c: -------------------------------------------------------------------------------- 1 | /* u_2.c: Undefined behaviors on undefined constant expression. */ 2 | 3 | /* { dg-do preprocess } */ 4 | 5 | /* u.2.1: Undefined escape sequence. */ 6 | #if '\x' /* { dg-error "no following hex digits| Undefined escape sequence '\\\\x'\n\[^ \]* warning:" } */ 7 | #endif 8 | 9 | /* u.2.2: Illegal bit shift count. */ 10 | /* dg-warning, not dg-error to avoid a problem of GCC 4.3 testsuite */ 11 | #if 1 << -1 /* { dg-warning "Illegal shift count" } */ 12 | #endif 13 | #if 1 << 64 /* { dg-error "integer overflow | Illegal shift count" } */ 14 | #endif 15 | 16 | -------------------------------------------------------------------------------- /cpp-test/test-t/u_concat.c: -------------------------------------------------------------------------------- 1 | /* u_concat.c: Invalid pp-token generated by ## operator. */ 2 | 3 | /* { dg-do preprocess } */ 4 | 5 | #define _VARIANT_BOOL /##/ 6 | /* 7 | * The following line intends to be commented out. '//' generated by the 8 | * macro is, however, not a valid pp-token. Since any comment is removed 9 | * before macro definition or macro expansion, a comment is never generated 10 | * by macro. 11 | */ 12 | _VARIANT_BOOL bool; /* { dg-error "does not give a valid preprocessing token| Not a valid preprocessing token" } */ 13 | 14 | -------------------------------------------------------------------------------- /cpp-test/test-t/u_cplus.C: -------------------------------------------------------------------------------- 1 | /* u_cplus.C: C++: #undef or #define __cplusplus causes undefined 2 | behavior. */ 3 | 4 | /* { dg-do preprocess } */ 5 | /* { dg-options "-std=c++98 -pedantic-errors" } */ 6 | 7 | #undef __cplusplus /* { dg-error "undefining | shouldn't be undefined" } */ 8 | 9 | -------------------------------------------------------------------------------- /cpp-test/test-t/u_line.c: -------------------------------------------------------------------------------- 1 | /* u_line.c: Undefined behaviors on out-of-range #line number. */ 2 | 3 | /* { dg-do preprocess } */ 4 | /* { dg-options "-std=c99 -pedantic-errors" } */ 5 | 6 | /* C99: Line number argument of #line directive should be in range of 7 | [1..2147483647] */ 8 | 9 | #line 0 /* { dg-error "out of range" } */ 10 | #line 11 /* Restore to correct line number */ 11 | #line 2147483647 /* valid here */ 12 | /* line 2147483647 */ 13 | /* line 2147483648 ? : out of range */ 14 | __LINE__; /* 2147483649 ? or -2147483647 ?, 15 | maybe warned as an out-of-range */ 16 | /* { dg-warning "out of range| got beyond range\n\[\^ \]* warning: Line number \"\[\-0-9\]*\" is out of range" "" { target *-*-* } 0 } */ 17 | 18 | -------------------------------------------------------------------------------- /cpp-test/test-t/u_line_s.c: -------------------------------------------------------------------------------- 1 | /* u_line_s.c: Undefined behavior on out-of-range #line number. */ 2 | 3 | /* { dg-do preprocess } */ 4 | /* { dg-options "-std=c99 -pedantic-errors" } */ 5 | 6 | /* C99: Line number argument of #line directive should be in range of 7 | [1..2147483647] */ 8 | 9 | #line 2147483648 /* { dg-error "out of range" } */ 10 | 11 | /* 12 | * Note: DejaGnu sometimes fails to handle one of the dg-error lines of 13 | * #line 0 and #line 2147483648, when those are tested in a single testcase 14 | * file. 15 | * So, we separated this testcase from u_line.c. 16 | */ 17 | -------------------------------------------------------------------------------- /cpp-test/test-t/unbal1.h: -------------------------------------------------------------------------------- 1 | /* unbal1.h */ 2 | #endif 3 | -------------------------------------------------------------------------------- /cpp-test/test-t/unbal2.h: -------------------------------------------------------------------------------- 1 | /* unbal2.h */ 2 | 3 | #define UNBAL2 1 4 | 5 | #if UNBAL2 /* line 5 */ 6 | #else 7 | -------------------------------------------------------------------------------- /cpp-test/test-t/unbal3.h: -------------------------------------------------------------------------------- 1 | /* unbal3.h */ 2 | int unbal3; -------------------------------------------------------------------------------- /cpp-test/test-t/unbal4.h: -------------------------------------------------------------------------------- 1 | /* unbal4.h */ 2 | int unbal4\ 3 | -------------------------------------------------------------------------------- /cpp-test/test-t/unbal5.h: -------------------------------------------------------------------------------- 1 | /* unbal5.h */ 2 | int unbal5; /* unterminated comment 3 | -------------------------------------------------------------------------------- /cpp-test/test-t/unbal6.h: -------------------------------------------------------------------------------- 1 | /* unbal6.h */ 2 | #define UNBAL6( a, b) ((a) + (b)) 3 | UNBAL6 4 | ( 5 | x 6 | , 7 | -------------------------------------------------------------------------------- /cpp-test/test-t/vers2.h: -------------------------------------------------------------------------------- 1 | /* vers2.h */ 2 | 3 | /* comment */ # /**/ pragma /**/ once /**/ 4 | 5 | #include 6 | #include 7 | 8 | /* 9 | * , might have the line 10 | * #pragma once 11 | * near the beginning. 12 | */ 13 | -------------------------------------------------------------------------------- /cpp-test/test-t/warn_1_1.c: -------------------------------------------------------------------------------- 1 | /* warn_1_1.c */ 2 | 3 | /* 4 | * The following text is legal but suspicious one. Good preprocessor 5 | * will warn at this text. 6 | */ 7 | 8 | /* { dg-do preprocess } */ 9 | /* { dg-options "-ansi -pedantic -Wall" } */ 10 | 11 | /* w.1.1: "/*" in comment. */ /* { dg-warning "(\"/\\*\"|`/\\*') within comment" } */ 12 | /* comment /* nested comment and no closing */ /* { dg-warning "(\"/\\*\"|`/\\*') within comment" } */ 13 | 14 | -------------------------------------------------------------------------------- /cpp-test/test-t/warn_1_2.c: -------------------------------------------------------------------------------- 1 | /* warn_1_2.c */ 2 | 3 | /* 4 | * The following text is legal but suspicious one. Good preprocessor 5 | * will warn at this text. 6 | */ 7 | 8 | /* { dg-do preprocess } */ 9 | /* { dg-options "-ansi -pedantic -Wall" } */ 10 | 11 | /* w.1.2: Rescanning of replacement text involves succeding text. */ 12 | #define sub( x, y) (x - y) 13 | #define head sub( 14 | int a = 1, b = 2, c; 15 | c = head a,b ); /* { dg-warning "involved subsequent text" "macro call involves subsequent text" } */ 16 | 17 | #define OBJECT_LIKE FUNCTION_LIKE 18 | #define FUNCTION_LIKE( x, y) (x + y) 19 | c = OBJECT_LIKE( a, b); /* { dg-warning "involved subsequent text" "macro call involves subsequent text" } */ 20 | 21 | -------------------------------------------------------------------------------- /cpp-test/test-t/warn_2.c: -------------------------------------------------------------------------------- 1 | /* warn_2.c */ 2 | 3 | /* 4 | * The following texts are legal but suspicious ones. Good preprocessor 5 | * will warn at these texts. 6 | */ 7 | 8 | /* { dg-do preprocess } */ 9 | /* { dg-options "-ansi -pedantic -Wall" } */ 10 | 11 | /* w.2.1: Negative number converted to positive in #if expression. */ 12 | #if -1 < 0U /* { dg-warning "changes sign when promoted| converted to positive" } */ 13 | #endif 14 | 15 | /* w.2.2: Out of range of unsigned type (wraps around and never overflow) 16 | in #if expression. */ 17 | #if 0U - 1 /* { dg-warning "out of range" } */ 18 | #endif 19 | 20 | -------------------------------------------------------------------------------- /doc-jp/cpp-test.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/doc-jp/cpp-test.html -------------------------------------------------------------------------------- /doc-jp/mcpp-manual.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/doc-jp/mcpp-manual.html -------------------------------------------------------------------------------- /doc-jp/mcpp-porting.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/doc-jp/mcpp-porting.html -------------------------------------------------------------------------------- /doc-jp/mcpp-summary.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/doc-jp/mcpp-summary.pdf -------------------------------------------------------------------------------- /doc/cpp-test.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/doc/cpp-test.html -------------------------------------------------------------------------------- /doc/mcpp-summary.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/doc/mcpp-summary.pdf -------------------------------------------------------------------------------- /src/main_libmcpp.c: -------------------------------------------------------------------------------- 1 | /* most simple sample source to use libmcpp */ 2 | 3 | #include "mcpp_lib.h" 4 | 5 | int 6 | main (int argc, char *argv[]) 7 | { 8 | return mcpp_lib_main (argc, argv); 9 | } 10 | -------------------------------------------------------------------------------- /src/mcpp_lib.def: -------------------------------------------------------------------------------- 1 | LIBRARY mcpp0 2 | EXPORTS 3 | mcpp_lib_main 4 | mcpp_reset_def_out_func 5 | mcpp_set_out_func 6 | mcpp_use_mem_buffers 7 | mcpp_get_mem_buffer 8 | -------------------------------------------------------------------------------- /src/mcpp_out.h: -------------------------------------------------------------------------------- 1 | /* mcpp_out.h: declarations of OUTDEST data types for MCPP */ 2 | #ifndef _MCPP_OUT_H 3 | #define _MCPP_OUT_H 4 | 5 | /* Choices for output destination */ 6 | typedef enum { 7 | OUT, /* ~= fp_out */ 8 | ERR, /* ~= fp_err */ 9 | DBG, /* ~= fp_debug */ 10 | NUM_OUTDEST 11 | } OUTDEST; 12 | 13 | #endif /* _MCPP_OUT_H */ 14 | -------------------------------------------------------------------------------- /src/preproc.c: -------------------------------------------------------------------------------- 1 | /* preproc.c: to "pre-preprocess" header files. */ 2 | 3 | #pragma MCPP preprocess 4 | 5 | #include "system.H" 6 | #include "internal.H" 7 | 8 | #pragma MCPP put_defines 9 | 10 | -------------------------------------------------------------------------------- /test-c/defs.h: -------------------------------------------------------------------------------- 1 | /* defs.h */ 2 | 3 | #include 4 | 5 | /* assert(): Enable one of these three. */ 6 | /* Note: This source doesn't use #elif directive to test preprocessor which 7 | can't recognize the directive. */ 8 | #if 1 /* For the translator which can process properly. */ 9 | #include 10 | #else 11 | #if 0 /* Not to abort on error. */ 12 | #define assert( exp) (exp) ? (void)0 : (void) fprintf( stderr, \ 13 | "Assertion failed: %s, from line %d of file %s\n", \ 14 | # exp, __LINE__, __FILE__) 15 | #endif 16 | #endif 17 | 18 | extern int strcmp( const char *, const char *); 19 | extern size_t strlen( const char *); 20 | extern void exit( int); 21 | 22 | -------------------------------------------------------------------------------- /test-c/e_12_8.c: -------------------------------------------------------------------------------- 1 | /* e_12_8.c: Out of range of integer pp-token in #if expression. */ 2 | 3 | /* 12.8: Preprocessing number perhaps out of range of unsigned long. */ 4 | #if 123456789012345678901 5 | #endif 6 | 7 | main( void) 8 | { 9 | return 0; 10 | } 11 | 12 | -------------------------------------------------------------------------------- /test-c/e_14_10.c: -------------------------------------------------------------------------------- 1 | /* e_14_10.c: Overflow of constant expression in #if directive. */ 2 | 3 | /* 14.10: */ 4 | #include 5 | 6 | #if LONG_MAX - LONG_MIN 7 | #endif 8 | #if LONG_MAX + 1 9 | #endif 10 | #if LONG_MIN - 1 11 | #endif 12 | #if LONG_MAX * 2 13 | #endif 14 | 15 | int main( void) 16 | { 17 | return 0; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /test-c/e_14_7.c: -------------------------------------------------------------------------------- 1 | /* e_14_7.c: There is no keyword in #if expression. */ 2 | 3 | /* 14.7: sizeof operator is disallowed. */ 4 | /* Evaluated as: 0 (0) 5 | Constant expression syntax error. */ 6 | #if sizeof (int) 7 | #endif 8 | 9 | /* 14.8: type cast is disallowed. */ 10 | /* Evaluated as: (0)0x8000 11 | Also a constant expression error. */ 12 | #if (int)0x8000 < 0 13 | #endif 14 | 15 | main( void) 16 | { 17 | return 0; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /test-c/e_14_9.c: -------------------------------------------------------------------------------- 1 | /* e_14_9.c: Out of range in #if expression (division by 0). */ 2 | 3 | /* 14.9: Divided by 0. */ 4 | #if 1 / 0 5 | #endif 6 | 7 | int main( void) 8 | { 9 | return 0; 10 | } 11 | 12 | -------------------------------------------------------------------------------- /test-c/e_15_3.c: -------------------------------------------------------------------------------- 1 | /* e_15_3.c: #ifdef, #ifndef syntax errors. */ 2 | 3 | /* 15.3: Not an identifier. */ 4 | #ifdef "string" 5 | #endif 6 | #ifdef 123 7 | #endif 8 | 9 | /* 15.4: Excessive token sequence. */ 10 | #ifdef MACRO Junk 11 | #endif 12 | 13 | /* 15.5: No argument. */ 14 | #ifndef 15 | #endif 16 | 17 | main( void) 18 | { 19 | return 0; 20 | } 21 | 22 | -------------------------------------------------------------------------------- /test-c/e_16.c: -------------------------------------------------------------------------------- 1 | /* e_16.c: Trailing junk of #else, #endif. */ 2 | 3 | /* 16.1: Trailing junk of #else. */ 4 | #define MACRO_0 0 5 | #if MACRO_0 6 | #else MACRO_0 7 | 8 | /* 16.2: Trailing junk of #endif. */ 9 | #endif MACRO_0 10 | 11 | main( void) 12 | { 13 | return 0; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /test-c/e_17.c: -------------------------------------------------------------------------------- 1 | /* e_17.c: Ill-formed group in a source file. */ 2 | 3 | #define MACRO_1 1 4 | 5 | /* 17.1: Error of #endif without #if. */ 6 | #endif 7 | 8 | /* 17.2: Error of #else without #if. */ 9 | #else 10 | 11 | /* 17.3: Error of #else after #else. */ 12 | #if MACRO_1 13 | #else 14 | #else 15 | #endif 16 | 17 | /* 17.4: Error of #elif after #else. */ 18 | #if MACRO_1 == 1 19 | #else 20 | #elif MACRO_1 == 0 21 | #endif 22 | 23 | /* 17.5: Error of #endif without #if in an included file. */ 24 | #if 1 25 | #include "unbal1.h" 26 | 27 | /* 17.6: Error of unterminated #if section in an included file. */ 28 | #include "unbal2.h" 29 | #endif 30 | 31 | /* 17.7: Error of unterminated #if section. */ 32 | #if MACRO_1 == 0 33 | #else 34 | 35 | -------------------------------------------------------------------------------- /test-c/e_23_3.c: -------------------------------------------------------------------------------- 1 | /* e_23_3.c: ## operator shall not occur at the beginning or at the end of 2 | replacement list for either form of macro definition. */ 3 | 4 | /* 23.3: In object-like macro. */ 5 | #define con ## name 6 | #define cat 12 ## 7 | 8 | /* 23.4: In function-like macro. */ 9 | #define CON( a, b) ## a ## b 10 | #define CAT( b, c) b ## c ## 11 | 12 | main( void) 13 | { 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /test-c/e_24_6.c: -------------------------------------------------------------------------------- 1 | /* e_24_6.c: Operand of # operator in function-like macro definition should 2 | be a parameter. */ 3 | 4 | /* 24.6: */ 5 | #define FUNC( a) # b 6 | 7 | main( void) 8 | { 9 | return 0; 10 | } 11 | 12 | -------------------------------------------------------------------------------- /test-c/e_25_6.c: -------------------------------------------------------------------------------- 1 | /* e_25_6.c: Macro arguments are pre-expanded separately. */ 2 | 3 | /* 25.6: */ 4 | #define sub( x, y) (x - y) 5 | #define head sub( 6 | #define body(x,y) x,y 7 | #define tail ) 8 | #define head_body_tail( a, b, c) a b c 9 | /* "head" is once expanded to "sub(", then rescanning of "sub(" causes an 10 | uncompleted macro call. Expansion of an argument should complete 11 | within the argument. */ 12 | head_body_tail( head, body(a,b), tail); 13 | 14 | main( void) 15 | { 16 | return 0; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /test-c/e_27_7.c: -------------------------------------------------------------------------------- 1 | /* e_27_7.c: Error of rescanning. */ 2 | 3 | #define sub( x, y) (x - y) 4 | 5 | /* 27.7: */ 6 | #define TWO_TOKENS a,b 7 | #define SUB( x, y) sub( x, y) 8 | /* Too many arguments error while rescanning after once replaced to: 9 | sub( a,b, 1); */ 10 | SUB( TWO_TOKENS, 1); 11 | 12 | main( void) 13 | { 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /test-c/e_29_3.c: -------------------------------------------------------------------------------- 1 | /* e_29_3.c: #undef errors. */ 2 | 3 | /* 29.3: Not an identifier. */ 4 | #undef "string" 5 | #undef 123 6 | 7 | /* 29.4: Excessive token sequence. */ 8 | #undef MACRO_0 Junk 9 | 10 | /* 29.5: No argument. */ 11 | #undef 12 | 13 | main( void) 14 | { 15 | return 0; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /test-c/e_31.c: -------------------------------------------------------------------------------- 1 | /* e_31.c: Illegal macro calls. */ 2 | 3 | #define sub( x, y) (x - y) 4 | 5 | /* 31.1: Too many arguments error. */ 6 | sub( x, y, z); 7 | 8 | /* 31.2: Too few arguments error. */ 9 | sub( x); 10 | 11 | main( void) 12 | { 13 | return 0; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /test-c/e_31_3.c: -------------------------------------------------------------------------------- 1 | /* e_31_3.c: Macro call in control line should complete in the line. */ 2 | 3 | #define glue( a, b) a ## b 4 | #define str( s) # s 5 | #define xstr( s) str( s) 6 | 7 | /* 31.3: Unterminated macro call. */ 8 | #include xstr( glue( header, 9 | .h)) 10 | 11 | main( void) 12 | { 13 | return 0; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /test-c/e_32_5.c: -------------------------------------------------------------------------------- 1 | /* e_32_5.c: Range error of character constant. */ 2 | 3 | /* 32.5: Value of a numerical escape sequence in character constant should 4 | be in the range of char. */ 5 | #if '\x123' == 0x123 /* Out of range. */ 6 | #endif 7 | 8 | main( void) 9 | { 10 | return 0; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /test-c/e_33_2.c: -------------------------------------------------------------------------------- 1 | /* e_33_2.c: Out of range of numerical escape sequence in wide-char. */ 2 | 3 | /* 33.2: Value of a numerical escape sequence in wide-character constant 4 | should be in the range of wchar_t. */ 5 | #if L'\xabcdef012' == 0xbcdef012 /* Perhaps out of range. */ 6 | #endif 7 | 8 | main( void) 9 | { 10 | return 0; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /test-c/e_35_2.c: -------------------------------------------------------------------------------- 1 | /* e_35_2.c: Out of range of character constant. */ 2 | 3 | /* In ASCII character set. */ 4 | /* 35.2: */ 5 | #if 'abcdefghi' == '\x61\x62\x63\x64\x65\x66\x67\x68\x69' 6 | /* Perhaps out of range. */ 7 | #endif 8 | 9 | main( void) 10 | { 11 | return 0; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /test-c/e_4_3.c: -------------------------------------------------------------------------------- 1 | /* e_4_3.c: Illegal pp-token. */ 2 | 3 | /* 4.3: Empty character constant is an error. */ 4 | #if '' == 0 /* This line is invalid, maybe skipped. */ 5 | #endif /* This line maybe the second error. */ 6 | 7 | main( void) 8 | { 9 | return 0; 10 | } 11 | 12 | -------------------------------------------------------------------------------- /test-c/e_7_4.c: -------------------------------------------------------------------------------- 1 | /* e_7_4.c: #line error. */ 2 | 3 | /* 7.4: string literal in #line directive shall be a character string 4 | literal. */ 5 | 6 | #line 123 L"wide" 7 | 8 | main( void) 9 | { 10 | return 0; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /test-c/header.h: -------------------------------------------------------------------------------- 1 | /* header.h */ 2 | 3 | #define MACRO_abc abc 4 | -------------------------------------------------------------------------------- /test-c/i_32_3.c: -------------------------------------------------------------------------------- 1 | /* i_32_3.c: Character constant in #if expression. */ 2 | 3 | #include "defs.h" 4 | 5 | main( void) 6 | { 7 | fputs( "started\n", stderr); 8 | 9 | /* 32.3: */ 10 | #if 'a' != 0x61 11 | fputs( "Not ASCII character set, or bad evaluation of character constant." 12 | , stderr); 13 | exit( 1); 14 | #endif 15 | 16 | /* 32.4: '\a' and '\v' */ 17 | #if '\a' != 7 || '\v' != 11 18 | fputs( "Not ASCII character set, or bad evaluation of escape sequences." 19 | , stderr); 20 | exit( 1); 21 | #endif 22 | 23 | fputs( "success\n", stderr); 24 | return 0; 25 | } 26 | 27 | -------------------------------------------------------------------------------- /test-c/i_35.c: -------------------------------------------------------------------------------- 1 | /* i_35.c: Multi-character character constant. */ 2 | 3 | #include "defs.h" 4 | 5 | main( void) 6 | { 7 | fputs( "started\n", stderr); 8 | 9 | /* In ASCII character set. */ 10 | /* 35.1: */ 11 | #if ('ab' != '\x61\x62') || ('\aa' != '\7\x61') 12 | fputs( "Bad handling of multi-character character constant.\n", stderr); 13 | exit( 1); 14 | #endif 15 | 16 | fputs( "success\n", stderr); 17 | return 0; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /test-c/i_35_3.c: -------------------------------------------------------------------------------- 1 | /* i_35_3.c: Multi-character wide character constant. */ 2 | 3 | #include "defs.h" 4 | 5 | main( void) 6 | { 7 | fputs( "started\n", stderr); 8 | 9 | /* In ASCII character set. */ 10 | /* 35.3: */ 11 | #if (L'ab' != L'\x61\x62') || (L'ab' == 'ab') 12 | fputs( "Bad handling of multi-character wide character constant.\n", 13 | stderr); 14 | exit( 1); 15 | #endif 16 | 17 | fputs( "success\n", stderr); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /test-c/ifdef15.h: -------------------------------------------------------------------------------- 1 | /* ifdef15.h */ 2 | 3 | #ifdef X01 4 | #else 5 | #ifdef X02 6 | #else 7 | #ifdef X03 8 | #else 9 | #ifdef X04 10 | #else 11 | #ifdef X05 12 | #else 13 | #ifdef X06 14 | #else 15 | #ifdef X07 16 | #else 17 | #ifdef X08 18 | #else 19 | #ifdef X09 20 | #else 21 | #ifdef X0A 22 | #else 23 | #ifdef X0B 24 | #else 25 | #ifdef X0C 26 | #else 27 | #ifdef X0D 28 | #else 29 | #ifdef X0E 30 | #else 31 | #ifdef X0F 32 | nest = 0x0f; 33 | #endif /* X0F */ 34 | #endif /* X0E */ 35 | #endif /* X0D */ 36 | #endif /* X0C */ 37 | #endif /* X0B */ 38 | #endif /* X0A */ 39 | #endif /* X09 */ 40 | #endif /* X08 */ 41 | #endif /* X07 */ 42 | #endif /* X06 */ 43 | #endif /* X05 */ 44 | #endif /* X04 */ 45 | #endif /* X03 */ 46 | #endif /* X02 */ 47 | #endif /* X01 */ 48 | 49 | -------------------------------------------------------------------------------- /test-c/line.h: -------------------------------------------------------------------------------- 1 | /* line.h */ 2 | 3 | { 4 | char * file = __FILE__; 5 | file += strlen( file) - 6; 6 | assert( __LINE__ == 6 && strcmp( file, "line.h") == 0); 7 | } 8 | -------------------------------------------------------------------------------- /test-c/m_33_big5.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-c/m_33_big5.c -------------------------------------------------------------------------------- /test-c/m_33_eucjp.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-c/m_33_eucjp.c -------------------------------------------------------------------------------- /test-c/m_33_gb.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-c/m_33_gb.c -------------------------------------------------------------------------------- /test-c/m_33_ksc.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-c/m_33_ksc.c -------------------------------------------------------------------------------- /test-c/m_33_sjis.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-c/m_33_sjis.c -------------------------------------------------------------------------------- /test-c/m_34_big5.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-c/m_34_big5.c -------------------------------------------------------------------------------- /test-c/m_34_eucjp.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-c/m_34_eucjp.c -------------------------------------------------------------------------------- /test-c/m_34_gb.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-c/m_34_gb.c -------------------------------------------------------------------------------- /test-c/m_34_jis.c: -------------------------------------------------------------------------------- 1 | /* m_34_jis.c: Multi-byte character constant encoded in ISO-2022-JP. */ 2 | 3 | #include "defs.h" 4 | 5 | main( void) 6 | { 7 | char * ptr; 8 | 9 | fputs( "started\n", stderr); 10 | 11 | /* 34.1: */ 12 | 13 | #pragma __setlocale( "jis") /* For MCPP */ 14 | #pragma setlocale( "jis") /* For MCPP on VC */ 15 | 16 | #if '$B;z(B' == '\x3b\x7a' 17 | /* This line doesn't work unless "shift states" are processed. */ 18 | ptr = "Multi-byte character is encoded in ISO-2022-JP."; 19 | #else 20 | ptr = "I cannot understand ISO-2022-JP."; 21 | #endif 22 | 23 | assert( strcmp( ptr, "I cannot understand ISO-2022-JP.") != 0); 24 | fputs( "success\n", stderr); 25 | return 0; 26 | } 27 | 28 | -------------------------------------------------------------------------------- /test-c/m_34_ksc.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-c/m_34_ksc.c -------------------------------------------------------------------------------- /test-c/m_34_sjis.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-c/m_34_sjis.c -------------------------------------------------------------------------------- /test-c/m_34_utf8.c: -------------------------------------------------------------------------------- 1 | /* m_34_utf8.c: Multi-byte character constant encoded in UTF-8. */ 2 | 3 | #include "defs.h" 4 | 5 | main( void) 6 | { 7 | char * ptr; 8 | 9 | fputs( "started\n", stderr); 10 | 11 | /* 34.1: */ 12 | 13 | #pragma __setlocale( "utf8") /* For MCPP */ 14 | #pragma setlocale( "utf8") /* For MCPP on VC */ 15 | 16 | #if '字' == '\xe5\xad\x97' 17 | ptr = "Multi-byte character is encoded in UTF-8."; 18 | #else 19 | ptr = "I cannot understand UTF-8."; 20 | #endif 21 | 22 | assert( strcmp( ptr, "I cannot understand UTF-8.") != 0); 23 | fputs( "success\n", stderr); 24 | return 0; 25 | } 26 | 27 | -------------------------------------------------------------------------------- /test-c/m_36_big5.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-c/m_36_big5.c -------------------------------------------------------------------------------- /test-c/m_36_sjis.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-c/m_36_sjis.c -------------------------------------------------------------------------------- /test-c/n_13_7.c: -------------------------------------------------------------------------------- 1 | /* n_13_7.c: Short-circuit evaluation of #if expression. */ 2 | 3 | #include "defs.h" 4 | #define MACRO_0 0 5 | 6 | main( void) 7 | { 8 | fputs( "started\n", stderr); 9 | 10 | /* 13.7: 10/0 or 10/MACRO_0 are never evaluated, "divide by zero" error 11 | cannot occur. */ 12 | #if 0 && 10 / 0 13 | exit( 1); 14 | #endif 15 | #if not_defined && 10 / not_defined 16 | exit( 1); 17 | #endif 18 | #if MACRO_0 && 10 / MACRO_0 > 1 19 | exit( 1); 20 | #endif 21 | #if MACRO_0 ? 10 / MACRO_0 : 0 22 | exit( 1); 23 | #endif 24 | #if MACRO_0 == 0 || 10 / MACRO_0 > 1 /* Valid block */ 25 | fputs( "success\n", stderr); 26 | return 0; 27 | #else 28 | exit( 1); 29 | #endif 30 | } 31 | 32 | -------------------------------------------------------------------------------- /test-c/n_15.c: -------------------------------------------------------------------------------- 1 | /* n_15.c: #ifdef, #ifndef directives. */ 2 | 3 | #include "defs.h" 4 | 5 | #define MACRO_0 0 6 | #define MACRO_1 1 7 | 8 | main( void) 9 | { 10 | fputs( "started\n", stderr); 11 | 12 | /* 15.1: #ifdef directive. */ 13 | #ifdef MACRO_1 /* Valid block */ 14 | assert( MACRO_1); 15 | #else 16 | assert( MACRO_0); 17 | #endif 18 | 19 | /* 15.2: #ifndef directive. */ 20 | #ifndef MACRO_1 21 | assert( MACRO_0); 22 | #else /* Valid block */ 23 | assert( MACRO_1); 24 | #endif 25 | 26 | fputs( "success\n", stderr); 27 | return 0; 28 | } 29 | 30 | -------------------------------------------------------------------------------- /test-c/n_19.c: -------------------------------------------------------------------------------- 1 | /* n_19.c: Valid re-definitions of macros. */ 2 | 3 | #include "defs.h" 4 | 5 | main( void) 6 | { 7 | int c = 1; 8 | 9 | fputs( "started\n", stderr); 10 | 11 | /* Excerpts from ISO C 6.8.3 "Examples". */ 12 | #define OBJ_LIKE (1-1) 13 | #define FTN_LIKE(a) ( a ) 14 | 15 | /* 19.1: */ 16 | #define OBJ_LIKE /* white space */ (1-1) /* other */ 17 | 18 | /* 19.2: */ 19 | #define FTN_LIKE( a )( /* note the white space */ \ 20 | a /* other stuff on this line 21 | */ ) 22 | assert( FTN_LIKE( c) == 1); 23 | 24 | fputs( "success\n", stderr); 25 | return 0; 26 | } 27 | 28 | -------------------------------------------------------------------------------- /test-c/n_20.c: -------------------------------------------------------------------------------- 1 | /* n_20.c: Macro lexically identical to keyword. */ 2 | 3 | #include "defs.h" 4 | 5 | main( void) 6 | { 7 | 8 | /* 20.1: */ 9 | #define float double 10 | float fl; 11 | 12 | fputs( "started\n", stderr); 13 | 14 | assert( sizeof fl == sizeof (double)); 15 | 16 | fputs( "success\n", stderr); 17 | return 0; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /test-c/n_21.c: -------------------------------------------------------------------------------- 1 | /* n_21.c: Tokenization (No preprocessing tokens are merged implicitly). */ 2 | 3 | #include "defs.h" 4 | 5 | main( void) 6 | { 7 | int a = 1, x = 2, y = -3; 8 | 9 | fputs( "started\n", stderr); 10 | 11 | /* 21.1: */ 12 | #define MINUS - 13 | assert( -MINUS-a == -1); 14 | 15 | /* 21.2: */ 16 | #define sub( a, b) a-b /* '(a)-(b)' is better */ 17 | #define Y -y /* '(-y)' is better */ 18 | /* x- -y */ 19 | assert( sub( x, Y) == -1); 20 | 21 | fputs( "success\n", stderr); 22 | return 0; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /test-c/n_22.c: -------------------------------------------------------------------------------- 1 | /* n_22.c: Tokenization of preprocessing number. */ 2 | 3 | #include "defs.h" 4 | 5 | #define str( a) # a 6 | #define xstr( a) str( a) 7 | #define EXP 1 8 | 9 | main( void) 10 | { 11 | fputs( "started\n", stderr); 12 | 13 | /* 22.1: 12E+EXP is a preprocessing number, EXP is not expanded. */ 14 | assert( strcmp( xstr( 12E+EXP), "12E+EXP") == 0); 15 | 16 | /* 22.2: .2e-EXP is also a preprocessing number. */ 17 | assert( strcmp( xstr( .2e-EXP), ".2e-EXP") == 0); 18 | 19 | /* 22.3: + or - is allowed only following E or e, 12+EXP is not a 20 | preprocessing number. */ 21 | assert( strcmp( xstr( 12+EXP), "12+1") == 0); 22 | 23 | fputs( "success\n", stderr); 24 | return 0; 25 | } 26 | 27 | -------------------------------------------------------------------------------- /test-c/n_23.c: -------------------------------------------------------------------------------- 1 | /* n_23.c: ## operator in macro definition. */ 2 | 3 | #include "defs.h" 4 | 5 | #define glue( a, b) a ## b 6 | #define xglue( a, b) glue( a, b) 7 | #define MACRO_0 0 8 | #define MACRO_1 1 9 | 10 | main( void) 11 | { 12 | int xy = 1; 13 | 14 | fputs( "started\n", stderr); 15 | 16 | /* 23.1: */ 17 | assert( glue( x, y) == 1); 18 | 19 | /* 23.2: Generate a preprocessing number. */ 20 | #define EXP 2 21 | assert( xglue( .12e+, EXP) == 12.0); 22 | 23 | fputs( "success\n", stderr); 24 | return 0; 25 | } 26 | 27 | -------------------------------------------------------------------------------- /test-c/n_29.c: -------------------------------------------------------------------------------- 1 | /* n_29.c: #undef directive. */ 2 | 3 | #include "defs.h" 4 | 5 | main( void) 6 | { 7 | int DEFINED = 1; 8 | 9 | fputs( "started\n", stderr); 10 | 11 | /* 29.1: Undefined macro is not a macro. */ 12 | #define DEFINED 13 | #undef DEFINED 14 | assert( DEFINED == 1); 15 | 16 | /* 29.2: Undefining undefined name is not an error. */ 17 | #undef UNDEFINED 18 | 19 | fputs( "success\n", stderr); 20 | return 0; 21 | } 22 | 23 | -------------------------------------------------------------------------------- /test-c/n_3.c: -------------------------------------------------------------------------------- 1 | /* n_3.c: Handling of comment. */ 2 | 3 | #include "defs.h" 4 | 5 | #define str( a) # a 6 | 7 | main( void) 8 | { 9 | int abcd = 4; 10 | 11 | fputs( "started\n", stderr); 12 | 13 | /* 3.1: A comment is converted to one space. */ 14 | assert( strcmp( str( abc/* comment */de), "abc de") == 0); 15 | 16 | /* 3.2: // is not a comment of C. */ 17 | /* assert( strcmp( str( //), "//") == 0); */ 18 | 19 | /* 3.3: Comment is parsed prior to the parsing of preprocessing directive. */ 20 | #if 0 21 | "nonsence"; /* 22 | #else 23 | still in 24 | comment */ 25 | #else 26 | #define MACRO_abcd /* 27 | in comment 28 | */ abcd 29 | #endif 30 | assert( MACRO_abcd == 4); 31 | 32 | fputs( "success\n", stderr); 33 | return 0; 34 | } 35 | 36 | -------------------------------------------------------------------------------- /test-c/n_32.c: -------------------------------------------------------------------------------- 1 | /* n_32.c: Escape sequence in character constant in #if expression. */ 2 | 3 | #include "defs.h" 4 | 5 | main( void) 6 | { 7 | fputs( "started\n", stderr); 8 | 9 | /* 32.1: Character octal escape sequence. */ 10 | #if '\123' != 83 11 | fputs( "Bad evaluation of octal escape sequence.\n", stderr); 12 | exit( 1); 13 | #endif 14 | 15 | /* 32.2: Character hexadecimal escape sequence. */ 16 | #if '\x1b' != '\033' 17 | fputs( "Bad evaluation of hexadecimal escape sequence.\n", stderr); 18 | exit( 1); 19 | #endif 20 | 21 | fputs( "success\n", stderr); 22 | return 0; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /test-c/n_3_4.c: -------------------------------------------------------------------------------- 1 | /* n_3_4.c: Handling of comment and . */ 2 | 3 | /* 3.4: Comment and in #error line. */ 4 | #error Message of first physical line. \ 5 | Message of second physical and first logical line. /* 6 | this comment splices the lines 7 | */ Message of forth physical and third logical line. 8 | 9 | -------------------------------------------------------------------------------- /test-c/n_4.c: -------------------------------------------------------------------------------- 1 | /* n_4.c: Special tokens. */ 2 | 3 | #include "defs.h" 4 | 5 | main( void) 6 | { 7 | /* 4.1: Digraph spellings in directive line. */ 8 | %: define stringize( a) %: a 9 | 10 | fputs( "started\n", stderr); 11 | 12 | assert( strcmp( stringize( abc), "abc") == 0); 13 | 14 | /* 4.2: Digraph spellings are retained in stringization. */ 15 | assert( strcmp( stringize( <:), "<" ":") == 0); 16 | 17 | fputs( "success\n", stderr); 18 | return 0; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /test-c/n_5.c: -------------------------------------------------------------------------------- 1 | /* n_5.c: Spaces or tabs are allowed at any place in pp-directive line, 2 | including between the top of a pp-directive line and '#', and between 3 | the '#' and the directive. */ 4 | 5 | #include "defs.h" 6 | 7 | main( void) 8 | { 9 | int abcde = 5; 10 | /* |**|[TAB]# |**|[TAB]define |**| MACRO_abcde[TAB]|**| abcde |**| */ 11 | /**/ # /**/ define /**/ MACRO_abcde /**/ abcde /**/ 12 | 13 | fputs( "started\n", stderr); 14 | 15 | assert( MACRO_abcde == 5); 16 | 17 | fputs( "success\n", stderr); 18 | return 0; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /test-c/n_6.c: -------------------------------------------------------------------------------- 1 | /* n_6.c: #include directive. */ 2 | 3 | #include "defs.h" 4 | /* 6.1: Header-name quoted by " and " as well as by < and > can include 5 | standard headers. */ 6 | /* Note: Standard headers can be included any times. */ 7 | #include "ctype.h" 8 | #include 9 | 10 | main( void) 11 | { 12 | int abc = 3; 13 | 14 | fputs( "started\n", stderr); 15 | 16 | assert( isalpha( 'a')); 17 | 18 | /* 6.2: Macro is allowed in #include line. */ 19 | #define HEADER "header.h" 20 | #include HEADER 21 | assert( MACRO_abc == 3); 22 | 23 | /* 6.3: With macro nonsence but legal. */ 24 | #undef MACRO_abc 25 | #define ZERO_TOKEN 26 | #include ZERO_TOKEN HEADER ZERO_TOKEN 27 | assert( MACRO_abc == 3); 28 | 29 | fputs( "success\n", stderr); 30 | return 0; 31 | } 32 | 33 | -------------------------------------------------------------------------------- /test-c/n_7.c: -------------------------------------------------------------------------------- 1 | /* n_7.c: #line directive. */ 2 | 3 | #include "defs.h" 4 | 5 | main( void) 6 | { 7 | fputs( "started\n", stderr); 8 | 9 | /* 7.1: Line number and filename. */ 10 | #line 1234 "cpp" 11 | assert( __LINE__ == 1234); 12 | assert( strcmp( __FILE__, "cpp") == 0); 13 | 14 | /* 7.2: Filename argument is optional. */ 15 | #line 2345 16 | assert( __LINE__ == 2345); 17 | assert( strcmp( __FILE__, "cpp") == 0); 18 | 19 | /* 7.3: Argument with macro. */ 20 | #define LINE_AND_FILENAME 1234 "n_7.c" 21 | #line LINE_AND_FILENAME 22 | assert( __LINE__ == 1234); 23 | assert( strcmp( __FILE__, "n_7.c") == 0); 24 | 25 | fputs( "success\n", stderr); 26 | return 0; 27 | } 28 | 29 | -------------------------------------------------------------------------------- /test-c/n_8.c: -------------------------------------------------------------------------------- 1 | /* n_8.c: #error directive. */ 2 | 3 | /* 8.1: Argument of #error directive is not a subject of macro expansion. 4 | Output to stderr as an example: 5 | Preprocessing error directive: MACRO is not a positive number. 6 | from line 10 of file "n_8.c" 7 | */ 8 | #define MACRO 0 9 | #if MACRO <= 0 10 | #error MACRO is not a positive number. 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /test-c/n_8_2.c: -------------------------------------------------------------------------------- 1 | /* n_8_2.c: Argument of #error is optional. */ 2 | 3 | /* 8.2: #error should be executed. */ 4 | #error 5 | 6 | -------------------------------------------------------------------------------- /test-c/n_9.c: -------------------------------------------------------------------------------- 1 | /* n_9.c: #pragma directive. */ 2 | 3 | #include "stdio.h" 4 | 5 | /* 9.1: Any #pragma directive should be processed or ignored, should not 6 | be diagnosed as an error. */ 7 | #pragma once 8 | #pragma who knows ? 9 | 10 | main( void) 11 | { 12 | fputs( "started\n", stderr); 13 | fputs( "success\n", stderr); 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /test-c/n_i_.lst: -------------------------------------------------------------------------------- 1 | n_1 2 | n_2 3 | n_3 4 | n_4 5 | n_5 6 | n_6 7 | n_7 8 | n_9 9 | n_10 10 | n_11 11 | n_12 12 | n_13 13 | n_13_5 14 | n_13_7 15 | n_13_8 16 | n_13_13 17 | n_15 18 | n_18 19 | n_19 20 | n_20 21 | n_21 22 | n_22 23 | n_23 24 | n_24 25 | n_25 26 | n_26 27 | n_27 28 | n_28 29 | n_29 30 | n_30 31 | n_32 32 | n_37 33 | i_32_3 34 | i_35 35 | i_35_3 36 | -------------------------------------------------------------------------------- /test-c/nest1.h: -------------------------------------------------------------------------------- 1 | /* nest1.h */ 2 | 3 | nest = 1; 4 | 5 | #include "nest2.h" 6 | -------------------------------------------------------------------------------- /test-c/nest10.h: -------------------------------------------------------------------------------- 1 | /* nest10.h */ 2 | #include "nest11.h" 3 | -------------------------------------------------------------------------------- /test-c/nest11.h: -------------------------------------------------------------------------------- 1 | /* nest11.h */ 2 | #include "nest12.h" 3 | -------------------------------------------------------------------------------- /test-c/nest12.h: -------------------------------------------------------------------------------- 1 | /* nest12.h */ 2 | #include "nest13.h" 3 | -------------------------------------------------------------------------------- /test-c/nest13.h: -------------------------------------------------------------------------------- 1 | /* nest13.h */ 2 | #include "nest14.h" 3 | -------------------------------------------------------------------------------- /test-c/nest14.h: -------------------------------------------------------------------------------- 1 | /* nest14.h */ 2 | #include "nest15.h" 3 | -------------------------------------------------------------------------------- /test-c/nest15.h: -------------------------------------------------------------------------------- 1 | /* nest15.h */ 2 | #ifdef X0F 3 | nest = 0x0f; 4 | #endif 5 | -------------------------------------------------------------------------------- /test-c/nest2.h: -------------------------------------------------------------------------------- 1 | /* nest2.h */ 2 | 3 | nest = 2; 4 | 5 | #include "nest3.h" 6 | -------------------------------------------------------------------------------- /test-c/nest3.h: -------------------------------------------------------------------------------- 1 | /* nest3.h */ 2 | 3 | nest = 3; 4 | 5 | #include "nest4.h" 6 | -------------------------------------------------------------------------------- /test-c/nest4.h: -------------------------------------------------------------------------------- 1 | /* nest4.h */ 2 | 3 | nest = 4; 4 | 5 | #include "nest5.h" 6 | -------------------------------------------------------------------------------- /test-c/nest5.h: -------------------------------------------------------------------------------- 1 | /* nest5.h */ 2 | 3 | nest = 5; 4 | 5 | #include "nest6.h" 6 | -------------------------------------------------------------------------------- /test-c/nest6.h: -------------------------------------------------------------------------------- 1 | /* nest6.h */ 2 | 3 | nest = 6; 4 | 5 | #include "nest7.h" 6 | -------------------------------------------------------------------------------- /test-c/nest7.h: -------------------------------------------------------------------------------- 1 | /* nest7.h */ 2 | 3 | nest = 7; 4 | 5 | #include "nest8.h" 6 | -------------------------------------------------------------------------------- /test-c/nest8.h: -------------------------------------------------------------------------------- 1 | /* nest8.h */ 2 | 3 | #ifndef X0F 4 | nest = 8; 5 | #else 6 | #include "nest9.h" 7 | #endif 8 | 9 | -------------------------------------------------------------------------------- /test-c/nest9.h: -------------------------------------------------------------------------------- 1 | /* nest9.h */ 2 | #include "nest10.h" 3 | -------------------------------------------------------------------------------- /test-c/u_1_1.c: -------------------------------------------------------------------------------- 1 | /* u_1_1.c: Undefined behaviors on unterminated line, comment or macro. */ 2 | 3 | main( void) 4 | { 5 | 6 | /* u.1.1: End of a source file without . */ 7 | #include "unbal3.h" 8 | int e_1; 9 | 10 | /* u.1.2: End of a source file with . */ 11 | #include "unbal4.h" 12 | ; 13 | 14 | /* u.1.3: End of a source file with an unterminated comment. */ 15 | #include "unbal5.h" 16 | */ 17 | 18 | /* u.1.4: End of a source file with an uncompleted macro call. */ 19 | #include "unbal6.h" 20 | y); 21 | 22 | return 0; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /test-c/u_1_11.c: -------------------------------------------------------------------------------- 1 | /* u_1_11.c: Undefined behaviors on undefined #include syntax or header- 2 | name. */ 3 | 4 | /* u.1.11: Header-name containing ', ", \ or "/*". */ 5 | /* Probably illegal filename and fails to open. */ 6 | #include "../*line.h" 7 | 8 | main( void) 9 | { 10 | /* \ is a legal path-delimiter in MS-DOS or some other OS's. */ 11 | #include "..\test-t\line.h" 12 | 13 | return 0; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /test-c/u_1_12.c: -------------------------------------------------------------------------------- 1 | /* u_1_12.c: Undefined behaviors on undefined #include syntax or header- 2 | name. */ 3 | 4 | /* u.1.12: Argument of #include other than header-name. */ 5 | #include filename 6 | 7 | main( void) 8 | { 9 | return 0; 10 | } 11 | 12 | -------------------------------------------------------------------------------- /test-c/u_1_13.c: -------------------------------------------------------------------------------- 1 | /* u_1_13.c: Undefined behaviors on undefined #include syntax or header- 2 | name. */ 3 | 4 | /* u.1.13: Excessive argument in #include directive. */ 5 | #include Junk 6 | 7 | main( void) 8 | { 9 | return 0; 10 | } 11 | 12 | -------------------------------------------------------------------------------- /test-c/u_1_14.c: -------------------------------------------------------------------------------- 1 | /* u_1_14.c: Undefined behaviors on undefined #line syntax. */ 2 | 3 | main( void) 4 | { 5 | 6 | /* u.1.14: #line directive without an argument of line number. */ 7 | #line "filename" 8 | 9 | /* u.1.15: #line directive with the second argument of other than string 10 | literal. */ 11 | #line 1234 filename 12 | 13 | /* u.1.16: Excessive argument in #line directive. */ 14 | #line 2345 "filename" Junk 15 | 16 | return 0; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /test-c/u_1_17.c: -------------------------------------------------------------------------------- 1 | /* u_1_17.c: Undefined behaviors on out-of-range #line number. */ 2 | 3 | #include 4 | 5 | main( void) 6 | { 7 | 8 | /* u.1.17: Line number argument of #line directive should be in range of 9 | [1,32767]. */ 10 | #line 32767 /* valid here */ 11 | /* line 32767 */ 12 | /* line 32768 ? : out of range */ 13 | printf( "%d\n", __LINE__); 14 | /* 32769 ? or -32767 ?, maybe warned as an out-of-range */ 15 | #line 0 16 | #line 32768 17 | 18 | /* u.1.18: Line number argument of #line directive should be written in 19 | decimal digits. */ 20 | #line 0x1000 21 | 22 | /* 23, u_1_17.c or other undefined results. */ 23 | printf( "%d, %s\n", __LINE__, __FILE__); 24 | 25 | return 0; 26 | } 27 | 28 | -------------------------------------------------------------------------------- /test-c/u_1_23.c: -------------------------------------------------------------------------------- 1 | /* u_1_23.c: Undefined behaviors on generating invalid pp-token by # 2 | operator. */ 3 | 4 | #include 5 | #define str( a) # a 6 | 7 | main( void) 8 | { 9 | 10 | /* "\\"\""; This sequence is parsed to three tokens "\\" \ "", and will be 11 | diagnosed by compiler-proper unless diagnosed by preprocessor. */ 12 | puts( str( \"")); 13 | 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /test-c/u_1_25.c: -------------------------------------------------------------------------------- 1 | /* u_1_25.c: Undefined behaviors on undefined macro argument. */ 2 | 3 | #include 4 | #define str( a) # a 5 | #define sub( x, y) (x - y) 6 | #define SUB sub 7 | 8 | main( void) 9 | { 10 | int a = 1, b = 2; 11 | 12 | /* u.1.25: Macro argument otherwise parsed as a directive. */ 13 | /* "#define NAME"; or other undefined behaviour. */ 14 | puts( str( 15 | #define NAME 16 | )); 17 | 18 | #if 0 /* Added by C90: Corrigendum 1 (1994) and deleted by C99 */ 19 | /* u.1.26: Expanded macro replacement list end with name of function-like 20 | macro. */ 21 | SUB( a, b); 22 | #endif 23 | 24 | return 0; 25 | } 26 | 27 | -------------------------------------------------------------------------------- /test-c/u_1_27.c: -------------------------------------------------------------------------------- 1 | /* u_1_27.c: Pseudo-directive-line. */ 2 | 3 | /* u.1.27: Unknown preprocessing directive (other than #pragma). */ 4 | #ifdefined MACRO 5 | #endif /* The second error. */ 6 | 7 | main( void) 8 | { 9 | return 0; 10 | } 11 | 12 | -------------------------------------------------------------------------------- /test-c/u_1_28.c: -------------------------------------------------------------------------------- 1 | /* u_1_28.c: Macro expanding to name identical to directive. */ 2 | 3 | #define D define 4 | /* u.1.28: There are following two ways of preprocessing. 5 | 1: "D" isn't expanded, because # is the first token of the line. 6 | Preprocessor reports that "D" is an unknown directive. 7 | 2: "D" is expanded, because that is not a directive. 8 | Compiler-phase will diagnose the output of preprocess. 9 | Anyway, preprocessor should not interprete this line as a preprocessing 10 | directive. */ 11 | #D A B 12 | 13 | main( void) 14 | { 15 | return 0; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /test-c/u_1_5.c: -------------------------------------------------------------------------------- 1 | /* u_1_5.c: Undefined behaviors on illegal characters. */ 2 | 3 | /* u.1.5: Illegal characters (in other than string literal, character 4 | constant, header-name or comment). */ 5 | #if 1 ||2 6 | /* 0x01e ^ ^ 0x1f */ 7 | #endif /* Maybe the second error. */ 8 | 9 | /* u.1.6: [VT], [FF] in directive line. */ 10 | #if 1 || 2 11 | /* [VT] ^ ^ [FF] */ 12 | #endif /* Maybe the second error. */ 13 | 14 | main( void) 15 | { 16 | return 0; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /test-c/u_1_7_big5.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-c/u_1_7_big5.c -------------------------------------------------------------------------------- /test-c/u_1_7_eucjp.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-c/u_1_7_eucjp.c -------------------------------------------------------------------------------- /test-c/u_1_7_gb.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-c/u_1_7_gb.c -------------------------------------------------------------------------------- /test-c/u_1_7_jis.c: -------------------------------------------------------------------------------- 1 | /* u_1_7_jis.c: Invalid multi-byte character sequence (in string literal, 2 | character constant, header-name or comment). */ 3 | 4 | #define str( a) # a 5 | #pragma __setlocale( "jis") /* For MCPP */ 6 | 7 | main( void) 8 | { 9 | char * cp = str( "$B1 (B"); /* 0x3120 */ 10 | return 0; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /test-c/u_1_7_ksc.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-c/u_1_7_ksc.c -------------------------------------------------------------------------------- /test-c/u_1_7_sjis.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-c/u_1_7_sjis.c -------------------------------------------------------------------------------- /test-c/u_1_7_utf8.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-c/u_1_7_utf8.c -------------------------------------------------------------------------------- /test-c/u_1_8.c: -------------------------------------------------------------------------------- 1 | /* u_1_8.c: Undefined behaviors on unterminated quotations. */ 2 | 3 | /* u.1.8: Unterminated character constant. */ 4 | /* The following "comment" may not interpreted as a comment but swallowed by 5 | the unterminated character constant. */ 6 | #error I can't understand. /* Token error prior to execution of #error. */ 7 | 8 | main( void) 9 | { 10 | /* u.1.9: Unterminated string literal. */ 11 | char * string = 12 | "String literal 13 | across the lines. 14 | " 15 | ; 16 | return 0; 17 | } 18 | 19 | /* u.1.10: Unterminated header-name. */ 20 | #include 7 | 8 | #if LONG_MAX - LONG_MIN 9 | #endif 10 | #if LONG_MAX + 1 > SHRT_MAX 11 | #endif 12 | #if LONG_MIN - 1 13 | #endif 14 | #if LONG_MAX * 2 15 | #endif 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /test-t/e_14_7.t: -------------------------------------------------------------------------------- 1 | /* e_14_7.t: There is no keyword in #if expression. */ 2 | 3 | /* 14.7: sizeof operator is disallowed. */ 4 | /* Evaluated as: 0 (0) 5 | Constant expression syntax error. */ 6 | #if sizeof (int) 7 | #endif 8 | 9 | /* 14.8: type cast is disallowed. */ 10 | /* Evaluated as: (0)0x8000 11 | Also a constant expression error. */ 12 | #if (int)0x8000 < 0 13 | #endif 14 | 15 | -------------------------------------------------------------------------------- /test-t/e_14_9.t: -------------------------------------------------------------------------------- 1 | /* e_14_9.t: Out of range in #if expression (division by 0). */ 2 | 3 | /* 14.9: Divided by 0. */ 4 | #if 1 / 0 5 | #endif 6 | 7 | -------------------------------------------------------------------------------- /test-t/e_15_3.t: -------------------------------------------------------------------------------- 1 | /* e_15_3.t: #ifdef, #ifndef syntax errors. */ 2 | 3 | /* 15.3: Not an identifier. */ 4 | #ifdef "string" 5 | #endif 6 | #ifdef 123 7 | #endif 8 | 9 | /* 15.4: Excessive token sequence. */ 10 | #ifdef MACRO Junk 11 | #endif 12 | 13 | /* 15.5: No argument. */ 14 | #ifndef 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /test-t/e_16.t: -------------------------------------------------------------------------------- 1 | /* e_16.t: Trailing junk of #else, #endif. */ 2 | 3 | /* 16.1: Trailing junk of #else. */ 4 | #define MACRO_0 0 5 | #if MACRO_0 6 | #else MACRO_0 7 | 8 | /* 16.2: Trailing junk of #endif. */ 9 | #endif MACRO_0 10 | 11 | -------------------------------------------------------------------------------- /test-t/e_23_3.t: -------------------------------------------------------------------------------- 1 | /* e_23_3.t: ## operator shall not occur at the beginning or at the end of 2 | replacement list for either form of macro definition. */ 3 | 4 | /* 23.3: In object-like macro. */ 5 | #define con ## name 6 | #define cat 12 ## 7 | 8 | /* 23.4: In function-like macro. */ 9 | #define CON( a, b) ## a ## b 10 | #define CAT( b, c) b ## c ## 11 | 12 | -------------------------------------------------------------------------------- /test-t/e_24_6.t: -------------------------------------------------------------------------------- 1 | /* e_24_6.t: Operand of # operator in function-like macro definition shall 2 | be a parameter name. */ 3 | 4 | /* 24.6: */ 5 | #define FUNC( a) # b 6 | 7 | -------------------------------------------------------------------------------- /test-t/e_25_6.t: -------------------------------------------------------------------------------- 1 | /* e_25_6.t: Macro arguments are pre-expanded separately. */ 2 | 3 | #define sub( x, y) (x - y) 4 | 5 | /* 25.6: */ 6 | #define head sub( 7 | #define body(x,y) x,y 8 | #define tail ) 9 | #define head_body_tail( a, b, c) a b c 10 | /* "head" is once replaced to "sub(", then rescanning of "sub(" causes an 11 | uncompleted macro call. Expansion of an argument should complete 12 | within the argument. */ 13 | head_body_tail( head, body(a,b), tail); 14 | 15 | -------------------------------------------------------------------------------- /test-t/e_27_7.t: -------------------------------------------------------------------------------- 1 | /* e_27_7.t: Error of rescanning. */ 2 | 3 | #define sub( x, y) (x - y) 4 | 5 | /* 27.7: */ 6 | #define TWO_TOKENS a,b 7 | #define SUB( x, y) sub( x, y) 8 | /* Too many arguments error while rescanning after once replaced to: 9 | sub( a,b, 1); */ 10 | SUB( TWO_TOKENS, 1); 11 | 12 | -------------------------------------------------------------------------------- /test-t/e_29_3.t: -------------------------------------------------------------------------------- 1 | /* e_29_3.t: #undef errors. */ 2 | 3 | /* 29.3: Not an identifier. */ 4 | #undef "string" 5 | #undef 123 6 | 7 | /* 29.4: Excessive token sequence. */ 8 | #undef MACRO_0 Junk 9 | 10 | /* 29.5: No argument. */ 11 | #undef 12 | 13 | -------------------------------------------------------------------------------- /test-t/e_31.t: -------------------------------------------------------------------------------- 1 | /* e_31.t: Illegal macro calls. */ 2 | 3 | #define sub( a, b) (a - b) 4 | 5 | /* 31.1: Too many arguments error. */ 6 | sub( x, y, z); 7 | 8 | /* 31.2: Too few arguments error. */ 9 | sub( x); 10 | 11 | -------------------------------------------------------------------------------- /test-t/e_31_3.t: -------------------------------------------------------------------------------- 1 | /* e_31_3.t: Macro call in control line should complete in the line. */ 2 | 3 | #define glue( a, b) a ## b 4 | #define str( s) # s 5 | #define xstr( s) str( s) 6 | 7 | /* 31.3: Unterminated macro call. */ 8 | #include xstr( glue( header, 9 | .h)) 10 | 11 | -------------------------------------------------------------------------------- /test-t/e_32_5.t: -------------------------------------------------------------------------------- 1 | /* e_32_5.t: Range error of character constant. */ 2 | 3 | /* 32.5: Value of a numerical escape sequence in character constant should 4 | be in the range of char. */ 5 | #if '\x123' == 0x123 /* Out of range */ 6 | #endif 7 | 8 | -------------------------------------------------------------------------------- /test-t/e_33_2.t: -------------------------------------------------------------------------------- 1 | /* e_33_2.t: Out of range of numerical escape sequence in wide-char. */ 2 | 3 | /* 33.2: Value of a numerical escape sequence in wide-character constant 4 | should be in the range of wchar_t. */ 5 | #if L'\xabcdef012' == 0xbcdef012 /* Perhaps out of range. */ 6 | #endif 7 | 8 | -------------------------------------------------------------------------------- /test-t/e_35_2.t: -------------------------------------------------------------------------------- 1 | /* e_35_2.t: Out of range of character constant. */ 2 | 3 | /* 35.2: */ 4 | #if 'abcdefghi' /* Perhaps out of range. */ 5 | #endif 6 | 7 | -------------------------------------------------------------------------------- /test-t/e_4_3.t: -------------------------------------------------------------------------------- 1 | /* e_4_3.t: Illegal pp-token. */ 2 | 3 | /* 4.3: Empty character constant is an error. */ 4 | #if '' == 0 /* This line is invalid, maybe skipped. */ 5 | #endif /* This line maybe the second error. */ 6 | 7 | -------------------------------------------------------------------------------- /test-t/e_7_4.t: -------------------------------------------------------------------------------- 1 | /* e_7_4.t: #line error. */ 2 | 3 | /* 7.4: string literal in #line directive shall be a character string 4 | literal. */ 5 | 6 | #line 123 L"wide" 7 | /* 8; "e_7_4.t"; */ 8 | __LINE__; __FILE__; 9 | 10 | -------------------------------------------------------------------------------- /test-t/e_intmax.t: -------------------------------------------------------------------------------- 1 | /* e_intmax.t: Overflow of constant expression in #if directive. */ 2 | 3 | #include 4 | #include 5 | 6 | #if INTMAX_MAX - INTMAX_MIN 7 | #endif 8 | #if INTMAX_MAX + 1 > SHRT_MAX 9 | #endif 10 | #if INTMAX_MIN - 1 11 | #endif 12 | #if INTMAX_MAX * 2 13 | #endif 14 | 15 | #if LLONG_MAX - LLONG_MIN 16 | #endif 17 | #if LLONG_MAX + 1 > SHRT_MAX 18 | #endif 19 | #if LLONG_MIN - 1 20 | #endif 21 | #if LLONG_MAX * 2 22 | #endif 23 | 24 | -------------------------------------------------------------------------------- /test-t/e_operat.cc: -------------------------------------------------------------------------------- 1 | /* e_operat.t */ 2 | /* 3 | * In C++98 the 11 identifier-like tokens are operators, not identifiers. 4 | * Note: in C95 these are defined as macros by . 5 | */ 6 | 7 | /* Cannot define operator as a macro. */ 8 | #define and && 9 | #define xor_eq ^= 10 | 11 | -------------------------------------------------------------------------------- /test-t/e_operat.t: -------------------------------------------------------------------------------- 1 | /* e_operat.t */ 2 | /* 3 | * In C++98 the 11 identifier-like tokens are operators, not identifiers. 4 | * Note: in C95 these are defined as macros by . 5 | */ 6 | 7 | /* Cannot define operator as a macro. */ 8 | #define and && 9 | #define xor_eq ^= 10 | 11 | -------------------------------------------------------------------------------- /test-t/e_pragma.t: -------------------------------------------------------------------------------- 1 | /* e_pragma.t: Erroneous use of _Pragma() operator */ 2 | /* Operand of _Pragma() should be a string literal */ 3 | _Pragma( This is not a string literal) 4 | 5 | -------------------------------------------------------------------------------- /test-t/e_ucn.t: -------------------------------------------------------------------------------- 1 | /* e_ucn.t: Errors of Universal-character-name sequense. */ 2 | 3 | #define macro\U0000001F /* violation of constraint */ 4 | #define macro\uD800 /* violation of constraint (only C, not for C++) */ 5 | #define macro\u123 /* too short sequence (violation of syntax rule) */ 6 | #define macro\U1234567 /* also too short sequence */ 7 | 8 | -------------------------------------------------------------------------------- /test-t/e_vargs.t: -------------------------------------------------------------------------------- 1 | /* e_vargs1.t: Erroneous usage of __VA_ARGS__ */ 2 | 3 | /* __VA_ARGS__ should not be defined. */ 4 | #define __VA_ARGS__ (x, y, z) 5 | 6 | /* 7 | * __VA_ARGS__ should be the parameter name in replacement list 8 | * corresponding to '...'. 9 | */ 10 | #define wrong_macro( a, b, __VA_ARGS__) (a + b - __VA_ARGS__) 11 | 12 | 13 | /* e_vargs2.t: Erroneous macro invocation of variable arguments */ 14 | #define debug( ...) fprintf( stderr, __VA_ARGS__) 15 | /* No argument to correspond __VA_ARGS__ */ 16 | debug(); 17 | 18 | -------------------------------------------------------------------------------- /test-t/header.h: -------------------------------------------------------------------------------- 1 | /* header.h */ 2 | 3 | #define MACRO_abc abc 4 | -------------------------------------------------------------------------------- /test-t/i_32_3.t: -------------------------------------------------------------------------------- 1 | /* i_32_3.t: Character constant in #if expression. */ 2 | 3 | /* In ASCII character set. */ 4 | /* 32.3: */ 5 | #if 'a' != 0x61 6 | Not ASCII character set, or bad evaluation of character constant. 7 | #endif 8 | 9 | /* 32.4: '\a' and '\v' */ 10 | #if '\a' != 7 || '\v' != 11 11 | Not ASCII character set, or bad evaluation of escape sequences. 12 | #endif 13 | 14 | -------------------------------------------------------------------------------- /test-t/i_35.t: -------------------------------------------------------------------------------- 1 | /* i_35.t: Multi-character character constant. */ 2 | 3 | /* In ASCII character set. */ 4 | /* 35.1: */ 5 | #if ('ab' != '\x61\x62') || ('\aa' != '\7\x61') 6 | Bad handling of multi-character character constant. 7 | #endif 8 | 9 | -------------------------------------------------------------------------------- /test-t/i_35_3.t: -------------------------------------------------------------------------------- 1 | /* i_35_3.t: Multi-character wide character constant. */ 2 | 3 | /* In ASCII character set. */ 4 | /* 35.3: */ 5 | #if (L'ab' != L'\x61\x62') || (L'ab' == 'ab') 6 | Bad handling of multi-character wide character constant. 7 | #endif 8 | 9 | -------------------------------------------------------------------------------- /test-t/i_mbident.t: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-t/i_mbident.t -------------------------------------------------------------------------------- /test-t/line.h: -------------------------------------------------------------------------------- 1 | /* line.h */ 2 | 3 | __LINE__; __FILE__; 4 | -------------------------------------------------------------------------------- /test-t/m_33_big5.t: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-t/m_33_big5.t -------------------------------------------------------------------------------- /test-t/m_33_eucjp.t: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-t/m_33_eucjp.t -------------------------------------------------------------------------------- /test-t/m_33_gb.t: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-t/m_33_gb.t -------------------------------------------------------------------------------- /test-t/m_33_ksc.t: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-t/m_33_ksc.t -------------------------------------------------------------------------------- /test-t/m_33_sjis.t: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-t/m_33_sjis.t -------------------------------------------------------------------------------- /test-t/m_33_utf8.t: -------------------------------------------------------------------------------- 1 | /* m_33_utf8.t: Wide character constant encoded in UTF-8. */ 2 | 3 | #include 4 | #define BYTES_VAL (1 << CHAR_BIT) 5 | 6 | /* 33.1: L'ch'. */ 7 | 8 | #pragma __setlocale( "utf8") /* For MCPP */ 9 | #pragma setlocale( "utf8") /* For MCPP on VC */ 10 | 11 | #if L'字' == '\xe5' * BYTES_VAL * BYTES_VAL + '\xad' * BYTES_VAL + '\x97' 12 | Wide character is encoded in UTF-8. 13 | #elif L'字' == '\x97' * BYTES_VAL * BYTES_VAL + '\xad' * BYTES_VAL + '\xe5' 14 | Wide character is encoded in UTF-8. 15 | Inverted order of evaluation. 16 | #else 17 | I cannot understand UTF-8. 18 | #endif 19 | #if L'字' < 0 20 | Evaluated in negative value. 21 | #endif 22 | 23 | -------------------------------------------------------------------------------- /test-t/m_34_big5.t: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-t/m_34_big5.t -------------------------------------------------------------------------------- /test-t/m_34_eucjp.t: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-t/m_34_eucjp.t -------------------------------------------------------------------------------- /test-t/m_34_gb.t: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-t/m_34_gb.t -------------------------------------------------------------------------------- /test-t/m_34_jis.t: -------------------------------------------------------------------------------- 1 | /* m_34_jis.t: Multi-byte character constant encoded in ISO-2022-JP. */ 2 | 3 | /* 34.1: */ 4 | 5 | #pragma __setlocale( "jis") /* For MCPP */ 6 | #pragma setlocale( "jis") /* For MCPP on VC */ 7 | 8 | #if '$B;z(B' == '\x3b\x7a' 9 | /* This line doesn't work unless "shift states" are processed. */ 10 | Multi-byte character is encoded in ISO-2022-JP. 11 | #else 12 | I cannot understand ISO-2022-JP. 13 | #endif 14 | 15 | -------------------------------------------------------------------------------- /test-t/m_34_ksc.t: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-t/m_34_ksc.t -------------------------------------------------------------------------------- /test-t/m_34_sjis.t: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-t/m_34_sjis.t -------------------------------------------------------------------------------- /test-t/m_34_utf8.t: -------------------------------------------------------------------------------- 1 | /* m_34_utf8.t: Multi-byte character constant encoded in UTF-8. */ 2 | 3 | /* 34.1: */ 4 | 5 | #pragma __setlocale( "utf8") /* For MCPP */ 6 | #pragma setlocale( "utf8") /* For MCPP on VC */ 7 | 8 | #if '字' == '\xe5\xad\x97' 9 | Multi-byte character is encoded in UTF-8. 10 | #else 11 | I cannot understand UTF-8. 12 | #endif 13 | 14 | -------------------------------------------------------------------------------- /test-t/m_36_big5.t: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-t/m_36_big5.t -------------------------------------------------------------------------------- /test-t/m_36_sjis.t: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-t/m_36_sjis.t -------------------------------------------------------------------------------- /test-t/misc.t: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-t/misc.t -------------------------------------------------------------------------------- /test-t/n_1.t: -------------------------------------------------------------------------------- 1 | /* n_1.t: Conversion of trigraph sequences. */ 2 | 3 | /* 1.1: The following 9 sequences are valid trigraph sequences. */ 4 | /* [ ] \ ^ { } | ~ #; */ 5 | ??( ??) ??/ ??' ??< ??> ??! ??- ??=; 6 | 7 | /* 1.2: In directive line. */ 8 | /* ab | cd; */ 9 | ??= define OR( a, b) a ??! b 10 | OR( ab, cd); 11 | 12 | /* 1.3: Any sequence other than above 9 is not a trigraph sequence. */ 13 | /* ?? ??? ??% ??^ ?#; */ 14 | ?? ??? ??% ??^ ???=; 15 | 16 | -------------------------------------------------------------------------------- /test-t/n_10.t: -------------------------------------------------------------------------------- 1 | /* n_10.t: #if, #elif, #else and #endif pp-directive. */ 2 | 3 | #define MACRO_0 0 4 | #define MACRO_1 1 5 | 6 | /* 10.1: */ 7 | /* Note: an undefined identifier in #if expression is replaced to 0. */ 8 | /* 1; */ 9 | #if a 10 | a; 11 | #elif MACRO_0 12 | MACRO_0; 13 | #elif MACRO_1 /* Valid block */ 14 | MACRO_1; 15 | #else 16 | 0; 17 | #endif 18 | 19 | /* 10.2: Comments must be processed even if in skipped #if block. */ 20 | /* At least tokenization of string literal and character constant is necessary 21 | to process comments, e.g. /* is not a comment mark in string literal. 22 | */ 23 | #ifdef UNDEFINED 24 | /* Comment */ 25 | "in literal /* is not a comment" 26 | #endif 27 | 28 | -------------------------------------------------------------------------------- /test-t/n_11.t: -------------------------------------------------------------------------------- 1 | /* n_11.t: Operator "defined" in #if or #elif directive. */ 2 | 3 | #define MACRO_abc abc 4 | #define MACRO_0 0 5 | #define ZERO_TOKEN 6 | 7 | /* 11.1: */ 8 | /* abc; */ 9 | /* abc; */ 10 | #if defined a 11 | a; 12 | #else 13 | MACRO_abc; 14 | #endif 15 | #if defined (MACRO_abc) 16 | MACRO_abc; 17 | #else 18 | 0; 19 | #endif 20 | 21 | /* 11.2: "defined" is an unary operator whose result is 1 or 0. */ 22 | #if defined MACRO_0 * 3 != 3 23 | Bad handling of "defined" operator. 24 | #endif 25 | #if (!defined ZERO_TOKEN != 0) || (-defined ZERO_TOKEN != -1) 26 | Bad grouping of "defined", !, - operator. 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /test-t/n_13_13.t: -------------------------------------------------------------------------------- 1 | /* n_13_13.t: #if expression with macros. */ 2 | 3 | #define ZERO_TOKEN 4 | #define MACRO_0 0 5 | #define MACRO_1 1 6 | #if ! __cplusplus 7 | #define and && 8 | #define or || 9 | #define not_eq != 10 | #define bitor | 11 | #endif 12 | 13 | /* 13.13: With macros expanding to operators. */ 14 | /* Valid block */ 15 | #if (1 bitor 2) == 3 and 4 not_eq 5 or 0 16 | /* #if (1 | 2) == 3 && 4 != 5 || 0 */ 17 | Valid block 18 | #else 19 | Block to be skipped 20 | #endif 21 | 22 | /* 13.14: With macros expanding to 0 token, nonsence but legal expression.*/ 23 | /* Valid block */ 24 | #if ZERO_TOKEN MACRO_1 ZERO_TOKEN > ZERO_TOKEN MACRO_0 ZERO_TOKEN 25 | /* #if 1 > 0 */ 26 | Valid block 27 | #else 28 | Block to be skipped 29 | #endif 30 | 31 | -------------------------------------------------------------------------------- /test-t/n_13_5.t: -------------------------------------------------------------------------------- 1 | /* n_13_5.t: Arithmetic conversion in #if expressions. */ 2 | 3 | /* 13.5: The usual arithmetic conversion is not performed on bit shift. */ 4 | #if -1 << 3U > 0 5 | Bad conversion of bit shift operands. 6 | #endif 7 | 8 | /* 13.6: Usual arithmetic conversions. */ 9 | #if -1 <= 0U /* -1 is converted to unsigned long. */ 10 | Bad arithmetic conversion. 11 | #endif 12 | 13 | #if -1 * 1U <= 0 14 | Bad arithmetic conversion. 15 | #endif 16 | 17 | /* Second and third operands of conditional operator are converted to the 18 | same type, thus -1 is converted to unsigned long. */ 19 | #if (1 ? -1 : 0U) <= 0 20 | Bad arithmetic conversion. 21 | #endif 22 | 23 | -------------------------------------------------------------------------------- /test-t/n_13_7.t: -------------------------------------------------------------------------------- 1 | /* n_13_7.t: Short-circuit evaluation of #if expression. */ 2 | 3 | /* 13.7: 10/0 or 10/MACRO_0 are never evaluated, "divide by zero" error 4 | cannot occur. */ 5 | #define MACRO_0 0 6 | 7 | /* Valid block */ 8 | #if 0 && 10 / 0 9 | Block to be skipped 10 | #endif 11 | #if not_defined && 10 / not_defined 12 | Block to be skipped 13 | #endif 14 | #if MACRO_0 && 10 / MACRO_0 > 1 15 | Block to be skipped 16 | #endif 17 | #if MACRO_0 ? 10 / MACRO_0 : 0 18 | Block to be skipped 19 | #endif 20 | #if MACRO_0 == 0 || 10 / MACRO_0 > 1 21 | Valid block 22 | #else 23 | Block to be skipped 24 | #endif 25 | 26 | -------------------------------------------------------------------------------- /test-t/n_15.t: -------------------------------------------------------------------------------- 1 | /* n_15.t: #ifdef, #ifndef directives. */ 2 | 3 | #define MACRO_1 1 4 | 5 | /* 15.1: #ifdef directive. */ 6 | /* Valid block */ 7 | #ifdef MACRO_1 8 | Valid block 9 | #else 10 | Block to be skipped 11 | #endif 12 | 13 | /* 15.2: #ifndef directive. */ 14 | /* Valid block */ 15 | #ifndef MACRO_1 16 | Block to be skipped 17 | #else 18 | Valid block 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /test-t/n_18.t: -------------------------------------------------------------------------------- 1 | /* n_18.t: #define directive. */ 2 | 3 | /* Excerpts from ISO C 6.8.3 "Examples". */ 4 | #define OBJ_LIKE (1-1) 5 | #define FTN_LIKE(a) ( a ) 6 | 7 | #define ZERO_TOKEN 8 | 9 | /* 18.1: Definition of an object-like macro. */ 10 | /* (1-1); */ 11 | OBJ_LIKE; 12 | /* Macro defined to no token. */ 13 | /* ; */ 14 | ZERO_TOKEN; 15 | 16 | /* 18.2: Definition of a function-like macro. */ 17 | /* ( c ); */ 18 | FTN_LIKE( c); 19 | 20 | /* 18.3: Spelling in string identical to parameter is not a parameter. */ 21 | /* "n1:n2"; */ 22 | #define STR( n1, n2) "n1:n2" 23 | STR( 1, 2); 24 | 25 | -------------------------------------------------------------------------------- /test-t/n_19.t: -------------------------------------------------------------------------------- 1 | /* n_19.t: Valid re-definitions of macros. */ 2 | 3 | /* Excerpts from ISO C 6.8.3 "Examples". */ 4 | #define OBJ_LIKE (1-1) 5 | #define FTN_LIKE(a) ( a ) 6 | 7 | /* 19.1: */ 8 | #define OBJ_LIKE /* white space */ (1-1) /* other */ 9 | 10 | /* 19.2: */ 11 | #define FTN_LIKE( a )( /* note the white space */ \ 12 | a /* other stuff on this line 13 | */ ) 14 | /* ( c ); */ 15 | FTN_LIKE( c); 16 | 17 | -------------------------------------------------------------------------------- /test-t/n_20.t: -------------------------------------------------------------------------------- 1 | /* n_20.t: Definition of macro lexically identical to keyword. */ 2 | 3 | /* 20.1: */ 4 | /* double fl; */ 5 | #define float double 6 | float fl; 7 | 8 | -------------------------------------------------------------------------------- /test-t/n_21.t: -------------------------------------------------------------------------------- 1 | /* n_21.t: Tokenization (No preprocessing tokens are merged implicitly). */ 2 | 3 | /* 21.1: */ 4 | /* - - -a; */ 5 | #define MINUS - 6 | -MINUS-a; 7 | 8 | /* 21.2: */ 9 | #define sub( a, b) a-b /* '(a)-(b)' is better */ 10 | #define Y -y /* '(-y)' is better */ 11 | /* x- -y; */ 12 | sub( x, Y); 13 | 14 | -------------------------------------------------------------------------------- /test-t/n_22.t: -------------------------------------------------------------------------------- 1 | /* n_22.t: Tokenization of preprocessing number. */ 2 | 3 | #define EXP 1 4 | 5 | /* 22.1: 12E+EXP is a preprocessing number, EXP is not expanded. */ 6 | /* 12E+EXP; */ 7 | 12E+EXP; 8 | 9 | /* 22.2: .2e-EXP is also a preprocessing number. */ 10 | /* .2e-EXP; */ 11 | .2e-EXP; 12 | 13 | /* 22.3: + or - is allowed only following E or e, 12+EXP is not a 14 | preprocessing number. */ 15 | /* Three tokens: 12 + 1; */ 16 | 12+EXP; 17 | 18 | -------------------------------------------------------------------------------- /test-t/n_23.t: -------------------------------------------------------------------------------- 1 | /* n_23.t: ## operator in macro definition. */ 2 | 3 | #define glue( a, b) a ## b 4 | #define xglue( a, b) glue( a, b) 5 | 6 | /* 23.1: */ 7 | /* xy; */ 8 | glue( x, y); 9 | 10 | /* 23.2: Generate a preprocessing number. */ 11 | /* .12e+2; */ 12 | #define EXP 2 13 | xglue( .12e+, EXP); 14 | 15 | -------------------------------------------------------------------------------- /test-t/n_26.t: -------------------------------------------------------------------------------- 1 | /* n_26.t: The name once replaced is not furthur replaced. */ 2 | 3 | /* 26.1: Directly recursive object-like macro definition. */ 4 | /* Z[0]; */ 5 | #define Z Z[0] 6 | Z; 7 | 8 | /* 26.2: Intermediately recursive object-like macro definition. */ 9 | /* AB; */ 10 | #define AB BA 11 | #define BA AB 12 | AB; 13 | 14 | /* 26.3: Directly recursive function-like macro definition. */ 15 | /* x + f(x); */ 16 | #define f(a) a + f(a) 17 | f( x); 18 | 19 | /* 26.4: Intermediately recursive function-like macro definition. */ 20 | /* x + x + g( x); */ 21 | #define g(a) a + h( a) 22 | #define h(a) a + g( a) 23 | g( x); 24 | 25 | /* 26.5: Rescanning encounters the non-replaced macro name. */ 26 | /* Z[0] + f( Z[0]); */ 27 | f( Z); 28 | 29 | -------------------------------------------------------------------------------- /test-t/n_28.t: -------------------------------------------------------------------------------- 1 | /* n_28.t: __FILE__, __LINE__, __DATE__, __TIME__, __STDC__ and 2 | __STDC_VERSION__ are predefined. */ 3 | 4 | /* 28.1: */ 5 | /* "n_28.t"; */ 6 | __FILE__; 7 | 8 | /* 28.2: */ 9 | /* 10; */ 10 | __LINE__; 11 | 12 | /* 28.3: */ 13 | /* "Aug 1 2001"; */ 14 | __DATE__; 15 | 16 | /* 28.4: */ 17 | /* "21:42:22"; */ 18 | __TIME__; 19 | 20 | /* 28.5: */ 21 | /* 1; */ 22 | __STDC__; 23 | 24 | /* 28.6: */ 25 | /* 199409L; */ 26 | /* In C99, the value of this macro is 199901L */ 27 | __STDC_VERSION__; 28 | 29 | /* 28.7: __LINE__, __FILE__ in an included file. */ 30 | /* 3; "line.h"; */ 31 | #include "line.h" 32 | 33 | -------------------------------------------------------------------------------- /test-t/n_29.t: -------------------------------------------------------------------------------- 1 | /* n_29.t: #undef directive. */ 2 | 3 | /* 29.1: Undefined macro is not a macro. */ 4 | /* DEFINED; */ 5 | #define DEFINED 6 | #undef DEFINED 7 | DEFINED; 8 | 9 | /* 29.2: Undefining undefined name is not an error. */ 10 | #undef UNDEFINED 11 | 12 | -------------------------------------------------------------------------------- /test-t/n_3.t: -------------------------------------------------------------------------------- 1 | /* n_3.t: Handling of comment. */ 2 | 3 | /* 3.1: A comment is converted to one space. */ 4 | /* abc de */ 5 | abc/* comment */de 6 | 7 | /* 3.2: // is not a comment of C. */ 8 | #if 0 /* This feature is obsolete now. */ 9 | /* // is not a comment of C */ 10 | // is not a comment of C 11 | #endif 12 | 13 | /* 3.3: Comment is parsed prior to the parsing of preprocessing directive. */ 14 | /* abcd */ 15 | #if 0 16 | "nonsence"; /* 17 | #else 18 | still in 19 | comment */ 20 | #else 21 | #define MACRO_abcd /* 22 | in comment 23 | */ abcd 24 | #endif 25 | MACRO_abcd 26 | 27 | -------------------------------------------------------------------------------- /test-t/n_30.t: -------------------------------------------------------------------------------- 1 | /* n_30.t: Macro call. */ 2 | /* Note: Comma separate the arguments of function-like macro call, 3 | but comma between matching inner parenthesis doesn't. This feature 4 | is tested on so many places in this suite especially on *.c samples 5 | which use assert() macro, that no separete item to test this feature 6 | is provided. */ 7 | 8 | /* 30.1: A macro call may cross the lines. */ 9 | #define FUNC( a, b, c) a + b + c 10 | /* a + b + c; */ 11 | FUNC 12 | ( 13 | a, 14 | b, 15 | c 16 | ) 17 | ; 18 | 19 | -------------------------------------------------------------------------------- /test-t/n_32.t: -------------------------------------------------------------------------------- 1 | /* n_32.t: Escape sequence in character constant in #if expression. */ 2 | 3 | /* 32.1: Character octal escape sequence. */ 4 | #if '\123' != 83 5 | Bad evaluation of octal escape sequence. 6 | #endif 7 | 8 | /* 32.2: Character hexadecimal escape sequence. */ 9 | #if '\x1b' != '\033' 10 | Bad evaluation of hexadecimal escape sequence. 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /test-t/n_3_4.t: -------------------------------------------------------------------------------- 1 | /* n_3_4.t: Handling of comment and . */ 2 | 3 | /* 3.4: Comment and in #error line. */ 4 | #error Message of first physical line. \ 5 | Message of second physical and first logical line. /* 6 | this comment splices the lines 7 | */ Message of forth physical and third logical line. 8 | 9 | -------------------------------------------------------------------------------- /test-t/n_4.t: -------------------------------------------------------------------------------- 1 | /* n_4.t: Special tokens. */ 2 | 3 | /* 4.1: Digraph spellings in directive line. */ 4 | /* "abc"; */ 5 | %: define stringize( a) %: a 6 | 7 | stringize( abc); 8 | 9 | /* 4.2: Digraph spellings are retained in stringization. */ 10 | /* "<:"; */ 11 | stringize( <:); 12 | 13 | -------------------------------------------------------------------------------- /test-t/n_5.t: -------------------------------------------------------------------------------- 1 | /* n_5.t: Spaces or tabs are allowed at any place in pp-directive line, 2 | including between the top of a pp-directive line and '#', and between 3 | the '#' and the directive. */ 4 | 5 | /* 5.1: */ 6 | /* |**|[TAB]# |**|[TAB]define |**| MACRO_abcde[TAB]|**| abcde |**| */ 7 | /**/ # /**/ define /**/ MACRO_abcde /**/ abcde /**/ 8 | /* abcde */ 9 | MACRO_abcde 10 | 11 | -------------------------------------------------------------------------------- /test-t/n_6.t: -------------------------------------------------------------------------------- 1 | /* n_6.t: #include directive. */ 2 | 3 | /* 6.1: Header-name quoted by " and " as well as by < and > can include 4 | standard headers. */ 5 | /* Note: Standard headers can be included any times. */ 6 | #include "ctype.h" 7 | #include 8 | 9 | /* 6.2: Macro is allowed in #include line. */ 10 | #define HEADER "header.h" 11 | /* Before file inclusion: #include "header.h" */ 12 | #include HEADER 13 | /* abc */ 14 | MACRO_abc 15 | 16 | /* 6.3: With macro nonsence but legal. */ 17 | #undef MACRO_abc 18 | #define ZERO_TOKEN 19 | #include ZERO_TOKEN HEADER ZERO_TOKEN 20 | /* abc */ 21 | MACRO_abc 22 | 23 | -------------------------------------------------------------------------------- /test-t/n_7.t: -------------------------------------------------------------------------------- 1 | /* n_7.t: #line directive. */ 2 | 3 | /* 7.1: Line number and filename. */ 4 | /* 1234; "cpp"; */ 5 | #line 1234 "cpp" 6 | __LINE__; __FILE__; 7 | 8 | /* 7.2: Filename argument is optional. */ 9 | /* 2345; "cpp"; */ 10 | #line 2345 11 | __LINE__; __FILE__; 12 | 13 | /* 7.3: Argument with macro. */ 14 | /* 3456; "n_7.t"; */ 15 | #define LINE_AND_FILENAME 3456 "n_7.t" 16 | #line LINE_AND_FILENAME 17 | __LINE__; __FILE__; 18 | 19 | -------------------------------------------------------------------------------- /test-t/n_8.t: -------------------------------------------------------------------------------- 1 | /* n_8.t: #error directive. */ 2 | 3 | /* 8.1: Argument of #error directive is not a subject of macro expansion. 4 | Output to stderr as an example: 5 | Preprocessing error directive: MACRO is not a positive number. 6 | from line 10 of file "n_8.t" 7 | */ 8 | #define MACRO 0 9 | #if MACRO <= 0 10 | #error MACRO is not a positive number. 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /test-t/n_8_2.t: -------------------------------------------------------------------------------- 1 | /* n_8_2.t: Argument of #error is optional. */ 2 | 3 | /* 8.2: #error should be executed. */ 4 | #error 5 | 6 | -------------------------------------------------------------------------------- /test-t/n_9.t: -------------------------------------------------------------------------------- 1 | /* n_9.t: #pragma directive. */ 2 | 3 | /* 9.1: Any #pragma directive should be processed or ignored, should not 4 | be diagnosed as an error. */ 5 | #pragma once 6 | #pragma who knows ? 7 | 8 | -------------------------------------------------------------------------------- /test-t/n_bool.cc: -------------------------------------------------------------------------------- 1 | /* bool.t */ 2 | /* 3 | * On C++: 'true' and 'false' are evaluated 1 and 0 respectively. 4 | * and logical AND, logical OR are evaluated boolean. 5 | */ 6 | 7 | /* Valid block; */ 8 | 9 | #define MACRO 1 10 | #define MACRO3 3 11 | 12 | #if MACRO == true 13 | Valid block; 14 | #else 15 | non-Valid block; 16 | #endif 17 | 18 | #if (MACRO && MACRO3) == true 19 | Valid block; 20 | #else 21 | non-Valid block; 22 | #endif 23 | 24 | -------------------------------------------------------------------------------- /test-t/n_bool.t: -------------------------------------------------------------------------------- 1 | /* bool.t */ 2 | /* 3 | * On C++: 'true' and 'false' are evaluated 1 and 0 respectively. 4 | * and logical AND, logical OR are evaluated boolean. 5 | */ 6 | 7 | /* Valid block; */ 8 | 9 | #define MACRO 1 10 | #define MACRO3 3 11 | 12 | #if MACRO == true 13 | Valid block; 14 | #else 15 | non-Valid block; 16 | #endif 17 | 18 | #if (MACRO && MACRO3) == true 19 | Valid block; 20 | #else 21 | non-Valid block; 22 | #endif 23 | 24 | -------------------------------------------------------------------------------- /test-t/n_cnvucn.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-t/n_cnvucn.cc -------------------------------------------------------------------------------- /test-t/n_cnvucn.t: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-t/n_cnvucn.t -------------------------------------------------------------------------------- /test-t/n_cplus.cc: -------------------------------------------------------------------------------- 1 | /* cplus.t: C++98 pre-defined macro __cplusplus. */ 2 | 3 | /* 199711L; */ 4 | __cplusplus; 5 | 6 | -------------------------------------------------------------------------------- /test-t/n_cplus.t: -------------------------------------------------------------------------------- 1 | /* cplus.t: C++98 pre-defined macro __cplusplus. */ 2 | 3 | /* 199711L; */ 4 | __cplusplus; 5 | 6 | -------------------------------------------------------------------------------- /test-t/n_dslcom.cc: -------------------------------------------------------------------------------- 1 | /* n_dslcom: // is a comment of C++ and C99. */ 2 | /* a; */ 3 | a; // is a comment of C++ and C99 4 | 5 | -------------------------------------------------------------------------------- /test-t/n_dslcom.t: -------------------------------------------------------------------------------- 1 | /* n_dslcom: // is a comment of C++ and C99. */ 2 | /* a; */ 3 | a; // is a comment of C++ and C99 4 | 5 | -------------------------------------------------------------------------------- /test-t/n_line.t: -------------------------------------------------------------------------------- 1 | /* n_line.t: line number argument of #line */ 2 | /* C99: Range of line number in #line directive is [1..2147483647] */ 3 | 4 | /* 2147483647; */ 5 | #line 2147483647 6 | __LINE__; 7 | 8 | -------------------------------------------------------------------------------- /test-t/n_llong.t: -------------------------------------------------------------------------------- 1 | /* n_llong.t: long long in #if expression */ 2 | 3 | #if 12345678901234567890 < 13345678901234567890 4 | "long long #if expression is implemented." 5 | #else 6 | "long long #if expression is not implemented." 7 | #endif 8 | 9 | #if 12345678901234567890LL < 13345678901234567890LL 10 | Valid block 11 | #else 12 | Block to be skipped 13 | #endif 14 | 15 | #if (0x7FFFFFFFFFFFFFFFULL - 0x6FFFFFFFFFFFFFFFULL) >> 60 == 1 16 | Valid block 17 | #else 18 | Block to be skipped 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /test-t/n_ppnum.t: -------------------------------------------------------------------------------- 1 | /* n_ppnum.t: Preprocessing number token *p+* */ 2 | /* Undefined on C90, because '+A' is not a valid pp-token. */ 3 | 4 | #define A 3 5 | #define glue( a, b) a ## b 6 | /* 12p+A; */ 7 | glue( 12p+, A); 8 | 9 | -------------------------------------------------------------------------------- /test-t/n_std99.t: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-t/n_std99.t -------------------------------------------------------------------------------- /test-t/n_stdmac.t: -------------------------------------------------------------------------------- 1 | /* n_stdmac.t: C99 Standard pre-defined macros. */ 2 | 3 | /* 199901L; */ 4 | __STDC_VERSION__; 5 | 6 | /* 1; or 0; */ 7 | __STDC_HOSTED__; 8 | 9 | -------------------------------------------------------------------------------- /test-t/n_tlim_3.t: -------------------------------------------------------------------------------- 1 | /* n_tlim_3.t: Significant initial characters in an internal identifier or a 2 | macro name: at least 63 bytes. */ 3 | 4 | int 5 | A23456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef = 63; 6 | -------------------------------------------------------------------------------- /test-t/n_tlim_4.t: -------------------------------------------------------------------------------- 1 | /* n_tlim_4.t: Nested conditional inclusion: at least 63 level. */ 2 | 3 | /* nest = 0x3f; */ 4 | #define X3F 5 | #include "ifdef15.h" 6 | -------------------------------------------------------------------------------- /test-t/n_tlim_5.t: -------------------------------------------------------------------------------- 1 | /* n_tlim_5.t: Nested source file inclusion: at least 15 level. */ 2 | 3 | /* nest = 0x0f; */ 4 | #define X0F 5 | #include "nest1.h" 6 | -------------------------------------------------------------------------------- /test-t/n_tlim_8.t: -------------------------------------------------------------------------------- 1 | /* n_tlim_8.t: Length of logical source line: at least 4095 bytes. */ 2 | 3 | #include "long4095.h" 4 | -------------------------------------------------------------------------------- /test-t/n_tlim_9.t: -------------------------------------------------------------------------------- 1 | /* n_tlim_9.t: Number of macro definitions: at least 4095. */ 2 | 3 | #undef ARG 4 | #include "m4095.h" 5 | 6 | /* 0x0fff; */ 7 | GBM; 8 | -------------------------------------------------------------------------------- /test-t/n_token.cc: -------------------------------------------------------------------------------- 1 | /* n_token.t: special pp-token in C++ */ 2 | 3 | #define str( a) xstr( a) 4 | #define xstr( a) # a 5 | #define paste( a, b) a ## b 6 | 7 | /* token.1: '::' is a token in C++, although illegal token sequence 8 | in C */ 9 | /* "::"; */ 10 | str( paste( :, :)); 11 | 12 | /* token.2: 'and', 'or', 'not', etc. are tokens in C++, although in C 13 | these are macros defined by */ 14 | /* "xor"; */ 15 | #if 1 and 2 or not 3 16 | str( xor); 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /test-t/n_token.t: -------------------------------------------------------------------------------- 1 | /* n_token.t: special pp-token in C++ */ 2 | 3 | #define str( a) xstr( a) 4 | #define xstr( a) # a 5 | #define paste( a, b) a ## b 6 | 7 | /* token.1: '::' is a token in C++, although illegal token sequence 8 | in C */ 9 | /* "::"; */ 10 | str( paste( :, :)); 11 | 12 | /* token.2: 'and', 'or', 'not', etc. are tokens in C++, although in C 13 | these are macros defined by */ 14 | /* "xor"; */ 15 | #if 1 and 2 or not 3 16 | str( xor); 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /test-t/n_ucn1.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-t/n_ucn1.cc -------------------------------------------------------------------------------- /test-t/n_ucn1.t: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-t/n_ucn1.t -------------------------------------------------------------------------------- /test-t/n_ucn2.t: -------------------------------------------------------------------------------- 1 | /* n_ucn2.t: Universal-character-name */ 2 | 3 | /* UCN in pp-number */ 4 | 5 | #define mkint( a) a ## 1\u5B57 6 | 7 | int mkint( abc) = 0; /* int abc1\u5B57 = 0; */ 8 | 9 | -------------------------------------------------------------------------------- /test-t/n_vargs.t: -------------------------------------------------------------------------------- 1 | /* n_vargs.t: Macro of variable arguments */ 2 | /* from C99 Standard 6.10.3 Examples */ 3 | #define debug( ...) fprintf( stderr, __VA_ARGS__) 4 | #define showlist( ...) puts( #__VA_ARGS__) 5 | #define report( test, ...) ((test) ? puts( #test) \ 6 | : printf( __VA_ARGS__)) 7 | { 8 | /* fprintf( stderr, "Flag"); */ 9 | debug( "Flag"); 10 | /* fprintf( stderr, "X = %d\n", x); */ 11 | debug( "X = %d\n", x); 12 | /* puts( "The first, second, and third items."); */ 13 | showlist( The first, second, and third items.); 14 | /* ((x>y) ? puts( "x>y") : printf( "x is %d but y is %d", x, y)); */ 15 | report( x>y, "x is %d but y is %d", x, y); 16 | } 17 | 18 | -------------------------------------------------------------------------------- /test-t/nest1.h: -------------------------------------------------------------------------------- 1 | /* nest1.h */ 2 | 3 | nest = 1; 4 | 5 | #include "nest2.h" 6 | -------------------------------------------------------------------------------- /test-t/nest10.h: -------------------------------------------------------------------------------- 1 | /* nest10.h */ 2 | #include "nest11.h" 3 | -------------------------------------------------------------------------------- /test-t/nest11.h: -------------------------------------------------------------------------------- 1 | /* nest11.h */ 2 | #include "nest12.h" 3 | -------------------------------------------------------------------------------- /test-t/nest12.h: -------------------------------------------------------------------------------- 1 | /* nest12.h */ 2 | #include "nest13.h" 3 | -------------------------------------------------------------------------------- /test-t/nest13.h: -------------------------------------------------------------------------------- 1 | /* nest13.h */ 2 | #include "nest14.h" 3 | -------------------------------------------------------------------------------- /test-t/nest14.h: -------------------------------------------------------------------------------- 1 | /* nest14.h */ 2 | #include "nest15.h" 3 | -------------------------------------------------------------------------------- /test-t/nest15.h: -------------------------------------------------------------------------------- 1 | /* nest15.h */ 2 | #ifdef X0F 3 | nest = 0x0f; 4 | #endif 5 | -------------------------------------------------------------------------------- /test-t/nest2.h: -------------------------------------------------------------------------------- 1 | /* nest2.h */ 2 | 3 | nest = 2; 4 | 5 | #include "nest3.h" 6 | -------------------------------------------------------------------------------- /test-t/nest3.h: -------------------------------------------------------------------------------- 1 | /* nest3.h */ 2 | 3 | nest = 3; 4 | 5 | #include "nest4.h" 6 | -------------------------------------------------------------------------------- /test-t/nest4.h: -------------------------------------------------------------------------------- 1 | /* nest4.h */ 2 | 3 | nest = 4; 4 | 5 | #include "nest5.h" 6 | -------------------------------------------------------------------------------- /test-t/nest5.h: -------------------------------------------------------------------------------- 1 | /* nest5.h */ 2 | 3 | nest = 5; 4 | 5 | #include "nest6.h" 6 | -------------------------------------------------------------------------------- /test-t/nest6.h: -------------------------------------------------------------------------------- 1 | /* nest6.h */ 2 | 3 | nest = 6; 4 | 5 | #include "nest7.h" 6 | -------------------------------------------------------------------------------- /test-t/nest7.h: -------------------------------------------------------------------------------- 1 | /* nest7.h */ 2 | 3 | nest = 7; 4 | 5 | #include "nest8.h" 6 | -------------------------------------------------------------------------------- /test-t/nest8.h: -------------------------------------------------------------------------------- 1 | /* nest8.h */ 2 | 3 | nest = 8; 4 | #ifndef X8 5 | #include "nest9.h" 6 | #endif 7 | 8 | -------------------------------------------------------------------------------- /test-t/nest9.h: -------------------------------------------------------------------------------- 1 | /* nest9.h */ 2 | #include "nest10.h" 3 | -------------------------------------------------------------------------------- /test-t/pragmas.h: -------------------------------------------------------------------------------- 1 | /* pragmas.h based on the proposal to C99 by Bill Homer */ 2 | 3 | #if defined(Machine_A) 4 | /* Request fastest calling sequence for machine A */ 5 | # define Fast_call \ 6 | _Pragma("fast_call") 7 | #elif defined(Machine_B) 8 | /* Request fastest calling sequence for machine B */ 9 | # define Fast_call \ 10 | _Pragma("vfunction") 11 | #else 12 | # define Fast_call 13 | #endif 14 | 15 | #if defined(Machine_B) 16 | /* Vectorization hint (ignore vector dependencies) */ 17 | # define Independent _Pragma("ivdep") 18 | #elif defined(Machine_C) 19 | /* Parallelization hint (iterations are independent) */ 20 | # define Independent _Pragma("independent") 21 | #else 22 | # define Independent 23 | #endif 24 | 25 | -------------------------------------------------------------------------------- /test-t/recurs.t: -------------------------------------------------------------------------------- 1 | /* recurs.t: recursive macro */ 2 | /* The sample posted to comp.std.c by B. Stroustrap. */ 3 | 4 | #define NIL(xxx) xxx 5 | #define G_0(arg) NIL(G_1)(arg) 6 | #define G_1(arg) NIL(arg) 7 | 8 | G_0(42) 9 | 10 | /* 11 | * Note by kmatsui: 12 | * There are two interpretations on the Standard's specification. 13 | * (1) This macro should be expanded to 'NIL(42)'. 14 | * (2) This macro should be expanded to '42'. 15 | * The Standard's wording seems to justify the (1). 16 | * GCC, Visual C++ and other major implementations, however, expand 17 | * this macro as (2). 18 | * MCPP V.2.4.1 or later of Standard mode expands this as (1) by default, 19 | * and expands as (2) when invoked with -@compat option. 20 | */ 21 | 22 | -------------------------------------------------------------------------------- /test-t/u_1_1.t: -------------------------------------------------------------------------------- 1 | /* u_1_1.t: Undefined behaviors on unterminated line, comment or macro. */ 2 | 3 | /* u.1.1: End of a source file without . */ 4 | #include "unbal3.h" 5 | int e_1; 6 | 7 | /* u.1.2: End of a source file with . */ 8 | #include "unbal4.h" 9 | ; 10 | 11 | /* u.1.3: End of a source file with an unterminated comment. */ 12 | #include "unbal5.h" 13 | */ 14 | 15 | /* u.1.4: End of a source file with an uncompleted macro call. */ 16 | #include "unbal6.h" 17 | y); 18 | 19 | -------------------------------------------------------------------------------- /test-t/u_1_11.t: -------------------------------------------------------------------------------- 1 | /* u_1_11.t: Undefined behaviors on undefined #include syntax or header- 2 | name. */ 3 | 4 | /* u.1.11: Header-name containing ', ", \ or "/*". */ 5 | /* Probably illegal filename and fails to open. */ 6 | #include "../*line.h" 7 | /* \ is a legal path-delimiter in MS-DOS or some other OS's. */ 8 | #include "..\test-t\line.h" 9 | 10 | -------------------------------------------------------------------------------- /test-t/u_1_12.t: -------------------------------------------------------------------------------- 1 | /* u_1_12.t: Undefined behaviors on undefined #include syntax or header- 2 | name. */ 3 | 4 | /* u.1.12: Argument of #include other than header-name. */ 5 | #include filename 6 | 7 | -------------------------------------------------------------------------------- /test-t/u_1_13.t: -------------------------------------------------------------------------------- 1 | /* u_1_13.t: Undefined behaviors on undefined #include syntax or header- 2 | name. */ 3 | 4 | /* u.1.13: Excessive argument in #include directive. */ 5 | #include Junk 6 | 7 | -------------------------------------------------------------------------------- /test-t/u_1_14.t: -------------------------------------------------------------------------------- 1 | /* u_1_14.t: Undefined behaviors on undefined #line syntax. */ 2 | 3 | /* u.1.14: #line directive without an argument of line number. */ 4 | #line "filename" 5 | 6 | /* u.1.15: #line directive with the second argument of other than string 7 | literal. */ 8 | #line 1234 filename 9 | 10 | /* u.1.16: Excessive argument in #line directive. */ 11 | #line 2345 "filename" Junk 12 | 13 | /* 14; "u_1_14.t"; or other undefined results. */ 14 | __LINE__; __FILE__; 15 | 16 | -------------------------------------------------------------------------------- /test-t/u_1_25.t: -------------------------------------------------------------------------------- 1 | /* u_1_25.t: Miscelaneous undefined macros. */ 2 | 3 | #define str( a) # a 4 | #define sub( x, y) (x - y) 5 | #define SUB sub 6 | 7 | /* u.1.25: Macro argument otherwise parsed as a directive. */ 8 | /* "#define NAME"; or other undefined behaviour. */ 9 | str( 10 | #define NAME 11 | ); 12 | 13 | #if 0 /* Added by C90: Corrigendum 1 (1994) and deleted by C99 */ 14 | /* u.1.26: Expanded macro replacement list end with name of function-like 15 | macro. */ 16 | SUB( a, b); 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /test-t/u_1_27.t: -------------------------------------------------------------------------------- 1 | /* u_1_27.t: Pseudo-directive-line. */ 2 | 3 | /* u.1.27: Unknown preprocessing directive (other than #pragma). */ 4 | #ifdefined MACRO 5 | #endif /* The second error. */ 6 | 7 | -------------------------------------------------------------------------------- /test-t/u_1_28.t: -------------------------------------------------------------------------------- 1 | /* u_1_28.t: Macro expanding to name identical to directive. */ 2 | 3 | #define D define 4 | /* u.1.28: There are following two ways of preprocessing. 5 | 1: "D" isn't expanded, because # is the first token of the line. 6 | Preprocessor reports that "D" is an unknown directive. 7 | 2: "D" is expanded, because that is not a directive. 8 | Compiler-phase will diagnose the output of preprocess. 9 | Anyway, preprocessor should not interprete this line as a preprocessing 10 | directive. 11 | */ 12 | #D A B 13 | 14 | -------------------------------------------------------------------------------- /test-t/u_1_5.t: -------------------------------------------------------------------------------- 1 | /* u_1_5.t: Undefined behaviors on illegal characters. */ 2 | 3 | /* u.1.5: Illegal characters (in other than string literal, character 4 | constant, header-name or comment). */ 5 | #if 1 ||2 6 | /* 0x1e ^ ^ 0x1f */ 7 | #endif /* Maybe the second error. */ 8 | 9 | /* u.1.6: [VT], [FF] in directive line. */ 10 | #if 1 || 2 11 | /* [VT] ^ ^ [FF] */ 12 | #endif /* Maybe the second error. */ 13 | 14 | -------------------------------------------------------------------------------- /test-t/u_1_7_big5.t: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-t/u_1_7_big5.t -------------------------------------------------------------------------------- /test-t/u_1_7_eucjp.t: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-t/u_1_7_eucjp.t -------------------------------------------------------------------------------- /test-t/u_1_7_gb.t: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-t/u_1_7_gb.t -------------------------------------------------------------------------------- /test-t/u_1_7_jis.t: -------------------------------------------------------------------------------- 1 | /* u_1_7_jis.t: Invalid multi-byte character sequence (in string literal, 2 | character constant, header-name or comment). */ 3 | 4 | #define str( a) # a 5 | #pragma __setlocale( "jis") /* For MCPP */ 6 | 7 | str( "$B1 (B"); /* 0x3120 */ 8 | 9 | -------------------------------------------------------------------------------- /test-t/u_1_7_ksc.t: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-t/u_1_7_ksc.t -------------------------------------------------------------------------------- /test-t/u_1_7_sjis.t: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-t/u_1_7_sjis.t -------------------------------------------------------------------------------- /test-t/u_1_7_utf8.t: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ned14/mcpp/4787481564c5be03306be32483fab020ec93e409/test-t/u_1_7_utf8.t -------------------------------------------------------------------------------- /test-t/u_1_8.t: -------------------------------------------------------------------------------- 1 | /* u_1_8.t: Undefined behaviors on unterminated quotations (1). */ 2 | 3 | /* u.1.8: Unterminated character constant. */ 4 | /* The following "comment" may not interpreted as a comment but swallowed by 5 | the unterminated character constant. */ 6 | #error I can't understand. /* Token error prior to execution of #error. */ 7 | 8 | -------------------------------------------------------------------------------- /test-t/u_1_9.t: -------------------------------------------------------------------------------- 1 | /* u_1_8.t: Undefined behaviors on unterminated quotations (2). */ 2 | 3 | /* u.1.9: Unterminated string literal. */ 4 | "String literal 5 | across the lines. 6 | " 7 | 8 | /* u.1.10: Unterminated header-name. */ 9 | #include 6 | #include 7 | 8 | /* 9 | * , might have the line 10 | * #pragma once 11 | * near the beginning. 12 | */ 13 | -------------------------------------------------------------------------------- /tests/after_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ## ./after_test.sh $CC $gcc_path $cpp_call $target_cc 3 | 4 | CC=$1 5 | gcc_path=`expr $2 : "\(.*\)/${CC}\$"` 6 | target_cc=$4 7 | if test x$target_cc != x; then 8 | CC=$target_cc 9 | fi 10 | cpp_name=`echo $3 | sed 's,.*/,,'` 11 | cpp_path=`echo $3 | sed "s,/$cpp_name,,"` 12 | 13 | echo " cd $cpp_path" 14 | cd "$cpp_path" 15 | echo " removing '-23j' options from mcpp invocation" 16 | for i in mcpp*.sh 17 | do 18 | cat $i | sed 's/mcpp -23j/mcpp/' > tmp 19 | mv -f tmp $i 20 | chmod a+x $i 21 | done 22 | 23 | if test $CC = gcc; then 24 | exit 0 25 | fi 26 | 27 | echo " cd $gcc_path" 28 | cd "$gcc_path" 29 | echo " rm gcc" 30 | rm gcc 31 | if test -f "gcc.save"; then 32 | echo " mv gcc.save gcc" 33 | mv gcc.save gcc 34 | fi 35 | -------------------------------------------------------------------------------- /tool/LICENSE: -------------------------------------------------------------------------------- 1 | Redistribution and use of the files under this directory in source and 2 | binary forms, with or without modification, are freely permitted. 3 | [Kiyoshi Matsui] 4 | -------------------------------------------------------------------------------- /tool/app_once.bat: -------------------------------------------------------------------------------- 1 | REM append once.txt to header files in the current directory 2 | REM 3 | FOR %%f IN ( *.H ) DO copy %%f+once.txt 4 | -------------------------------------------------------------------------------- /tool/once.txt: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | --------------------------------------------------------------------------------