scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit eb80c90a72ca9b4cd2f035c98897332f9181f661
parent f264d340ebf98ea1b194567fbf7d79318c8e718f
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sun, 18 Feb 2018 00:51:17 +0100

Merge branch 'master' of ssh://simple-cc.org/var/gitrepos/scc

Diffstat:
M.gitignore | 3++-
MMakefile | 13++++---------
Mar/Makefile | 11+++++++----
Mar/main.c | 677+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
Mar/posix/stat.h | 1+
Mas/Makefile | 13+++++++------
Mas/main.c | 2+-
Mas/test.sh | 2+-
Mcc1/Makefile | 16+++++++++-------
Mcc2/Makefile | 15++++++++-------
Mconfig.mk.def | 28----------------------------
Aconfigure | 15+++++++++++++++
Mdriver/Makefile | 5+++--
Mdriver/posix/Makefile | 25+++++++++++++------------
Mdriver/posix/cpp.sh | 4++--
Mdriver/posix/scc.c | 38++++++++++++++++++++++++++------------
Minc/Makefile | 4+++-
Minc/ar.h | 31++++++++++++-------------------
Mlib/Makefile | 12++++--------
Mlib/c/Makefile | 2+-
Mlib/c/target/Makefile | 4+++-
Mlib/c/target/amd64-sysv-linux-elf/Makefile | 4+++-
Mlib/c/target/amd64-sysv-openbsd-elf/Makefile | 4+++-
Mlib/c/target/i386-sysv-linux-elf/Makefile | 4+++-
Mlib/c/target/z80-scc-none-none/Makefile | 4+++-
Mlib/crt/Makefile | 4+++-
Mlib/scc/Makefile | 11++++++-----
Mlib/scc/libdep.mk | 2--
Dlib/scc/rar.c | 33---------------------------------
Dlib/scc/war.c | 38--------------------------------------
Mlib/sys/Makefile | 6++++--
Mlib/sys/common.mk | 6++++--
Mlib/sys/libsys.mk | 4+++-
Mnm/Makefile | 9+++++----
Mnm/main.c | 8++++++--
Mobjdump/Makefile | 9+++++----
Arules.mk | 27+++++++++++++++++++++++++++
Mtests/Makefile | 11++++++++---
Atests/ar/Makefile | 7+++++++
Atests/ar/error/Makefile | 3+++
Atests/ar/execute/Makefile | 12++++++++++++
Atests/ar/execute/chktest.sh | 93+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dtests/execute/0136-if.c | 21---------------------
Dtests/execute/0137-int-cast.c | 273-------------------------------------------------------------------------------
Dtests/execute/0138-namespace.c | 30------------------------------
Dtests/execute/0139-ptr-ary.c | 22----------------------
Dtests/execute/0140-int-fold.c | 27---------------------------
Dtests/execute/0141-int-iden.c | 37-------------------------------------
Dtests/execute/0142-char-const.c | 40----------------------------------------
Dtests/execute/0143-int-const.c | 24------------------------
Dtests/execute/0144-long-const.c | 25-------------------------
Dtests/execute/0145-llong-const.c | 23-----------------------
Dtests/execute/0146-ifdef.c | 52----------------------------------------------------
Dtests/execute/0147-intern-cpp.c | 19-------------------
Dtests/execute/0148-cpp-string.c | 10----------
Dtests/execute/0149-define.c | 10----------
Dtests/execute/0150-define.c | 15---------------
Dtests/execute/0151-vararg.c | 25-------------------------
Dtests/execute/0152-cat.c | 14--------------
Dtests/execute/0153-cpp-string.c | 13-------------
Dtests/execute/0154-if-defined | 15---------------
Dtests/execute/0155-struct-compl.c | 16----------------
Dtests/execute/0156-duff2.c | 35-----------------------------------
Dtests/execute/0157-list.c | 14--------------
Dtests/execute/0158-ternary.c | 17-----------------
Dtests/execute/0159-typedef.c | 24------------------------
Dtests/execute/0160-cpp-if.c | 17-----------------
Dtests/execute/0161-struct.c | 12------------
Dtests/execute/0162-array.c | 13-------------
Dtests/execute/0163-array.c | 16----------------
Dtests/execute/0164-struct.c | 12------------
Dtests/execute/0165-struct.c | 33---------------------------------
Dtests/execute/0166-desig.c | 18------------------
Dtests/execute/0167-array.c | 15---------------
Dtests/execute/0168-array.c | 16----------------
Dtests/execute/0169-string.c | 27---------------------------
Dtests/execute/0170-line.c | 13-------------
Dtests/execute/0171-macros.c | 10----------
Dtests/execute/0172-hexa.c | 10----------
Dtests/execute/0173-macro.c | 13-------------
Dtests/execute/0174-decay.c | 24------------------------
Dtests/execute/0175-defined.c | 32--------------------------------
Dtests/execute/0176-macro.c | 21---------------------
Dtests/execute/Makefile | 12------------
Dtests/execute/README | 2--
Dtests/execute/chktest.sh | 18------------------
Dtests/execute/compose.sh | 23-----------------------
Dtests/execute/include/0062-include.h | 5-----
Dtests/execute/include/0062-include2.h | 2--
Dtests/execute/scc-tests.lst | 169-------------------------------------------------------------------------------
Dtests/execute/sysinclude/0064-sysinclude.h | 4----
Dtests/execute/sysinclude/0064-sysinclude2.h | 1-
Atests/scc/Makefile | 7+++++++
Rtests/error/0001-sanity.c -> tests/scc/error/0001-sanity.c | 0
Rtests/error/0002-missinginclude.c -> tests/scc/error/0002-missinginclude.c | 0
Rtests/error/0003-junkinclude.c -> tests/scc/error/0003-junkinclude.c | 0
Rtests/error/0004-macroredef.c -> tests/scc/error/0004-macroredef.c | 0
Rtests/error/0005-fmacro.c -> tests/scc/error/0005-fmacro.c | 0
Rtests/error/0006-endif.c -> tests/scc/error/0006-endif.c | 0
Rtests/error/0007-unmatchedcppif.c -> tests/scc/error/0007-unmatchedcppif.c | 0
Rtests/error/0008-unmatchedcppelse.c -> tests/scc/error/0008-unmatchedcppelse.c | 0
Rtests/error/0009-unmatchedcppelif.c -> tests/scc/error/0009-unmatchedcppelif.c | 0
Rtests/error/0010-extraelif.c -> tests/scc/error/0010-extraelif.c | 0
Rtests/error/0011-extraelse.c -> tests/scc/error/0011-extraelse.c | 0
Rtests/error/0012-ifnoexpr.c -> tests/scc/error/0012-ifnoexpr.c | 0
Rtests/error/0013-macro.c -> tests/scc/error/0013-macro.c | 0
Rtests/error/0014-macro.c -> tests/scc/error/0014-macro.c | 0
Rtests/error/0015-macro.c -> tests/scc/error/0015-macro.c | 0
Rtests/error/0016-arrayinitsize.c -> tests/scc/error/0016-arrayinitsize.c | 0
Rtests/error/0017-duplicatefunc.c -> tests/scc/error/0017-duplicatefunc.c | 0
Rtests/error/0018-voidparam.c -> tests/scc/error/0018-voidparam.c | 0
Rtests/error/0019-kr_names.c -> tests/scc/error/0019-kr_names.c | 0
Rtests/error/0020-storage.c -> tests/scc/error/0020-storage.c | 0
Rtests/error/0021-namespace.c -> tests/scc/error/0021-namespace.c | 0
Rtests/error/0021-void.c -> tests/scc/error/0021-void.c | 0
Rtests/error/0022-cpp-if.c -> tests/scc/error/0022-cpp-if.c | 0
Rtests/error/0023-include.c -> tests/scc/error/0023-include.c | 0
Rtests/error/0023-include.h -> tests/scc/error/0023-include.h | 0
Rtests/error/Makefile -> tests/scc/error/Makefile | 0
Rtests/error/README -> tests/scc/error/README | 0
Rtests/error/chktest.sh -> tests/scc/error/chktest.sh | 0
Rtests/error/scc-tests.lst -> tests/scc/error/scc-tests.lst | 0
Rtests/error/update.sh -> tests/scc/error/update.sh | 0
Rtests/execute/0001-sanity.c -> tests/scc/execute/0001-sanity.c | 0
Rtests/execute/0002-expr.c -> tests/scc/execute/0002-expr.c | 0
Rtests/execute/0003-local.c -> tests/scc/execute/0003-local.c | 0
Rtests/execute/0004-pointer.c -> tests/scc/execute/0004-pointer.c | 0
Rtests/execute/0005-ifstmt.c -> tests/scc/execute/0005-ifstmt.c | 0
Rtests/execute/0006-whilestmt.c -> tests/scc/execute/0006-whilestmt.c | 0
Rtests/execute/0007-forstmt.c -> tests/scc/execute/0007-forstmt.c | 0
Rtests/execute/0008-dowhilestmt.c -> tests/scc/execute/0008-dowhilestmt.c | 0
Rtests/execute/0009-expr.c -> tests/scc/execute/0009-expr.c | 0
Rtests/execute/0010-goto.c -> tests/scc/execute/0010-goto.c | 0
Rtests/execute/0011-assign.c -> tests/scc/execute/0011-assign.c | 0
Rtests/execute/0012-expr.c -> tests/scc/execute/0012-expr.c | 0
Rtests/execute/0013-addridx.c -> tests/scc/execute/0013-addridx.c | 0
Rtests/execute/0014-assignidx.c -> tests/scc/execute/0014-assignidx.c | 0
Rtests/execute/0015-localarray.c -> tests/scc/execute/0015-localarray.c | 0
Rtests/execute/0016-addrarray.c -> tests/scc/execute/0016-addrarray.c | 0
Rtests/execute/0017-struct.c -> tests/scc/execute/0017-struct.c | 0
Rtests/execute/0018-structptr.c -> tests/scc/execute/0018-structptr.c | 0
Rtests/execute/0019-selfrefstruct.c -> tests/scc/execute/0019-selfrefstruct.c | 0
Rtests/execute/0020-ptrptr.c -> tests/scc/execute/0020-ptrptr.c | 0
Rtests/execute/0021-intfunc.c -> tests/scc/execute/0021-intfunc.c | 0
Rtests/execute/0022-typedef.c -> tests/scc/execute/0022-typedef.c | 0
Rtests/execute/0023-global.c -> tests/scc/execute/0023-global.c | 0
Rtests/execute/0024-typedefstruct.c -> tests/scc/execute/0024-typedefstruct.c | 0
Rtests/execute/0025-string.c -> tests/scc/execute/0025-string.c | 0
Rtests/execute/0026-implicitret.c -> tests/scc/execute/0026-implicitret.c | 0
Rtests/execute/0027-charval.c -> tests/scc/execute/0027-charval.c | 0
Rtests/execute/0028-bor.c -> tests/scc/execute/0028-bor.c | 0
Rtests/execute/0029-band.c -> tests/scc/execute/0029-band.c | 0
Rtests/execute/0030-bxor.c -> tests/scc/execute/0030-bxor.c | 0
Rtests/execute/0031-relop.c -> tests/scc/execute/0031-relop.c | 0
Rtests/execute/0032-indec.c -> tests/scc/execute/0032-indec.c | 0
Rtests/execute/0033-ptrindec.c -> tests/scc/execute/0033-ptrindec.c | 0
Rtests/execute/0034-logandor.c -> tests/scc/execute/0034-logandor.c | 0
Rtests/execute/0035-breakcont.c -> tests/scc/execute/0035-breakcont.c | 0
Rtests/execute/0036-notneg.c -> tests/scc/execute/0036-notneg.c | 0
Rtests/execute/0037-assignop.c -> tests/scc/execute/0037-assignop.c | 0
Rtests/execute/0038-ptradd.c -> tests/scc/execute/0038-ptradd.c | 0
Rtests/execute/0039-sizeof.c -> tests/scc/execute/0039-sizeof.c | 0
Rtests/execute/0040-cast.c -> tests/scc/execute/0040-cast.c | 0
Rtests/execute/0041-queen.c -> tests/scc/execute/0041-queen.c | 0
Rtests/execute/0042-prime.c -> tests/scc/execute/0042-prime.c | 0
Rtests/execute/0043-union.c -> tests/scc/execute/0043-union.c | 0
Rtests/execute/0044-struct.c -> tests/scc/execute/0044-struct.c | 0
Rtests/execute/0045-struct.c -> tests/scc/execute/0045-struct.c | 0
Rtests/execute/0046-inits.c -> tests/scc/execute/0046-inits.c | 0
Rtests/execute/0047-anonexport.c -> tests/scc/execute/0047-anonexport.c | 0
Rtests/execute/0048-inits.c -> tests/scc/execute/0048-inits.c | 0
Rtests/execute/0049-inits.c -> tests/scc/execute/0049-inits.c | 0
Rtests/execute/0050-inits.c -> tests/scc/execute/0050-inits.c | 0
Rtests/execute/0051-inits.c -> tests/scc/execute/0051-inits.c | 0
Rtests/execute/0052-switch.c -> tests/scc/execute/0052-switch.c | 0
Rtests/execute/0053-struct.c -> tests/scc/execute/0053-struct.c | 0
Rtests/execute/0054-struct.c -> tests/scc/execute/0054-struct.c | 0
Rtests/execute/0055-enum.c -> tests/scc/execute/0055-enum.c | 0
Rtests/execute/0056-enum.c -> tests/scc/execute/0056-enum.c | 0
Rtests/execute/0057-duff.c -> tests/scc/execute/0057-duff.c | 0
Rtests/execute/0058-bug.c -> tests/scc/execute/0058-bug.c | 0
Rtests/execute/0059-multistring.c -> tests/scc/execute/0059-multistring.c | 0
Rtests/execute/0060-charlit.c -> tests/scc/execute/0060-charlit.c | 0
Rtests/execute/0061-comments.c -> tests/scc/execute/0061-comments.c | 0
Rtests/execute/0062-include.c -> tests/scc/execute/0062-include.c | 0
Rtests/execute/0063-define.c -> tests/scc/execute/0063-define.c | 0
Rtests/execute/0064-sysinclude.c -> tests/scc/execute/0064-sysinclude.c | 0
Rtests/execute/0065-ifdef.c -> tests/scc/execute/0065-ifdef.c | 0
Rtests/execute/0066-cppelse.c -> tests/scc/execute/0066-cppelse.c | 0
Rtests/execute/0067-define.c -> tests/scc/execute/0067-define.c | 0
Rtests/execute/0068-funclikemacro.c -> tests/scc/execute/0068-funclikemacro.c | 0
Rtests/execute/0069-funclikemacro.c -> tests/scc/execute/0069-funclikemacro.c | 0
Rtests/execute/0070-cppif.c -> tests/scc/execute/0070-cppif.c | 0
Rtests/execute/0071-cppelif.c -> tests/scc/execute/0071-cppelif.c | 0
Rtests/execute/0072-cppelif.c -> tests/scc/execute/0072-cppelif.c | 0
Rtests/execute/0073-ifndef.c -> tests/scc/execute/0073-ifndef.c | 0
Rtests/execute/0074-undef.c -> tests/scc/execute/0074-undef.c | 0
Rtests/execute/0075-ptraddasn.c -> tests/scc/execute/0075-ptraddasn.c | 0
Rtests/execute/0076-ptrsubasn.c -> tests/scc/execute/0076-ptrsubasn.c | 0
Rtests/execute/0077-defined.c -> tests/scc/execute/0077-defined.c | 0
Rtests/execute/0078-dirifexpr.c -> tests/scc/execute/0078-dirifexpr.c | 0
Rtests/execute/0079-cond.c -> tests/scc/execute/0079-cond.c | 0
Rtests/execute/0080-arrays.c -> tests/scc/execute/0080-arrays.c | 0
Rtests/execute/0081-calls.c -> tests/scc/execute/0081-calls.c | 0
Rtests/execute/0082-bug.c -> tests/scc/execute/0082-bug.c | 0
Rtests/execute/0083-voidret.c -> tests/scc/execute/0083-voidret.c | 0
Rtests/execute/0084-longlong.c -> tests/scc/execute/0084-longlong.c | 0
Rtests/execute/0085-ulonglong.c -> tests/scc/execute/0085-ulonglong.c | 0
Rtests/execute/0086-variadic.c -> tests/scc/execute/0086-variadic.c | 0
Rtests/execute/0087-variadic.c -> tests/scc/execute/0087-variadic.c | 0
Rtests/execute/0088-macros.c -> tests/scc/execute/0088-macros.c | 0
Rtests/execute/0089-short.c -> tests/scc/execute/0089-short.c | 0
Rtests/execute/0090-fptr.c -> tests/scc/execute/0090-fptr.c | 0
Rtests/execute/0091-fptr.c -> tests/scc/execute/0091-fptr.c | 0
Rtests/execute/0092-fptr.c -> tests/scc/execute/0092-fptr.c | 0
Rtests/execute/0093-arrayinit.c -> tests/scc/execute/0093-arrayinit.c | 0
Rtests/execute/0094-arrayinit.c -> tests/scc/execute/0094-arrayinit.c | 0
Rtests/execute/0095-arrayselector.c -> tests/scc/execute/0095-arrayselector.c | 0
Rtests/execute/0096-inferredarraysize.c -> tests/scc/execute/0096-inferredarraysize.c | 0
Rtests/execute/0097-extern.c -> tests/scc/execute/0097-extern.c | 0
Rtests/execute/0098-tentative.c -> tests/scc/execute/0098-tentative.c | 0
Rtests/execute/0099-tentative.c -> tests/scc/execute/0099-tentative.c | 0
Rtests/execute/0100-redeclaremacro.c -> tests/scc/execute/0100-redeclaremacro.c | 0
Rtests/execute/0101-wcharlit.c -> tests/scc/execute/0101-wcharlit.c | 0
Rtests/execute/0102-bug.c -> tests/scc/execute/0102-bug.c | 0
Rtests/execute/0103-voidparm.c -> tests/scc/execute/0103-voidparm.c | 0
Rtests/execute/0104-qbebug.c -> tests/scc/execute/0104-qbebug.c | 0
Rtests/execute/0105-shl.c -> tests/scc/execute/0105-shl.c | 0
Rtests/execute/0106-ppcast.c -> tests/scc/execute/0106-ppcast.c | 0
Rtests/execute/0107-bnot.c -> tests/scc/execute/0107-bnot.c | 0
Rtests/execute/0108-bug.c -> tests/scc/execute/0108-bug.c | 0
Rtests/execute/0109-struct.c -> tests/scc/execute/0109-struct.c | 0
Rtests/execute/0110-typedefcast.c -> tests/scc/execute/0110-typedefcast.c | 0
Rtests/execute/0111-doubledef.c -> tests/scc/execute/0111-doubledef.c | 0
Rtests/execute/0112-cond.c -> tests/scc/execute/0112-cond.c | 0
Rtests/execute/0113-externredecl.c -> tests/scc/execute/0113-externredecl.c | 0
Rtests/execute/0114-shortassig.c -> tests/scc/execute/0114-shortassig.c | 0
Rtests/execute/0115-null-comparision.c -> tests/scc/execute/0115-null-comparision.c | 0
Rtests/execute/0116-floatcmp.c -> tests/scc/execute/0116-floatcmp.c | 0
Rtests/execute/0117-pointarith.c -> tests/scc/execute/0117-pointarith.c | 0
Rtests/execute/0118-voidmain.c -> tests/scc/execute/0118-voidmain.c | 0
Rtests/execute/0119-macrostr.c -> tests/scc/execute/0119-macrostr.c | 0
Rtests/execute/0120-funpar.c -> tests/scc/execute/0120-funpar.c | 0
Rtests/execute/0121-localinit.c -> tests/scc/execute/0121-localinit.c | 0
Rtests/execute/0122-localinit.c -> tests/scc/execute/0122-localinit.c | 0
Rtests/execute/0123-doubleconst.c -> tests/scc/execute/0123-doubleconst.c | 0
Rtests/execute/0124-enumstruct.c -> tests/scc/execute/0124-enumstruct.c | 0
Rtests/execute/0125-fundcl.c -> tests/scc/execute/0125-fundcl.c | 0
Rtests/execute/0126-macropar.c -> tests/scc/execute/0126-macropar.c | 0
Rtests/execute/0127-doublecte.c -> tests/scc/execute/0127-doublecte.c | 0
Rtests/execute/0128-kr_names.c -> tests/scc/execute/0128-kr_names.c | 0
Rtests/execute/0129-initi.c -> tests/scc/execute/0129-initi.c | 0
Rtests/execute/0130-mulpars.c -> tests/scc/execute/0130-mulpars.c | 0
Rtests/execute/0131-hello.c -> tests/scc/execute/0131-hello.c | 0
Rtests/execute/0132-forward.c -> tests/scc/execute/0132-forward.c | 0
Rtests/execute/0133-ftn-ptr.c -> tests/scc/execute/0133-ftn-ptr.c | 0
Rtests/execute/0134-arith.c -> tests/scc/execute/0134-arith.c | 0
Rtests/execute/0135-unary.c -> tests/scc/execute/0135-unary.c | 0
Atests/scc/execute/0136-if.c | 21+++++++++++++++++++++
Atests/scc/execute/0137-int-cast.c | 273+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atests/scc/execute/0138-namespace.c | 30++++++++++++++++++++++++++++++
Atests/scc/execute/0139-ptr-ary.c | 22++++++++++++++++++++++
Atests/scc/execute/0140-int-fold.c | 27+++++++++++++++++++++++++++
Atests/scc/execute/0141-int-iden.c | 37+++++++++++++++++++++++++++++++++++++
Atests/scc/execute/0142-char-const.c | 40++++++++++++++++++++++++++++++++++++++++
Atests/scc/execute/0143-int-const.c | 24++++++++++++++++++++++++
Atests/scc/execute/0144-long-const.c | 25+++++++++++++++++++++++++
Atests/scc/execute/0145-llong-const.c | 23+++++++++++++++++++++++
Atests/scc/execute/0146-ifdef.c | 52++++++++++++++++++++++++++++++++++++++++++++++++++++
Atests/scc/execute/0147-intern-cpp.c | 19+++++++++++++++++++
Atests/scc/execute/0148-cpp-string.c | 10++++++++++
Atests/scc/execute/0149-define.c | 10++++++++++
Atests/scc/execute/0150-define.c | 15+++++++++++++++
Atests/scc/execute/0151-vararg.c | 25+++++++++++++++++++++++++
Atests/scc/execute/0152-cat.c | 14++++++++++++++
Atests/scc/execute/0153-cpp-string.c | 13+++++++++++++
Atests/scc/execute/0154-if-defined | 15+++++++++++++++
Atests/scc/execute/0155-struct-compl.c | 16++++++++++++++++
Atests/scc/execute/0156-duff2.c | 35+++++++++++++++++++++++++++++++++++
Atests/scc/execute/0157-list.c | 14++++++++++++++
Atests/scc/execute/0158-ternary.c | 17+++++++++++++++++
Atests/scc/execute/0159-typedef.c | 24++++++++++++++++++++++++
Atests/scc/execute/0160-cpp-if.c | 17+++++++++++++++++
Atests/scc/execute/0161-struct.c | 12++++++++++++
Atests/scc/execute/0162-array.c | 13+++++++++++++
Atests/scc/execute/0163-array.c | 16++++++++++++++++
Atests/scc/execute/0164-struct.c | 12++++++++++++
Atests/scc/execute/0165-struct.c | 33+++++++++++++++++++++++++++++++++
Atests/scc/execute/0166-desig.c | 18++++++++++++++++++
Atests/scc/execute/0167-array.c | 15+++++++++++++++
Atests/scc/execute/0168-array.c | 16++++++++++++++++
Atests/scc/execute/0169-string.c | 27+++++++++++++++++++++++++++
Atests/scc/execute/0170-line.c | 13+++++++++++++
Atests/scc/execute/0171-macros.c | 10++++++++++
Atests/scc/execute/0172-hexa.c | 10++++++++++
Atests/scc/execute/0173-macro.c | 13+++++++++++++
Atests/scc/execute/0174-decay.c | 24++++++++++++++++++++++++
Rtests/execute/0077-defined.c -> tests/scc/execute/0175-defined.c | 0
Atests/scc/execute/0176-macro.c | 21+++++++++++++++++++++
Atests/scc/execute/0177-literal.c | 9+++++++++
Atests/scc/execute/Makefile | 10++++++++++
Rtests/error/README -> tests/scc/execute/README | 0
Atests/scc/execute/chktest.sh | 20++++++++++++++++++++
Atests/scc/execute/compose.sh | 23+++++++++++++++++++++++
Atests/scc/execute/include/0062-include.h | 5+++++
Atests/scc/execute/include/0062-include2.h | 2++
Atests/scc/execute/scc-tests.lst | 170+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atests/scc/execute/sysinclude/0064-sysinclude.h | 4++++
Atests/scc/execute/sysinclude/0064-sysinclude2.h | 1+
309 files changed, 2288 insertions(+), 1593 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -14,8 +14,9 @@ inc/ldflags.h inc/sysincludes.h inc/syslibs.h driver/posix/config.h -driver/posix/scpp +driver/posix/cpp rootdir/ ar/ar-* nm/nm objdump/objdump +as/target/*/*tbl.c diff --git a/Makefile b/Makefile @@ -1,8 +1,9 @@ # scc - Suckless C Compiler +.POSIX: -include config.mk.def +PROJECTDIR = . -.POSIX: +include rules.mk DIRS = inc cc1 cc2 driver lib as ar nm objdump @@ -20,17 +21,11 @@ distclean: rm -rf rootdir rm -f config.mk -config.mk: - trap "rm -f $$.mk" 0 2 3; \ - (cat config.mk.def ;\ - sed -n '/^# '`uname`'/,/^$$/p' system.mk) > $$.mk && \ - mv $$.mk config.mk - dep: config.mk $(FORALL) tests: all - cd tests && $(MAKE) -e all + +cd tests && $(MAKE) -e all install: all cp -r rootdir/* $(DESTDIR)$(PREFIX)/ diff --git a/ar/Makefile b/ar/Makefile @@ -1,23 +1,26 @@ .POSIX: -LIBDIR = ../lib/scc -include ../config.mk +PROJECTDIR = .. +LIBDIR = $(PROJECTDIR)/lib/scc +include $(PROJECTDIR)/rules.mk include $(LIBDIR)/libdep.mk OBJ = main.o $(DRIVER)/stat.c MOREFLAGS = -I$(DRIVER) all: ar-$(DRIVER) + mkdir -p $(PROJECTDIR)/rootdir/bin + cp ar-$(DRIVER) $(PROJECTDIR)/rootdir/bin/ar ar-$(DRIVER): $(OBJ) $(LIBDIR)/libscc.a $(CC) $(SCC_LDFLAGS) $(OBJ) -lscc -o $@ -main.o: ../inc/scc.h ../inc/ar.h +main.o: $(PROJECTDIR)/inc/scc.h $(PROJECTDIR)/inc/ar.h $(DRIVER)/stat.o: $(DRIVER)/stat.h $(LIBDIR)/libscc.a: $(LIB-OBJ) - cd $(LIBDIR) && $(MAKE) + +cd $(LIBDIR) && $(MAKE) main.o: $(DRIVER)/stat.h diff --git a/ar/main.c b/ar/main.c @@ -1,58 +1,673 @@ static char sccsid[] = "@(#) ./ar/main.c"; #include <errno.h> +#include <signal.h> #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <time.h> #include <stat.h> -#include "../inc/scc.h" #include "../inc/ar.h" +#include "../inc/arg.h" +#include "../inc/scc.h" -int -main(int argc, char *argv[]) +char *argv0; + +static int bflag, iflag, vflag, cflag, lflag, uflag, aflag; +static char *posname, *tmpafile1, *tmpafile2; + +struct arop { + FILE *src; + FILE *dst; + FILE *tmp; + struct ar_hdr hdr; + char *fname; + long size; + long mode; + long long date; +}; + +static void +cleanup(void) +{ + if (tmpafile1) + remove(tmpafile1); + if (tmpafile2) + remove(tmpafile2); +} + +static void +sigfun(int signum) +{ + cleanup(); + exit(1); +} + +static FILE * +openar(char *afile) +{ + FILE *fp; + char magic[SARMAG+1]; + + if ((fp = fopen(afile,"r+b")) == NULL) { + if (!cflag) + fprintf(stderr, "ar: creating %s\n", afile); + if ((fp = fopen(afile, "w+b")) == NULL) { + perror("ar:opening archive"); + exit(1); + } + fputs(ARMAG, fp); + if (fflush(fp) == EOF) { + perror("ar:writing magic number"); + exit(1); + } + } else { + if (fgets(magic, sizeof(magic), fp) == NULL) { + perror("ar:error reading magic number"); + exit(1); + } + if (strcmp(magic, ARMAG)) { + fprintf(stderr, + "ar:%s:invalid magic number '%s'\n", + afile, + magic); + exit(1); + } + } + return fp; +} + +static void +archive(char *fname, FILE *to, char letter) { int c; size_t n; - FILE *fp, *arfile; - char *fname, *arname = "lib.a"; + FILE *from; + char mtime[13]; struct stat st; - struct arhdr hdr; - if ((arfile = fopen(arname, "wb")) == NULL) { - perror("ar:error opening library file"); + if (vflag) + printf("%c - %s\n", letter, fname); + if (strlen(fname) > 16) + fprintf(stderr, "ar:%s: too long name\n", fname); + if (stat(fname, &st) < 0) { + fprintf(stderr, "ar:error getting '%s' attributes\n", fname); + exit(1); + } + if ((from = fopen(fname, "rb")) == NULL) { + fprintf(stderr, + "ar:opening member '%s':%s\n", + fname, + strerror(errno)); + exit(1); + } + strftime(mtime, sizeof(mtime), "%s", gmtime(&st.st_mtime)); + fprintf(to, + "%-16.16s%-12s%-6u%-6u%-8o%-10llu`\n", + fname, + mtime, + st.st_uid, + st.st_gid, + st.st_mode, + (unsigned long long) st.st_size); + for (n = 0; (c = getc(from)) != EOF; n++) + putc(c, to); + if (n & 1) + putc('\n', to); + if (ferror(from)) { + fprintf(stderr, + "ar:reading input '%s':%s\n", + fname, strerror(errno)); + exit(1); + } + fclose(from); +} + +static void +append(FILE *fp, char *list[]) +{ + char *fname; + + if (fseek(fp, 0, SEEK_END) == EOF) { + perror("ar:seeking archive"); exit(1); } - fputs(ARMAGIC, arfile); - while ((fname = *++argv) != NULL) { - if ((n = strlen(fname)) > ARNAME_SIZ) - die("ar: %s: too long file name", fname); - if (stat(fname, &st) < 0) - goto member_error; + while ((fname = *list++) != NULL) + archive(fname, fp, 'a'); + if (fclose(fp) == EOF) { + perror("ar:error writing archive"); + exit(1); + } +} - strcpy(hdr.name, fname); - hdr.time = st.st_atime; - hdr.uid = st.st_uid; - hdr.gid = st.st_gid; - hdr.mode = st.st_mode; - hdr.size = st.st_mode; +static void +cat(FILE *src1, FILE *src2, FILE *dst) +{ + int c; - if (wrarhdr(arfile, &hdr) < 0) - goto member_error; - if (wrarfile(arfile, &hdr) < 0) - goto member_error; + while ((c = getc(src1)) != EOF) + fputc(c, dst); + while ((c = getc(src2)) != EOF) + fputc(c, dst); + if (ferror(src1) || ferror(src2) || fclose(dst) == EOF) { + perror("ar:moving files in archive"); + exit(1); } +} - if (fclose(arfile)) { - fprintf(stderr, - "ar:error writing to output file '%s':%s\n", - arname, strerror(errno)); +static void +copy(struct ar_hdr *hdr, long siz, FILE *src, FILE *dst) +{ + int c; + + fwrite(hdr, sizeof(*hdr), 1, dst); + if ((siz & 1) == 1) + siz++; + while (siz--) { + if ((c = getc(src)) == EOF) + break; + fputc(c, dst); } +} - return 0; +static void +letters(unsigned long val, char *s) +{ + *s++ = (val & 04) ? 'r' : '-'; + *s++ = (val & 02) ? 'w' : '-'; + *s++ = (val & 01) ? 'x' : '-'; +} + +static char * +perms(struct arop *op) +{ + static char buf[10]; + + letters(op->mode >> 6, buf); + letters(op->mode >> 3, buf+3); + letters(op->mode, buf +6); + buf[9] = '\0'; + + return buf; +} + +static void +rmlist(char *list[]) +{ + for (; *list; ++list) + list[0] = list[1]; +} + +static char ** +inlist(char *fname, char *list[]) +{ + while (*list && strcmp(*list, fname)) + ++list; + if (*list == NULL) + return NULL; + return list; +} + +static void +split(struct arop *op, char *files[]) +{ + char **l; + + l = inlist(op->fname, files); + if (!l) { + copy(&op->hdr, op->size, op->src, op->dst); + return; + } else { + if (vflag) + printf("m - %s\n", op->fname); + copy(&op->hdr, op->size, op->src, op->tmp); + rmlist(l); + } +} + +static void +merge(struct arop *op, char *list[]) +{ + int c; + + if (strcmp(op->fname, posname)) { + copy(&op->hdr, op->size, op->src, op->dst); + return; + } + + if (aflag) + copy(&op->hdr, op->size, op->src, op->dst); + + while ((c = getc(op->tmp)) != EOF) + putc(c, op->dst); + + if (bflag || iflag) + copy(&op->hdr, op->size, op->src, op->dst); +} + +static void +insert(struct arop *op, char *list[]) +{ + if (!posname || strcmp(op->fname, posname)) { + copy(&op->hdr, op->size, op->src, op->dst); + return; + } + + if (aflag) + copy(&op->hdr, op->size, op->src, op->dst); + + for ( ; *list; ++list) + archive(*list, op->dst, 'a'); + + if (bflag || iflag) + copy(&op->hdr, op->size, op->src, op->dst); +} + +static void +update(struct arop *op, char *files[]) +{ + char **l; + + l = inlist(op->fname, files); + if (!l) { + copy(&op->hdr, op->size, op->src, op->dst); + return; + } + archive(op->fname, op->dst, 'r'); + rmlist(l); +} + +static void +extract(struct arop *op, char *files[]) +{ + int c; + long siz; + FILE *fp; + + if (*files && !inlist(op->fname, files)) + return; + if (vflag) + printf("x - %s\n", op->fname); + siz = op->size; + + if ((fp = fopen(op->fname, "wb")) == NULL) + goto error_file; + while (siz-- > 0 && (c = getc(op->src)) != EOF) + putc(c, fp); + fflush(fp); + if (ferror(op->src) || ferror(fp)) + goto error_file; + fclose(fp); + + /* TODO: set attributes */ + return; -member_error: - die("ar: %s: %s", fname, strerror(errno)); + +error_file: + perror("ar:error extracting file"); + exit(1); +} + +static void +print(struct arop *op, char *files[]) +{ + long siz; + int c; + + if (*files && !inlist(op->fname, files)) + return; + if (vflag) + printf("\n<%s>\n\n", op->fname); + siz = op->size; + while (siz-- > 0 && (c = getc(op->src)) != EOF) + putchar(c); +} + +static void +list(struct arop *op, char *files[]) +{ + time_t t; + struct ar_hdr *hdr = &op->hdr; + char mtime[30]; + + if (*files && !inlist(op->fname, files)) + return; + if (!vflag) { + printf("%s\n", op->fname); + } else { + t = totime(op->date); + strftime(mtime, sizeof(mtime), "%c", localtime(&t)); + printf("%s %ld/%ld\t%s %s\n", + perms(op), + atol(hdr->ar_uid), + atol(hdr->ar_gid), + mtime, + op->fname); + } +} + +static void +del(struct arop *op, char *files[]) +{ + if (inlist(op->fname, files)) { + if (vflag) + printf("d - %s\n", op->fname); + return; + } + copy(&op->hdr, op->size, op->src, op->dst); +} + +static char * +getfname(struct ar_hdr *hdr) +{ + static char fname[FILENAME_MAX]; + size_t i; + char *bp = fname; + + for (i = 0; i < sizeof(hdr->ar_name); i++) { + if ((*bp = hdr->ar_name[i]) == ' ') + break; + ++bp; + } + *bp = '\0'; + return fname; +} + +static long long +getnum(char *s, int size, int base) +{ + int c; + long long val; + char *p; + static char digits[] = "0123456789"; + + for (val = 0; size > 0; val += c) { + --size; + if ((c = *s++) == ' ') + break; + if ((p = strchr(digits, c)) == NULL) + return -1; + if ((c = p - digits) >= base) + return -1; + val *= base; + } + + while (size > 0 && *s++ == ' ') + --size; + return (size == 0) ? val : -1; +} + +static int +valid(struct arop *op) +{ + struct ar_hdr *hdr = &op->hdr; + + op->fname = getfname(&op->hdr); + op->size = getnum(hdr->ar_size, sizeof(hdr->ar_size), 10); + op->mode = getnum(hdr->ar_mode, sizeof(hdr->ar_mode), 8); + op->date = getnum(hdr->ar_date, sizeof(hdr->ar_date), 10); + + if (strncmp(hdr->ar_fmag, ARFMAG, sizeof(hdr->ar_fmag)) || + op->size < 0 || op->mode < 0 || op->date < 0) { + return 0; + } + return 1; +} + +static void +run(FILE *fp, FILE *tmp1, FILE *tmp2, + char *files[], void (*fun)(struct arop *, char *files[])) +{ + struct arop op; + + op.src = fp; + op.dst = tmp1; + op.tmp = tmp2; + while (!ferror(fp) && fread(&op.hdr, sizeof(op.hdr), 1, fp) == 1) { + fpos_t pos; + + if (!valid(&op)) { + fprintf(stderr, + "ar:corrupted member '%s'\n", + op.fname); + exit(1); + } + /* TODO: Implement early break */ + fgetpos(fp, &pos); + (*fun)(&op, files); + fsetpos(fp, &pos); + fseek(fp, op.size+1 & ~1, SEEK_CUR); + } + if (ferror(fp)) { + perror("ar:reading members"); + exit(1); + } + fclose(fp); + if (tmp1 && fflush(tmp1) == EOF) { + perror("ar:writing in temporary file"); + exit(1); + } + if (tmp2 && fflush(tmp2) == EOF) { + perror("ar:writing in temporary file"); + exit(1); + } +} + +static void +closetmp(FILE *tmp, char **name, char *afile) +{ + int c; + FILE *fp; + + if (lflag) { + if (afile && rename(*name, afile) < 0) { + perror("ar:renaming temporary"); + exit(1); + } + *name = NULL; + } else if (afile) { + if ((fp = fopen(afile, "wb")) == NULL) { + perror("ar:reopening archive file"); + exit(1); + } + rewind(tmp); + while ((c = getc(tmp)) != EOF) + fputc(c, fp); + fflush(fp); + if (ferror(fp) || ferror(tmp)) { + perror("ar:copying from temporary"); + exit(1); + } + fclose(fp); + } + fclose(tmp); +} + +static FILE * +opentmp(char *fname, char **dst) +{ + FILE *tmp; + + if (lflag) { + *dst = fname; + tmp = fopen(fname, "w+b"); + } else { + tmp = tmpfile(); + } + if (tmp == NULL) { + perror("ar:creating temporary"); + exit(1); + } + fputs(ARMAG, tmp); + + return tmp; +} + +static void +usage(void) +{ + fputs("ar [-drqtpmx][posname] [-vuaibcl] [posname] afile name ...\n", stderr); + exit(1); +} + +static void +doit(int key, char *afile, FILE *fp, char *flist[]) +{ + FILE *tmp1, *tmp2; + + if (*flist == NULL && (key == 'r' || key == 'd' || key == 'm')) { + if (fclose(fp) == EOF) { + perror("ar:early close of archive file"); + exit(-1); + } + return; + } + + switch (key) { + case 'r': + tmp1 = opentmp("ar.tmp1", &tmpafile1); + run(fp, tmp1, NULL, flist, update); + + if (*flist == NULL) { + closetmp(tmp1, &tmpafile1, afile); + break; + } + if (!posname) { + append(tmp1, flist); + break; + } + + fseek(tmp1, SARMAG, SEEK_SET); + tmp2 = opentmp("ar.tmp2", &tmpafile2); + run(tmp1, tmp2, NULL, flist, insert); + closetmp(tmp1, &tmpafile1, NULL); + closetmp(tmp2, &tmpafile2, afile); + break; + case 'q': + append(fp, flist); + break; + case 'd': + tmp1 = opentmp("ar.tmp", &tmpafile1); + run(fp, tmp1, NULL, flist, del); + closetmp(tmp1, &tmpafile1, afile); + break; + case 't': + run(fp, NULL, NULL, flist, list); + break; + case 'p': + run(fp, NULL, NULL, flist, print); + break; + case 'x': + run(fp, NULL, NULL, flist, extract); + break; + case 'm': + tmp1 = opentmp("ar.tmp1", &tmpafile1); + tmp2 = opentmp("ar.tmp2", &tmpafile2); + run(fp, tmp1, tmp2, flist, split); + + if (*flist) { + fprintf(stderr, "ar: entry '%s' not found\n", *flist); + exit(1); + } + fp = openar(afile); + fseek(tmp1, SARMAG, SEEK_SET); + fseek(tmp2, SARMAG, SEEK_SET); + if (!posname) { + cat(tmp1, tmp2, fp); + break; + } + run(tmp1, fp, tmp2, NULL, merge); + closetmp(tmp1, &tmpafile1, NULL); + closetmp(tmp2, &tmpafile2, NULL); + break; + } + +} + +int +main(int argc, char *argv[]) +{ + int key, nkey = 0, pos = 0; + char *afile; + + atexit(cleanup); + ARGBEGIN { + case 'd': + nkey++; + key = 'd'; + break; + case 'r': + nkey++; + key = 'r'; + break; + case 'q': + nkey++; + key = 'q'; + break; + case 't': + nkey++; + key = 't'; + break; + case 'p': + nkey++; + key = 'p'; + break; + case 'm': + nkey++; + key = 'm'; + break; + case 'x': + nkey++; + key = 'x'; + break; + case 'a': + aflag = 1; + pos++; + posname = EARGF(usage()); + break; + case 'b': + bflag = 1; + pos++; + posname = EARGF(usage()); + break; + case 'i': + iflag = 1; + pos++; + posname = EARGF(usage()); + break; + case 'v': + vflag = 1; + break; + case 'c': + cflag = 1; + break; + case 'l': + lflag = 1; + break; + case 'u': + uflag = 1; + break; + default: + usage(); + } ARGEND + + if (nkey == 0 || nkey > 1 || pos > 1 || argc == 0) + usage(); + + signal(SIGINT, sigfun); + signal(SIGQUIT, sigfun); + signal(SIGTERM, sigfun); + + afile = *argv; + doit(key, afile, openar(afile), argv+1); + + if (fflush(stdout) == EOF) { + perror("ar:error writing to stdout"); + exit(1); + } + + return 0; } diff --git a/ar/posix/stat.h b/ar/posix/stat.h @@ -3,3 +3,4 @@ #include <sys/stat.h> #include <unistd.h> +#define totime(x) (x) diff --git a/as/Makefile b/as/Makefile @@ -1,12 +1,13 @@ .POSIX: -LIBDIR = ../lib/scc -include ../config.mk +PROJECTDIR = .. +LIBDIR = $(PROJECTDIR)/lib/scc +include $(PROJECTDIR)/rules.mk include $(LIBDIR)/libdep.mk OBJ = main.o symbol.o ins.o parser.o expr.o myro.o -HDR = ../inc/scc.h as.h -MOREFLAGS = -I../inc/$(STD) $(AS_CFLAGS) +HDR = $(PROJECTDIR)/inc/scc.h as.h +MOREFLAGS = -I$(PROJECTDIR)/inc/$(STD) $(AS_CFLAGS) all: @@ -15,10 +16,10 @@ $(OBJ): $(HDR) as: $(OBJ) $(CC) $(SCC_LDFLAGS) $(OBJ) -lscc -o $@ -myro.o: ../inc/myro.h +myro.o: $(PROJECTDIR)/inc/myro.h $(LIBDIR)/libscc.a: $(LIB-OBJ) - cd $(LIBDIR) && $(MAKE) + +cd $(LIBDIR) && $(MAKE) dep: ./gendep.sh $(TARGETS) diff --git a/as/main.c b/as/main.c @@ -117,7 +117,7 @@ main(int argc, char *argv[]) left2right = 1; break; case 'r': - left2right = 1; + left2right = 0; break; default: usage(); diff --git a/as/test.sh b/as/test.sh @@ -43,4 +43,4 @@ cat $tmp1 printf "\nobjdump\n" cat $tmp2 printf "\ndiff\n" -diff $tmp1 $tmp2 +diff -u $tmp1 $tmp2 diff --git a/cc1/Makefile b/cc1/Makefile @@ -3,23 +3,25 @@ # Makefile is only used as a template for makefile. # If you modify Makefile remember to run make dep -LIBDIR = ../lib/scc -include ../config.mk +PROJECTDIR = .. + +LIBDIR = $(PROJECTDIR)/lib/scc +include $(PROJECTDIR)/rules.mk include $(LIBDIR)/libdep.mk -MOREFLAGS = -I../inc/$(STD) $(CC1_CFLAGS) +MOREFLAGS = -I$(PROJECTDIR)/inc/$(STD) $(CC1_CFLAGS) OBJ = types.o decl.o lex.o error.o symbol.o main.o expr.o \ code.o stmt.o cpp.o fold.o init.o builtin.o -HDR = cc1.h ../inc/scc.h ../inc/$(STD)/cstd.h ../inc/sysincludes.h +HDR = cc1.h $(PROJECTDIR)/inc/scc.h $(PROJECTDIR)/inc/$(STD)/cstd.h $(PROJECTDIR)/inc/sysincludes.h all: - mkdir -p ../rootdir/libexec/scc/ - cp cc1-* ../rootdir/libexec/scc/ + mkdir -p $(PROJECTDIR)/rootdir/libexec/scc/ + cp cc1-* $(PROJECTDIR)/rootdir/libexec/scc/ $(LIBDIR)/libscc.a: $(LIB-OBJ) - cd $(LIBDIR) && $(MAKE) + +cd $(LIBDIR) && $(MAKE) dep: ./gendep.sh $(TARGETS) diff --git a/cc2/Makefile b/cc2/Makefile @@ -3,24 +3,25 @@ # Makefile is only used as a template for makefile. # If you modify Makefile remember to run make dep -LIBDIR = ../lib/scc -include ../config.mk +PROJECTDIR = .. +LIBDIR = $(PROJECTDIR)/lib/scc +include $(PROJECTDIR)/rules.mk include $(LIBDIR)/libdep.mk -MOREFLAGS = -I../inc/$(STD) $(CC2_CFLAGS) +MOREFLAGS = -I$(PROJECTDIR)/inc/$(STD) $(CC2_CFLAGS) OBJ = main.o parser.o peep.o symbol.o node.o code.o optm.o -HDR = cc2.h ../inc/$(STD)/cstd.h ../inc/scc.h +HDR = cc2.h $(PROJECTDIR)/inc/$(STD)/cstd.h $(PROJECTDIR)/inc/scc.h all: - mkdir -p ../rootdir/libexec/scc/ - cp cc2-* ../rootdir/libexec/scc/ + mkdir -p $(PROJECTDIR)/rootdir/libexec/scc/ + cp cc2-* $(PROJECTDIR)/rootdir/libexec/scc/ dep: MKQBE=${MKQBE} ./gendep.sh $(TARGETS) $(LIBDIR)/libscc.a: $(LIB-OBJ) - cd $(LIBDIR) && $(MAKE) + +cd $(LIBDIR) && $(MAKE) main.o: error.h diff --git a/config.mk.def b/config.mk.def @@ -30,31 +30,3 @@ MANPREFIX = $(PREFIX)/share/man # CC = c99 # AR = ar AS = as - -SCC_CFLAGS = $(MOREFLAGS) \ - $(SYSCFLAGS) \ - -g \ - $(CFLAGS) - -SCC_LDFLAGS = -L$(LIBDIR)/ -g $(LDFLAGS) - -.s.o: - $(AS) $< -o $@ - -.c.o: - $(CC) $(SCC_CFLAGS) -o $@ -c $< - -.c: - $(CC) $(SCC_CFLAGS) $(SCC_LDFLAGS) -o $@ $< - -# helper macro to run over all the directories -FORALL = @set -e ;\ - pwd=$$PWD; \ - for i in $(DIRS); \ - do \ - cd $$i; \ - $(MAKE) $@; \ - cd $$pwd; \ - done - -# system specific flags diff --git a/configure b/configure @@ -0,0 +1,15 @@ +#!/bin/sh + +if [ ! -e config.mk ] +then + printf '%s\n' 'Generating config.mk from defaults...' \ + '(edit it for customization and then re-run this script)' + trap "rm -f $$.mk" 0 2 3; \ + (cat config.mk.def ;\ + sed -n '/^# '`uname`'/,/^$$/p' system.mk) > $$.mk && \ + mv $$.mk config.mk +fi + +printf 'Generating arch-dependant build files...\n' +make dep > /dev/null && \ +printf 'You can now install scc with “make install”\n' diff --git a/driver/Makefile b/driver/Makefile @@ -1,9 +1,10 @@ .POSIX: +PROJECTDIR = .. # fallback case if DRIVER isn't defined DRIVER = posix -include ../config.mk +include $(PROJECTDIR)/rules.mk all dep clean distclean: - cd $(DRIVER) && $(MAKE) $@ + +cd $(DRIVER) && $(MAKE) $@ diff --git a/driver/posix/Makefile b/driver/posix/Makefile @@ -1,19 +1,20 @@ .POSIX: -LIBDIR = ../../lib/scc -include ../../config.mk +PROJECTDIR = ../.. +LIBDIR = $(PROJECTDIR)/lib/scc +include $(PROJECTDIR)/rules.mk include $(LIBDIR)/libdep.mk OBJ = scc.o HDR = config.h \ - ../../inc/scc.h \ - ../../inc/arg.h \ - ../../inc/syslibs.h \ - ../../inc/ldflags.h + $(PROJECTDIR)/inc/scc.h \ + $(PROJECTDIR)/inc/arg.h \ + $(PROJECTDIR)/inc/syslibs.h \ + $(PROJECTDIR)/inc/ldflags.h -all: scc scpp - mkdir -p ../../rootdir/bin - cp scc scpp ../../rootdir/bin/ +all: scc cpp + mkdir -p $(PROJECTDIR)/rootdir/bin + cp scc cpp $(PROJECTDIR)/rootdir/bin/ dep: PREFIX=$(PREFIX) USEQBE=$(USEQBE) ./gendep.sh $(TARGETS) @@ -23,16 +24,16 @@ $(OBJ): $(HDR) scc: $(OBJ) $(LIBDIR)/libscc.a $(CC) $(SCC_LDFLAGS) $(OBJ) -lscc -o $@ -scpp: cpp.sh config.h +cpp: cpp.sh config.h set -x ;\ trap "rm -f $$$$.sh" 0 2 3;\ rm -f $@ ;\ sed "s%@PREFIX@%$(PREFIX)%" < cpp.sh > $$$$.sh && \ chmod +x $$$$.sh && \ - mv $$$$.sh scpp + mv $$$$.sh $@ $(LIBDIR)/libscc.a: - cd $(LIBDIR) && $(MAKE) + +cd $(LIBDIR) && $(MAKE) clean: rm -f $(OBJ) diff --git a/driver/posix/cpp.sh b/driver/posix/cpp.sh @@ -1,4 +1,4 @@ #!/bin/sh -SCCPREFIX=$(SCCPREFIX:-@PREFIX@) -$(SCCPREFIX)/bin/scc -E $@ +SCCPREFIX=${SCCPREFIX:-@PREFIX@} +${SCCPREFIX}/bin/scc -E $@ diff --git a/driver/posix/scc.c b/driver/posix/scc.c @@ -282,8 +282,12 @@ spawn(int tool) if (!dflag && tool != CC1 && tool != LD) dup2(devnullfd, 2); execvp(t->cmd, t->args.s); - fprintf(stderr, "scc: execvp %s: %s\n", - t->cmd, strerror(errno)); + if (dflag) { + fprintf(stderr, + "scc: execvp %s: %s\n", + t->cmd, + strerror(errno)); + } abort(); default: if (t->in > -1) @@ -320,6 +324,25 @@ toolfor(char *file) } static int +valid(int tool, struct tool *t) +{ + int st; + + if (waitpid(t->pid, &st, 0) == -1 || WIFSIGNALED(st)) + goto internal; + if (WIFEXITED(st) && WEXITSTATUS(st) == 0) + return 1; + if (!failure && (tool == CC1 || tool == LD)) + goto fail; + +internal: + fprintf(stderr, "scc:%s: internal error\n", t->bin); +fail: + failure = 1; + return 0; +} + +static int validatetools(void) { struct tool *t; @@ -330,17 +353,8 @@ validatetools(void) t = &tools[tool]; if (!t->pid) continue; - if (waitpid(t->pid, &st, 0) < 0 || - !WIFEXITED(st) || - WEXITSTATUS(st) != 0) { - if (!WIFEXITED(st) || - !failure && tool != CC1 && tool != LD) { - fprintf(stderr, - "scc:%s: internal error\n", t->bin); - } - failure = 1; + if (!valid(tool, t)) failed = tool; - } if (tool >= failed && t->outfile) unlink(t->outfile); for (i = t->nparams; i < t->args.n; ++i) diff --git a/inc/Makefile b/inc/Makefile @@ -1,6 +1,8 @@ .POSIX: -include ../config.mk +PROJECTDIR = .. + +include $(PROJECTDIR)/rules.mk HDR = ldflags.h sysincludes.h syslibs.h diff --git a/inc/ar.h b/inc/ar.h @@ -1,21 +1,14 @@ -#define ARMAGIC "!<arch>\n" -#define ARMAGIC_SIZ 8 - -struct arhdr { - char name[17]; - unsigned long long time; - int uid; - int gid; - int mode; - unsigned long long size; +#define ARMAG "!<arch>\n" /* ar "magic number" */ +#define SARMAG 8 /* strlen(ARMAG); */ +#define ARFMAG "`\n" + +struct ar_hdr { + char ar_name[16]; /* name */ + char ar_date[12]; /* modification time */ + char ar_uid[6]; /* user id */ + char ar_gid[6]; /* group id */ + char ar_mode[8]; /* octal file permissions */ + char ar_size[10]; /* size in bytes */ + char ar_fmag[2]; /* consistency check */ }; - -#define ARHDR_SIZ 60 -#define ARNAME_SIZ 16 -#define ARMAGIC "!<arch>\n" -#define ARMAGIC_SIZ 8 - -extern int wrarhdr(FILE *fp, struct arhdr *hdr); -extern int wrarfile(FILE *fp, struct arhdr *hdr); -extern int rdarhdr(FILE *fp, struct arhdr *hdr); diff --git a/lib/Makefile b/lib/Makefile @@ -1,14 +1,10 @@ .POSIX: -include ../config.mk +PROJECTDIR = .. + +include $(PROJECTDIR)/rules.mk DIRS = scc all dep clean distclean: - @pwd=$$PWD; \ - for i in $(DIRS); \ - do \ - cd $$i; \ - $(MAKE) $@; \ - cd $$pwd; \ - done + $(FORALL) diff --git a/lib/c/Makefile b/lib/c/Makefile @@ -1,4 +1,4 @@ .POSIX: all dep clean distclean: - cd target && $(MAKE) $@ + +cd target && $(MAKE) $@ diff --git a/lib/c/target/Makefile b/lib/c/target/Makefile @@ -1,5 +1,7 @@ -include ../../../config.mk +PROJECTDIR = ../../.. + +include $(PROJECTDIR)/rules.mk DIRS = $(TARGETS) diff --git a/lib/c/target/amd64-sysv-linux-elf/Makefile b/lib/c/target/amd64-sysv-linux-elf/Makefile @@ -1,6 +1,8 @@ .POSIX: -include ../../../../config.mk +PROJECTDIR = ../../../.. + +include $(PROJECTDIR)/rules.mk include ../objlst.mk include ../common.mk diff --git a/lib/c/target/amd64-sysv-openbsd-elf/Makefile b/lib/c/target/amd64-sysv-openbsd-elf/Makefile @@ -1,5 +1,7 @@ .POSIX: -include ../../../../config.mk +PROJECTDIR = ../../../.. + +include $(PROJECTDIR)/rules.mk include ../objlst.mk include ../common.mk diff --git a/lib/c/target/i386-sysv-linux-elf/Makefile b/lib/c/target/i386-sysv-linux-elf/Makefile @@ -1,5 +1,7 @@ .POSIX: -include ../../../../config.mk +PROJECTDIR = ../../../.. + +include $(PROJECTDIR)/rules.mk include ../objlst.mk include ../common.mk diff --git a/lib/c/target/z80-scc-none-none/Makefile b/lib/c/target/z80-scc-none-none/Makefile @@ -1,5 +1,7 @@ .POSIX: -include ../../../../config.mk +PROJECTDIR = ../../../.. + +include $(PROJECTDIR)/rules.mk include ../objlst.mk include ../common.mk diff --git a/lib/crt/Makefile b/lib/crt/Makefile @@ -1,6 +1,8 @@ .POSIX: -include ../../config.mk +PROJECTDIR = ../.. + +include $(PROJECTDIR)/rules.mk all: diff --git a/lib/scc/Makefile b/lib/scc/Makefile @@ -1,14 +1,15 @@ .POSIX: -LIBDIR = ./ -include ../../config.mk +PROJECTDIR = ../.. +LIBDIR = . +include $(PROJECTDIR)/rules.mk include libdep.mk all: libscc.a -$(LIB-OBJ): ../../inc/scc.h -$(LIBDIR)/wmyro.o: ../../inc/myro.h -$(LIBDIR)/rmyro.o: ../../inc/myro.h +$(LIB-OBJ): $(PROJECTDIR)/inc/scc.h +$(LIBDIR)/wmyro.o: $(PROJECTDIR)/inc/myro.h +$(LIBDIR)/rmyro.o: $(PROJECTDIR)/inc/myro.h libscc.a: $(LIB-OBJ) ar $(ARFLAGS) $@ $? diff --git a/lib/scc/libdep.mk b/lib/scc/libdep.mk @@ -11,5 +11,3 @@ LIB-OBJ = $(LIBDIR)/debug.o \ $(LIBDIR)/lpack.o \ $(LIBDIR)/wmyro.o \ $(LIBDIR)/rmyro.o \ - $(LIBDIR)/war.o \ - $(LIBDIR)/rar.o \ diff --git a/lib/scc/rar.c b/lib/scc/rar.c @@ -1,33 +0,0 @@ -static char sccsid[] = "@(#) ./lib/scc/rar.c"; - -#include <assert.h> -#include <stdio.h> -#include <string.h> - -#include "../../inc/ar.h" - -int -rdarhdr(FILE *fp, struct arhdr *hdr) -{ - char buf[ARHDR_SIZ+1]; - size_t len; - int n; - - if (!fgets(buf, sizeof(buf), fp)) - return EOF; - if ((len = strlen(buf)) != ARHDR_SIZ || - buf[len-2] != '`' || - buf[len-1] != '\n') { - return EOF; - } - - n = sscanf(buf, "%16s-%llu-%u-%u-%o-%llu", - &hdr->name, - &hdr->time, - &hdr->uid, &hdr->gid, - &hdr->mode, - &hdr->size); - if (n != 6) - return EOF; - return (feof(fp)) ? EOF : 0; -} diff --git a/lib/scc/war.c b/lib/scc/war.c @@ -1,38 +0,0 @@ -static char sccsid[] = "@(#) ./lib/scc/war.c"; - -#include <assert.h> -#include <stdio.h> - -#include "../../inc/ar.h" - -int -wrarhdr(FILE *fp, struct arhdr *hdr) -{ - int len; - - len = fprintf(fp, - "%-16s%-12llu%-6u%-6u%-8o%-10llu`\n", - hdr->name, - hdr->time, - hdr->uid, hdr->gid, - hdr->mode, - hdr->size); - assert(len== ARHDR_SIZ); - - return (feof(fp)) ? EOF : len; -} - -int -wrarfile(FILE *fo, struct arhdr *hdr) -{ - FILE *fi; - int c; - - if ((fi = fopen(hdr->name, "rb")) == NULL) - return -1; - while ((c = getc(fi)) != EOF) - putc(c, fo); - if (hdr->size & 1) - putc('\n', fo); - return (fclose(fi) == EOF) ? -1 : 0; -} diff --git a/lib/sys/Makefile b/lib/sys/Makefile @@ -1,9 +1,11 @@ .POSIX: -include ../../config.mk +PROJECTDIR = ../.. + +include $(PROJECTDIR)/rules.mk all clean distclean: - pwd=$$PWD ;\ + +@pwd=$$PWD ;\ for i in $(SYSS); \ do \ cd $$i; \ diff --git a/lib/sys/common.mk b/lib/sys/common.mk @@ -1,9 +1,11 @@ .POSIX: -include ../../../config.mk +PROJECTDIR = ../../.. + +include $(PROJECTDIR)/rules.mk all clean distclean: system.mk - $(MAKE) ABI=$(ABI) -f ../libsys.mk $@ + +$(MAKE) ABI=$(ABI) -f ../libsys.mk $@ system.mk: syscall.lst rm -f $@; trap "rm -f $$$$.mk" 0 2 3; \ diff --git a/lib/sys/libsys.mk b/lib/sys/libsys.mk @@ -1,6 +1,8 @@ .POSIX: -include ../../../config.mk +PROJECTDIR = ../../.. + +include $(PROJECTDIR)/rules.mk include system.mk ASM = $(OBJ:.o=.s) diff --git a/nm/Makefile b/nm/Makefile @@ -1,7 +1,8 @@ .POSIX: -LIBDIR = ../lib/scc -include ../config.mk +PROJECTDIR = .. +LIBDIR = $(PROJECTDIR)/lib/scc +include $(PROJECTDIR)/rules.mk include $(LIBDIR)/libdep.mk OBJ = main.o @@ -11,10 +12,10 @@ all: nm nm: $(OBJ) $(LIBDIR)/libscc.a $(CC) $(SCC_LDFLAGS) $(OBJ) -lscc -o $@ -main.o: ../inc/scc.h ../inc/ar.h ../inc/myro.h +main.o: $(PROJECTDIR)/inc/scc.h $(PROJECTDIR)/inc/ar.h $(PROJECTDIR)/inc/myro.h $(LIBDIR)/libscc.a: $(LIB-OBJ) - cd $(LIBDIR) && $(MAKE) + +cd $(LIBDIR) && $(MAKE) dep: clean: diff --git a/nm/main.c b/nm/main.c @@ -38,6 +38,7 @@ object(char *fname, FILE *fp) return 0; } +#if 0 static int archive(char *fname, FILE *fp) { @@ -52,6 +53,7 @@ archive(char *fname, FILE *fp) return 1; return 0; } +#endif static int cmp(const void *p1, const void *p2) @@ -197,6 +199,7 @@ offset_overflow: goto free_arrays; } +#if 0 static void ar(char *fname, FILE *fp) { @@ -226,6 +229,7 @@ ar(char *fname, FILE *fp) fseek(fp, pos, SEEK_SET); } } +#endif void doit(char *fname) @@ -238,8 +242,8 @@ doit(char *fname) if (object(fname, fp)) nm(fname, fname, fp); - else if (archive(fname, fp)) - ar(fname, fp); +// else if (archive(fname, fp)) +// ar(fname, fp); else fprintf(stderr, "nm: %s: File format not recognized\n", fname); diff --git a/objdump/Makefile b/objdump/Makefile @@ -1,7 +1,8 @@ .POSIX: -LIBDIR = ../lib/scc -include ../config.mk +PROJECTDIR = .. +LIBDIR = $(PROJECTDIR)/lib/scc +include $(PROJECTDIR)/rules.mk include $(LIBDIR)/libdep.mk OBJ = main.o @@ -11,10 +12,10 @@ all: objdump objdump: $(OBJ) $(LIBDIR)/libscc.a $(CC) $(SCC_LDFLAGS) $(OBJ) -lscc -o $@ -main.o: ../inc/scc.h ../inc/myro.h ../inc/arg.h +main.o: $(PROJECTDIR)/inc/scc.h $(PROJECTDIR)/inc/myro.h $(PROJECTDIR)/inc/arg.h $(LIBDIR)/libscc.a: $(LIB-OBJ) - cd $(LIBDIR) && $(MAKE) + +cd $(LIBDIR) && $(MAKE) dep: clean: diff --git a/rules.mk b/rules.mk @@ -0,0 +1,27 @@ +include $(PROJECTDIR)/config.mk + +SCC_CFLAGS = $(MOREFLAGS) \ + $(SYSCFLAGS) \ + -g \ + $(CFLAGS) + +SCC_LDFLAGS = -L$(LIBDIR) -g $(LDFLAGS) + +# helper macro to run over all the directories +FORALL = +@set -e ;\ + pwd=$$PWD; \ + for i in $(DIRS); \ + do \ + cd $$i; \ + $(MAKE) $@; \ + cd $$pwd; \ + done + +.s.o: + $(AS) $< -o $@ + +.c.o: + $(CC) $(SCC_CFLAGS) -o $@ -c $< + +.c: + $(CC) $(SCC_CFLAGS) $(SCC_LDFLAGS) -o $@ $< diff --git a/tests/Makefile b/tests/Makefile @@ -1,5 +1,10 @@ .POSIX: +include ../config.mk -all clean dep distclean: - cd error && make -e $@ - cd execute && make -e $@ +DIRS=scc ar + +all clean: + $(FORALL) + +distclean: clean +dep: diff --git a/tests/ar/Makefile b/tests/ar/Makefile @@ -0,0 +1,7 @@ +.POSIX: +include ../../config.mk + +DIRS=error execute + +all clean: + $(FORALL) diff --git a/tests/ar/error/Makefile b/tests/ar/error/Makefile @@ -0,0 +1,3 @@ +.POSIX: + +all clean: diff --git a/tests/ar/execute/Makefile b/tests/ar/execute/Makefile @@ -0,0 +1,12 @@ +.POSIX: + +PROJECTDIR=$$PWD/../../../ +ROOTDIR=$(PROJECTDIR)/rootdir + +all: tests + +tests: + SCCPREFIX=$(ROOTDIR) PATH=$(ROOTDIR)/bin:$$PATH ./chktest.sh + +clean : + rm -f *.a diff --git a/tests/ar/execute/chktest.sh b/tests/ar/execute/chktest.sh @@ -0,0 +1,93 @@ +#!/bin/sh -x + +set -e + +TZ=UTC +tmp1=`mktemp` +tmp2=`mktemp` + +#trap "rm -f $tmp1 $tmp2" 0 2 3 + +rm -f test.a + +############################################################################ +#create the test files +mkdir -p files +cd files + +cat <<! >file1 +This is the first file, +and it should go in the +first position in the archive. +! + +cat <<! >file2 +But this other one is the second one, +and it shouldn't go in the first position +because it should go in the second position. +! + +cat <<! >file3 +and at the end, this is the last file +that should go at the end of the file, +thus it should go in the third position. +! + +cat <<! >file4 +Ok, we can add a new file +and see what happens +! + +touch -t 198001010000 file? + +############################################################################ +#generate the archive with the members in files +ar -qv ../test.a file1 file2 +ar -qv ../test.a file3 +cd .. + +############################################################################ +#verify that the output of ar -t is correct + +ar -t test.a > $tmp1 +cat <<! > $tmp2 +file1 +file2 +file3 +! + +cmp $tmp1 $tmp2 + +############################################################################ +#and now check that -tv doesn't break the code + +ar -tv test.a >$tmp1 +cat <<! >$tmp2 +rw-r--r-- 1000/100 Tue Jan 1 00:00:00 1980 file1 +rw-r--r-- 1000/100 Tue Jan 1 00:00:00 1980 file2 +rw-r--r-- 1000/100 Tue Jan 1 00:00:00 1980 file3 +! + +cmp $tmp1 $tmp2 + +############################################################################ +#extract the files +ar -xv test.a file1 file2 file3 + +cmp file1 files/file1 +cmp file2 files/file2 +cmp file3 files/file3 + +rm -f file1 file2 file3 + +############################################################################ +#delete the 2nd file +ar -dv test.a file2 + +ar -tv test.a >$tmp1 +cat <<! >$tmp2 +rw-r--r-- 1000/100 Tue Jan 1 00:00:00 1980 file1 +rw-r--r-- 1000/100 Tue Jan 1 00:00:00 1980 file3 +! + +cmp $tmp1 $tmp2 diff --git a/tests/execute/0136-if.c b/tests/execute/0136-if.c @@ -1,21 +0,0 @@ -int c; - -int -main() -{ - if(0) { - return 1; - } else if(0) { - /* empty */ - } else { - if(1) { - if(c) - return 1; - else - return 0; - } else { - return 1; - } - } - return 1; -} diff --git a/tests/execute/0137-int-cast.c b/tests/execute/0137-int-cast.c @@ -1,273 +0,0 @@ -/* -name: TEST013 -description: Basic test of integer types and integer conversions -comments: This test depends of the configuration in the type system. - With the current configuration char is equal to unsigned char, - short is equal to int, and unsigned short is equal to unsigned. -error: -output: -G1 I "a -G2 N "b -G3 K "c -G4 C "d -G5 K "e -G6 W "f -G7 Z "g -G8 Q "h -G9 O "i -G10 I "j -G11 N "k -G13 I F "main -{ -\ - G1 G2 gI :I - G1 G3 gI :I - G1 G4 gI :I - G1 G5 gI :I - G1 G6 gI :I - G1 G7 gI :I - G1 G8 gI :I - G1 G9 gI :I - G1 G10 :I - G1 G11 gI :I - G2 G1 gN :N - G2 G3 gN :N - G2 G4 gN :N - G2 G5 gN :N - G2 G6 gN :N - G2 G7 gN :N - G2 G8 gN :N - G2 G9 gN :N - G2 G10 gN :N - G2 G11 :N - G3 G1 gK :K - G3 G2 gK :K - G3 G4 gK :K - G3 G5 :K - G3 G6 gK :K - G3 G7 gK :K - G3 G8 gK :K - G3 G9 gK :K - G3 G10 gK :K - G3 G11 gK :K - G4 G1 gC :C - G4 G2 gC :C - G4 G3 gC :C - G4 G5 gC :C - G4 G6 gC :C - G4 G7 gC :C - G4 G8 gC :C - G4 G9 gC :C - G4 G10 gC :C - G4 G11 gC :C - G5 G1 gK :K - G5 G2 gK :K - G5 G3 :K - G5 G4 gK :K - G5 G6 gK :K - G5 G7 gK :K - G5 G8 gK :K - G5 G9 gK :K - G5 G10 gK :K - G5 G11 gK :K - G6 G1 gW :W - G6 G2 gW :W - G6 G3 gW :W - G6 G4 gW :W - G6 G5 gW :W - G6 G7 gW :W - G6 G8 gW :W - G6 G9 gW :W - G6 G10 gW :W - G6 G11 gW :W - G7 G1 gZ :Z - G7 G2 gZ :Z - G7 G3 gZ :Z - G7 G4 gZ :Z - G7 G5 gZ :Z - G7 G6 gZ :Z - G7 G8 gZ :Z - G7 G9 gZ :Z - G7 G10 gZ :Z - G7 G11 gZ :Z - G8 G1 gQ :Q - G8 G2 gQ :Q - G8 G3 gQ :Q - G8 G4 gQ :Q - G8 G5 gQ :Q - G8 G6 gQ :Q - G8 G7 gQ :Q - G8 G9 gQ :Q - G8 G10 gQ :Q - G8 G11 gQ :Q - G9 G1 gO :O - G9 G2 gO :O - G9 G3 gO :O - G9 G4 gO :O - G9 G5 gO :O - G9 G6 gO :O - G9 G7 gO :O - G9 G8 gO :O - G9 G10 gO :O - G9 G11 gO :O - G10 G1 :I - G10 G2 gI :I - G10 G3 gI :I - G10 G4 gI :I - G10 G5 gI :I - G10 G6 gI :I - G10 G7 gI :I - G10 G8 gI :I - G10 G9 gI :I - G10 G11 gI :I - G11 G1 gN :N - G11 G2 :N - G11 G3 gN :N - G11 G4 gN :N - G11 G5 gN :N - G11 G6 gN :N - G11 G7 gN :N - G11 G8 gN :N - G11 G10 gN :N - G11 G9 gN :N -} -*/ - -int a; -unsigned b; -char c; -signed char d; -unsigned char e; -long f; -unsigned long g; -long long h; -unsigned long long i; -short j; -unsigned short k; - -int -main(void) -{ - a = b; - a = c; - a = d; - a = e; - a = f; - a = g; - a = h; - a = i; - a = j; - a = k; - - b = a; - b = c; - b = d; - b = e; - b = f; - b = g; - b = h; - b = i; - b = j; - b = k; - - c = a; - c = b; - c = d; - c = e; - c = f; - c = g; - c = h; - c = i; - c = j; - c = k; - - d = a; - d = b; - d = c; - d = e; - d = f; - d = g; - d = h; - d = i; - d = j; - d = k; - - e = a; - e = b; - e = c; - e = d; - e = f; - e = g; - e = h; - e = i; - e = j; - e = k; - - f = a; - f = b; - f = c; - f = d; - f = e; - f = g; - f = h; - f = i; - f = j; - f = k; - - g = a; - g = b; - g = c; - g = d; - g = e; - g = f; - g = h; - g = i; - g = j; - g = k; - - h = a; - h = b; - h = c; - h = d; - h = e; - h = f; - h = g; - h = i; - h = j; - h = k; - - i = a; - i = b; - i = c; - i = d; - i = e; - i = f; - i = g; - i = h; - i = j; - i = k; - - j = a; - j = b; - j = c; - j = d; - j = e; - j = f; - j = g; - j = h; - j = i; - j = k; - - k = a; - k = b; - k = c; - k = d; - k = e; - k = f; - k = g; - k = h; - k = j; - k = i; - - return 0; -} diff --git a/tests/execute/0138-namespace.c b/tests/execute/0138-namespace.c @@ -1,30 +0,0 @@ -typedef struct s s; - -struct s { - struct s1 { - int s; - struct s2 { - int s; - } s1; - } s; -} s2; - -#define s s - -int -main(void) -{ -#undef s - goto s; - struct s s; - { - int s; - return s; - } - return s.s.s + s.s.s1.s; - s: - { - return 0; - } - return 1; -} diff --git a/tests/execute/0139-ptr-ary.c b/tests/execute/0139-ptr-ary.c @@ -1,22 +0,0 @@ -int -main() -{ - char arr[2][4], (*p)[4], *q; - int v[4]; - - p = arr; - q = &arr[1][3]; - arr[1][3] = 2; - v[0] = 2; - - if (arr[1][3] != 2) - return 1; - if (p[1][3] != 2) - return 1; - if (*q != 2) - return 1; - if (*v != 2) - return 1; - - return 0; -} diff --git a/tests/execute/0140-int-fold.c b/tests/execute/0140-int-fold.c @@ -1,27 +0,0 @@ -int -main(void) -{ - int i; - - i = 1 + 2; - i = 2 - 1; - i = 3 * 6; - i = 10 / 5; - i = 10 % 5; - i = i % 0; - i = i % 0; - i = 1 << 3; - i = 8 >> 2; - i = 12 & 4; - i = 8 | 4; - i = 12 ^ 4; - i = -(3); - i = ~12; - i = 1 < 3; - i = 2 > 3; - i = 2 >= 3; - i = 2 <= 3; - i = 1 == 0; - - return 0; -} diff --git a/tests/execute/0141-int-iden.c b/tests/execute/0141-int-iden.c @@ -1,37 +0,0 @@ -int -main(void) -{ - int i; - - i = i || 0; - i = i || 4; - i = 4 || i; - i = 0 || i; - i = i && 0; - i = i && 4; - i = 4 && i; - i = 0 && i; - i = i << 0; - i = 0 << i; - i = i >> 0; - i = 0 >> i; - i = i + 0; - i = 0 + i; - i = i - 0; - i = 0 - i; - i = i | 0; - i = 0 | i; - i = i ^ 0; - i = 0 ^ i; - i = i * 0; - i = 0 * i; - i = i * 1; - i = 1 * i; - i = i / 1; - i = 1 / i; - i = i & ~0; - i = ~0 & i; - i = i % 1; - i = i / 0; - i = i % 0; -} diff --git a/tests/execute/0142-char-const.c b/tests/execute/0142-char-const.c @@ -1,40 +0,0 @@ -int -main(void) -{ - unsigned char uc; - signed char sc; - - uc = -1; - if ((uc & 0xFF) != 0xFF) - return 1; - - uc = '\x23'; - if (uc != 36) - return 1; - - uc = 1u; - if (uc != (1025 & 0xFF) - return 1; - - uc = 'A'; - if (uc != 0x41) - return 1; - - sc = -1; - if ((sc & 0xFF) != 0xFF) - return 1; - - sc = '\x23'; - if (sc != 36) - return 1; - - sc = 1u; - if (uc != (1025 & 0xFF) - return 1; - - sc = 'A'; - if (uc != 0x41) - return 1; - - return 0; -} diff --git a/tests/execute/0143-int-const.c b/tests/execute/0143-int-const.c @@ -1,24 +0,0 @@ -main(void) -{ - int i; - unsigned u; - - i = 1; - i = -1; - i = -1l; - i = -1u; - i = -1ll; - i = 32766 + 1 & 3; - i = (int) 32768 < 0; - i = -1u < 0; - - u = 1; - u = -1; - u = -1l; - u = -1u; - u = -1ll; - u = (unsigned) 32768 < 0; - u = 32766 + 1 & 3; - u = -1u < 0; - return 0; -} diff --git a/tests/execute/0144-long-const.c b/tests/execute/0144-long-const.c @@ -1,25 +0,0 @@ -int -main(void) -{ - long i; - unsigned long u; - - i = 1; - i = -1; - i = -1l; - i = -1u; - i = -1ll; - i = (1ll << 32) - 1 & 3; - i = (long) ((1ll << 32) - 1) < 0; - i = -1u < 0; - - u = 1; - u = -1; - u = -1l; - u = -1u; - u = -1ll; - u = (1ll << 32) - 1 & 3; - u = (long) ((1ll << 32) - 1) < 0; - u = -1u < 0; - return 0; -} diff --git a/tests/execute/0145-llong-const.c b/tests/execute/0145-llong-const.c @@ -1,23 +0,0 @@ -int -main(void) -{ - long long i; - unsigned long long u; - - i = 1; - i = -1; - i = -1l; - i = -1u; - i = -1ll; - i = -1ll & 3; - i = -1ll < 0; - - u = 1; - u = -1; - u = -1l; - u = -1u; - u = -1ll; - u = -1llu & 3; - u = -1llu < 0; - return 0; -} diff --git a/tests/execute/0146-ifdef.c b/tests/execute/0146-ifdef.c @@ -1,52 +0,0 @@ -#define FOO - -#ifdef FOO - int a; - int b; - #undef FOO - #ifndef FOO - int c; - int d; - #else - int e; - int f; - #endif - int e; - int f; - #ifdef FOO - int c_; - int d_; - #else - int e_; - int f_; - #endif - int e_; - int f_; -int -main() -{ - return 0; -} -#else - int j; - int k; - #ifdef FOO - int j; - int k; - #else - int n; - int o; - #endif - int n; - int o; - #ifndef FOO - int r; - int s; - #else - int t; - int u; - #endif - int t; - int u; - #error bad branch -#endif diff --git a/tests/execute/0147-intern-cpp.c b/tests/execute/0147-intern-cpp.c @@ -1,19 +0,0 @@ -#define x(y) (y) - -int -main(void) -{ - int y; - char *p; - - p = __FILE__; - y = __LINE__; - p = __DATE__; - y = __STDC__; - p = __TIME__; - y = __STDC_HOSTED__; - y = __SCC__; - y = x(1); - - return 0; -} diff --git a/tests/execute/0148-cpp-string.c b/tests/execute/0148-cpp-string.c @@ -1,10 +0,0 @@ -#define x(y) #y - -int -main(void) -{ - char *p; - p = x(hello) " is better than bye"; - - return (*p == 'h') ? 0 : 1; -} diff --git a/tests/execute/0149-define.c b/tests/execute/0149-define.c @@ -1,10 +0,0 @@ -#define M(x) x -#define A(a,b) a(b) - -int -main(void) -{ - char *a = A(M,"hi"); - - return (a[1] == 'i') ? 0 : 1; -} diff --git a/tests/execute/0150-define.c b/tests/execute/0150-define.c @@ -1,15 +0,0 @@ -/* - * f(2) will expand to 2*g, which will expand to 2*f, and in this - * moment f will not be expanded because the macro definition is - * a function alike macro, and in this case there is no arguments. - */ -#define f(a) a*g -#define g f - -int -main(void) -{ - int f = 0; - - return f(2); -} diff --git a/tests/execute/0151-vararg.c b/tests/execute/0151-vararg.c @@ -1,25 +0,0 @@ -struct foo { - int i, j, k; - char *p; - float v; -}; - -int -f1(struct foo f, struct foo *p, int n, ...) -{ - if (f.i != p->i) - return 0; - return p->j + n; -} - -int -main(void) -{ - struct foo f; - - f.i = f.j = 1; - f1(f, &f, 2); - f1(f, &f, 2, 1, f, &f); - - return 0; -} diff --git a/tests/execute/0152-cat.c b/tests/execute/0152-cat.c @@ -1,14 +0,0 @@ -#define CAT(x,y) x ## y -#define XCAT(x,y) CAT(x,y) -#define FOO foo -#define BAR bar - -int -main(void) -{ - int foo, bar, foobar; - - CAT(foo,bar) = foo + bar; - XCAT(FOO,BAR) = foo + bar; - return 0; -} diff --git a/tests/execute/0153-cpp-string.c b/tests/execute/0153-cpp-string.c @@ -1,13 +0,0 @@ -#define M1(x) "This is a string $ or # or ## " ## #x -#define STR "This is a string $ or # or ## and it is ok!" - -int -main(void) -{ - char *s, *t = M1(and it is ok!); - - for (s = STR; *s && *s == *t; ++s) - ++t; - - return *s; -} diff --git a/tests/execute/0154-if-defined b/tests/execute/0154-if-defined @@ -1,15 +0,0 @@ -#if defined(FOO) -int a; -#elif !defined(FOO) && defined(BAR) -int b; -#elif !defined(FOO) && !defined(BAR) -int c; -#else -int d; -#endif - -int -main(void) -{ - return c; -} diff --git a/tests/execute/0155-struct-compl.c b/tests/execute/0155-struct-compl.c @@ -1,16 +0,0 @@ -extern struct X x; -int foo(); - -int main() -{ - extern struct X x; - return &x != 0; -} - -struct X {int v;}; - -int foo() -{ - x.v = 0; - return x.v; -} diff --git a/tests/execute/0156-duff2.c b/tests/execute/0156-duff2.c @@ -1,35 +0,0 @@ -/* - * Disgusting, no? But it compiles and runs just fine. I feel a - * combination of pride and revulsion at this discovery. If no one's - * thought of it before, I think I'll name it after myself. It amazes - * me that after 10 years of writing C there are still little corners - * that I haven't explored fully. - * - Tom Duff - */ -send(to, from, count) - register short *to, *from; - register count; -{ - register n=(count+7)/8; - switch(count%8){ - case 0: do{*to = *from++; - case 7: *to = *from++; - case 6: *to = *from++; - case 5: *to = *from++; - case 4: *to = *from++; - case 3: *to = *from++; - case 2: *to = *from++; - case 1: *to = *from++; - }while(--n>0); - } -} - -int -main() -{ - short a, b[40]; - - send(&a, b, 40); - - return (a == b[39]) ? 0 : 1; -} diff --git a/tests/execute/0157-list.c b/tests/execute/0157-list.c @@ -1,14 +0,0 @@ -typedef struct List List; -struct List { - int len; - struct List *head; - List *back; -}; - -int -main(void) -{ - List List; - - return List.len; -} diff --git a/tests/execute/0158-ternary.c b/tests/execute/0158-ternary.c @@ -1,17 +0,0 @@ -int -main(void) -{ - int i, *q; - void *p; - - i = i ? 0 : 0l; - p = i ? (void *) 0 : 0; - p = i ? 0 : (void *) 0; - p = i ? 0 : (const void *) 0; - q = i ? 0 : p; - q = i ? p : 0; - q = i ? q : 0; - q = i ? 0 : q; - - return (int) q; -} diff --git a/tests/execute/0159-typedef.c b/tests/execute/0159-typedef.c @@ -1,24 +0,0 @@ -/* Taken from plan9 kernel */ - -typedef struct Clock0link Clock0link; -typedef struct Clock0link { - int (*clock)(void); - Clock0link* link; -} Clock0link; - - -int -f(void) -{ - return 0; -} - -Clock0link cl0 = { - .clock = f; -}; - -int -main(void) -{ - return (*cl0.clock)(); -} diff --git a/tests/execute/0160-cpp-if.c b/tests/execute/0160-cpp-if.c @@ -1,17 +0,0 @@ -#if 0 != (0 && (0/0)) - #error 0 != (0 && (0/0)) -#endif - -#if 1 != (-1 || (0/0)) - #error 1 != (-1 || (0/0)) -#endif - -#if 3 != (-1 ? 3 : (0/0)) - #error 3 != (-1 ? 3 : (0/0)) -#endif - -int -main() -{ - return 0; -} diff --git a/tests/execute/0161-struct.c b/tests/execute/0161-struct.c @@ -1,12 +0,0 @@ -struct S { int a; int b; }; -struct S s = (struct S){1, 2}; - -int -main() -{ - if(s.a != 1) - return 1; - if(s.b != 2) - return 2; - return 0; -} diff --git a/tests/execute/0162-array.c b/tests/execute/0162-array.c @@ -1,13 +0,0 @@ -int arr[3] = {[2] = 2, [0] = 0, [1] = 1}; - -int -main() -{ - if(arr[0] != 0) - return 1; - if(arr[1] != 1) - return 2; - if(arr[2] != 2) - return 3; - return 0; -} diff --git a/tests/execute/0163-array.c b/tests/execute/0163-array.c @@ -1,16 +0,0 @@ -struct S {int a; int b;}; -struct S arr[2] = {[1] = {3, 4}, [0] = {1, 2}}; - -int -main() -{ - if(arr[0].a != 1) - return 1; - if(arr[0].b != 2) - return 2; - if(arr[1].a != 3) - return 3; - if(arr[1].b != 4) - return 4; - return 0; -} diff --git a/tests/execute/0164-struct.c b/tests/execute/0164-struct.c @@ -1,12 +0,0 @@ -struct S { int a; int b; }; -struct S *s = &(struct S) { 1, 2 }; - -int -main() -{ - if(s->a != 1) - return 1; - if(s->b != 2) - return 2; - return 0; -} diff --git a/tests/execute/0165-struct.c b/tests/execute/0165-struct.c @@ -1,33 +0,0 @@ -struct S1 { - int a; - int b; -}; -struct S2 { - struct S1 s1; - struct S1 *ps1; - int arr[2]; -}; -struct S1 gs1 = (struct S1) {.a = 1, 2}; -struct S2 *s = &(struct S2) { - {.b = 2, .a = 1}, - &gs1, - {[0] = 1, 1+1} -}; - -int -main() -{ - if(s->s1.a != 1) - return 1; - if(s->s1.b != 2) - return 2; - if(s->ps1->a != 1) - return 3; - if(s->ps1->b != 2) - return 4; - if(s->arr[0] != 1) - return 5; - if(s->arr[1] != 2) - return 6; - return 0; -} diff --git a/tests/execute/0166-desig.c b/tests/execute/0166-desig.c @@ -1,18 +0,0 @@ -struct S { - int a, b, c; - char d[3]; - int e; -} s = { - .a = 1, - .b = 2, - .d = {[0] = 3, [2] = 5}, - .d = {[0] = 4, [1] = 6} -}; - -char m[] = {}; - -int -main(void) -{ - return sizeof(m) == s.d[2]; -} diff --git a/tests/execute/0167-array.c b/tests/execute/0167-array.c @@ -1,15 +0,0 @@ -int arr1[][3] = { - { 2, 7, 5, }, - { 5, 1, 2, }, -}; - -int arr2[2][3] = { - 2, 7, 5, - 5, 1, 2 -}; - -int -main(void) -{ - return !(arr1[1][2] == arr2[1][3]); -} diff --git a/tests/execute/0168-array.c b/tests/execute/0168-array.c @@ -1,16 +0,0 @@ -int arr[][3][5] = { - { - { 0, 0, 3, 5 }, - { 1, [3] = 6, 7 }, - }, - { - { 1, 2 }, - { [4] = 7, }, - }, -}; - -int -main(void) -{ - return !(arr[0][1][4] == arr[1][1][4]); -} diff --git a/tests/execute/0169-string.c b/tests/execute/0169-string.c @@ -1,27 +0,0 @@ -char s0[] = "foo"; -char s1[7] = "foo"; -char s2[2] = "foo"; -char s3[] = {"foo"}; -char *p = "foo"; - -int -cmp(char *s1, char *s2) -{ - while (*s1 && *s1++ != *s2++) - ; - return *s1; -} - -int -main() -{ - if (sizeof(s0) != 4 || cmp(s0, "foo")) - return 1; - if (cmp(s1, "foo")) - return 1; - if (s2[0] != 'f' || s2[1] != 'o') - return 1; - if (sizeof(s3) != 4 || cmp(s3, "foo")) - return 1; - return 0; -} diff --git a/tests/execute/0170-line.c b/tests/execute/0170-line.c @@ -1,13 +0,0 @@ -#undef line -#define line 1000 - -#line line -#if 1000 != __LINE__ - #error " # line line" not work as expected -#endif - -int -main() -{ - return 0; -} diff --git a/tests/execute/0171-macros.c b/tests/execute/0171-macros.c @@ -1,10 +0,0 @@ -#define X (2) -#define L (0) -#define H (1) -#define Q(x) x - -int -main(void) -{ - return X == L + H + Q(1); -} diff --git a/tests/execute/0172-hexa.c b/tests/execute/0172-hexa.c @@ -1,10 +0,0 @@ -int -main(void) -{ - return 0xa == 0xA && - 0xb == 0xB && - 0xc == 0xC && - 0xd == 0xD && - 0xe == 0xE && - 0xf == 0xF; -} diff --git a/tests/execute/0173-macro.c b/tests/execute/0173-macro.c @@ -1,13 +0,0 @@ -#define x f -#define y() f - -typedef struct { int f; } S; - -int -main() -{ - S s; - - s.x = 0; - return s.y(); -} diff --git a/tests/execute/0174-decay.c b/tests/execute/0174-decay.c @@ -1,24 +0,0 @@ -int -main(int argc, char *argv[]) -{ - int v[1]; - int (*p)[]; - int (*f1)(int ,char *[]); - int (*f2)(int ,char *[]); - - v[0] = 0; - p = &v; - f1 = &main; - f2 = main; - if (argc == 0) - return 1; - if ((****main)(0, 0)) - return 2; - if ((****f1)(0, 0)) - return 3; - if ((****f2)(0, 0)) - return 4; - if (!(*p)[0]) - return 0; - return 1; -} diff --git a/tests/execute/0175-defined.c b/tests/execute/0175-defined.c @@ -1,32 +0,0 @@ -#if defined X -X -#endif - -#if defined(X) -X -#endif - -#if X -X -#endif - -#define X 0 - -#if X -X -#endif - -#if defined(X) -int x = 0; -#endif - -#undef X -#define X 1 - -#if X -int -main() -{ - return 0; -} -#endif diff --git a/tests/execute/0176-macro.c b/tests/execute/0176-macro.c @@ -1,21 +0,0 @@ -#ifdef __STDC__ -#define __(proto) proto -#else -#define __(proto) () -#endif - -extern int func __((int, int)); - -int -main() -{ - int (*fun)(int,int) = func; - - return (*func)(1, 2); -} - -int -func(int a, int b) -{ - return a - b - 1; -} diff --git a/tests/execute/Makefile b/tests/execute/Makefile @@ -1,12 +0,0 @@ -.POSIX: - -all: tests - -tests: - CFLAGS='' SCCPREFIX=../../rootdir/ PATH=../../rootdir/bin:$$PATH ./chktest.sh < scc-tests.lst - -clean: - rm -f *.as *.o *.ir *.qbe *core test.log - -distclean: clean -dep: diff --git a/tests/execute/README b/tests/execute/README @@ -1,2 +0,0 @@ -These tests are taken from https://github.com/andrewchambers/qc. -All the credits for this test suite are for Andrew Chambers. diff --git a/tests/execute/chktest.sh b/tests/execute/chktest.sh @@ -1,18 +0,0 @@ -#!/bin/sh - -ttyflags=`stty -g` -trap "stty $ttyflags;tabs -8;rm -f a.out; exit 1" 0 1 2 3 15 -stty tabs -tabs 40 -ulimit -c 0 -rm -f test.log - -while read i state -do - echo $i >>test.log - printf "%s\t" $i - printf "%s" $state - rm -f a.out - (scc -Isysinclude $CFLAGS "$i" && ./a.out) 2>test.log && - echo "[OK]" || echo "[FAILED]" -done diff --git a/tests/execute/compose.sh b/tests/execute/compose.sh @@ -1,23 +0,0 @@ -#!/bin/sh - -rm -f tmp_test.c -rm -f tests.h -rm -f tmp_*.c - -(echo '#include "tests.h"' -echo 'int main()' -echo '{' - -for i in *-*.c -do - n=`echo $i | sed 's/\(.*\)-.*\.c/\1/'` - sed s/main/main_$n/ < $i > tmp_$n.c - echo "int main_$n();" >> tests.h - echo "main_$n();" - -done - -echo 'return 0;' -echo '}' -) > tmp_test.c - diff --git a/tests/execute/include/0062-include.h b/tests/execute/include/0062-include.h @@ -1,5 +0,0 @@ -#include "0062-include2.h" - -int -main() -{ diff --git a/tests/execute/include/0062-include2.h b/tests/execute/include/0062-include2.h @@ -1,2 +0,0 @@ -int x; - diff --git a/tests/execute/scc-tests.lst b/tests/execute/scc-tests.lst @@ -1,169 +0,0 @@ -0001-sanity.c -0002-expr.c -0003-local.c -0004-pointer.c -0005-ifstmt.c -0006-whilestmt.c -0007-forstmt.c -0008-dowhilestmt.c -0009-expr.c -0010-goto.c -0011-assign.c -0012-expr.c -0013-addridx.c -0014-assignidx.c -0015-localarray.c -0016-addrarray.c -0017-struct.c -0018-structptr.c -0019-selfrefstruct.c -0020-ptrptr.c -0021-intfunc.c -0022-typedef.c -0023-global.c -0024-typedefstruct.c -0025-string.c -0026-implicitret.c -0027-charval.c -0028-bor.c -0029-band.c -0030-bxor.c -0031-relop.c -0032-indec.c -0033-ptrindec.c -0034-logandor.c -0035-breakcont.c -0036-notneg.c -0037-assignop.c -0038-ptradd.c -0039-sizeof.c -0040-cast.c -0041-queen.c -0042-prime.c -0043-union.c -0044-struct.c -0045-struct.c -0046-inits.c -0048-inits.c -0049-inits.c -0050-inits.c -0052-switch.c -0053-struct.c -0054-struct.c -0055-enum.c -0056-enum.c -0057-duff.c -0058-bug.c -0059-multistring.c -0060-charlit.c -0061-comments.c -0062-include.c -0063-define.c -0064-sysinclude.c -0065-ifdef.c -0066-cppelse.c -0067-define.c -0068-funclikemacro.c -0069-funclikemacro.c -0070-cppif.c -0071-cppelif.c -0072-cppelif.c -0073-ifndef.c -0074-undef.c -0075-ptraddasn.c -0076-ptrsubasn.c -0077-defined.c -0078-dirifexpr.c -0079-cond.c -0080-arrays.c -0081-calls.c -0082-bug.c -0083-voidret.c -0084-longlong.c -0085-ulonglong.c -0089-short.c -0090-fptr.c -0091-fptr.c -0092-fptr.c -0093-arrayinit.c -0094-arrayinit.c [TODO] -0095-arrayselector.c -0096-inferredarraysize.c -0097-extern.c -0098-tentative.c [TODO] -0099-tentative.c [TODO] -0102-bug.c -0103-voidparm.c -0104-qbebug.c -0105-shl.c -0106-ppcast.c -0107-bnot.c -0108-bug.c -0109-struct.c -0110-typedefcast.c -0111-doubledef.c -0112-cond.c -0113-externredecl.c -0114-shortassig.c [TODO] -0115-null-comparision.c -0116-floatcmp.c [TODO] -0117-pointarith.c -0118-voidmain.c [TODO] -0119-macrostr.c -0120-funpar.c -0121-localinit.c [TODO] -0122-localinit.c [TODO] -0123-doubleconst.c [TODO] -0124-enumstruct.c [TODO] -0125-fundcl.c -0126-macropar.c [TODO] -0127-doublecte.c [TODO] -0128-kr_names.c -0129-initi.c [TODO] -0130-mulpars.c -0131-hello.c [TODO] -0132-forward.c [TODO] -0133-ftn-ptr.c [TODO] -0134-arith.c [TODO] -0135-unary.c [TODO] -0136-if.c [TODO] -0137-int-cast.c [TODO] -0138-namespace.c [TODO] -0139-ptr-ary.c [TODO] -0140-int-fold.c [TODO] -0141-int-iden.c [TODO] -0142-char-const.c [TODO] -0143-int-const.c [TODO] -0144-long-const.c [TODO] -0145-llong-const.c [TODO] -0146-ifdef.c [TODO] -0147-intern-cpp.c [TODO] -0148-cpp-string.c [TODO] -0149-define.c [TODO] -0150-define.c [TODO] -0151-vararg.c [TODO] -0152-cat.c [TODO] -0153-cpp-string.c [TODO] -0154-if-defined [TODO] -0155-struct-compl.c [TODO] -0156-duff2.c [TODO] -0157-list.c [TODO] -0158-ternary.c [TODO] -0159-typedef.c [TODO] -0160-cpp-if.c [TODO] -0161-struct.c [TODO] -0162-array.c [TODO] -0163-array.c [TODO] -0164-struct.c [TODO] -0165-struct.c [TODO] -0166-desig.c [TODO] -0167-array.c [TODO] -0168-array.c [TODO] -0169-string.c [TODO] -0170-line.c [TODO] -0171-macros.c [TODO] -0172-hexa.c [TODO] -0173-macro.c [TODO] -0174-decay.c [TODO] -0175-defined.c [TODO] -0176-macro.c [TODO] diff --git a/tests/execute/sysinclude/0064-sysinclude.h b/tests/execute/sysinclude/0064-sysinclude.h @@ -1,4 +0,0 @@ -#include "0064-sysinclude2.h" - -int x = 2; - diff --git a/tests/execute/sysinclude/0064-sysinclude2.h b/tests/execute/sysinclude/0064-sysinclude2.h @@ -1 +0,0 @@ -int y = 2; diff --git a/tests/scc/Makefile b/tests/scc/Makefile @@ -0,0 +1,7 @@ +.POSIX: +include ../../config.mk + +DIRS=error execute + +all clean: + $(FORALL) diff --git a/tests/error/0001-sanity.c b/tests/scc/error/0001-sanity.c diff --git a/tests/error/0002-missinginclude.c b/tests/scc/error/0002-missinginclude.c diff --git a/tests/error/0003-junkinclude.c b/tests/scc/error/0003-junkinclude.c diff --git a/tests/error/0004-macroredef.c b/tests/scc/error/0004-macroredef.c diff --git a/tests/error/0005-fmacro.c b/tests/scc/error/0005-fmacro.c diff --git a/tests/error/0006-endif.c b/tests/scc/error/0006-endif.c diff --git a/tests/error/0007-unmatchedcppif.c b/tests/scc/error/0007-unmatchedcppif.c diff --git a/tests/error/0008-unmatchedcppelse.c b/tests/scc/error/0008-unmatchedcppelse.c diff --git a/tests/error/0009-unmatchedcppelif.c b/tests/scc/error/0009-unmatchedcppelif.c diff --git a/tests/error/0010-extraelif.c b/tests/scc/error/0010-extraelif.c diff --git a/tests/error/0011-extraelse.c b/tests/scc/error/0011-extraelse.c diff --git a/tests/error/0012-ifnoexpr.c b/tests/scc/error/0012-ifnoexpr.c diff --git a/tests/error/0013-macro.c b/tests/scc/error/0013-macro.c diff --git a/tests/error/0014-macro.c b/tests/scc/error/0014-macro.c diff --git a/tests/error/0015-macro.c b/tests/scc/error/0015-macro.c diff --git a/tests/error/0016-arrayinitsize.c b/tests/scc/error/0016-arrayinitsize.c diff --git a/tests/error/0017-duplicatefunc.c b/tests/scc/error/0017-duplicatefunc.c diff --git a/tests/error/0018-voidparam.c b/tests/scc/error/0018-voidparam.c diff --git a/tests/error/0019-kr_names.c b/tests/scc/error/0019-kr_names.c diff --git a/tests/error/0020-storage.c b/tests/scc/error/0020-storage.c diff --git a/tests/error/0021-namespace.c b/tests/scc/error/0021-namespace.c diff --git a/tests/error/0021-void.c b/tests/scc/error/0021-void.c diff --git a/tests/error/0022-cpp-if.c b/tests/scc/error/0022-cpp-if.c diff --git a/tests/error/0023-include.c b/tests/scc/error/0023-include.c diff --git a/tests/error/0023-include.h b/tests/scc/error/0023-include.h diff --git a/tests/error/Makefile b/tests/scc/error/Makefile diff --git a/tests/error/README b/tests/scc/error/README diff --git a/tests/error/chktest.sh b/tests/scc/error/chktest.sh diff --git a/tests/error/scc-tests.lst b/tests/scc/error/scc-tests.lst diff --git a/tests/error/update.sh b/tests/scc/error/update.sh diff --git a/tests/execute/0001-sanity.c b/tests/scc/execute/0001-sanity.c diff --git a/tests/execute/0002-expr.c b/tests/scc/execute/0002-expr.c diff --git a/tests/execute/0003-local.c b/tests/scc/execute/0003-local.c diff --git a/tests/execute/0004-pointer.c b/tests/scc/execute/0004-pointer.c diff --git a/tests/execute/0005-ifstmt.c b/tests/scc/execute/0005-ifstmt.c diff --git a/tests/execute/0006-whilestmt.c b/tests/scc/execute/0006-whilestmt.c diff --git a/tests/execute/0007-forstmt.c b/tests/scc/execute/0007-forstmt.c diff --git a/tests/execute/0008-dowhilestmt.c b/tests/scc/execute/0008-dowhilestmt.c diff --git a/tests/execute/0009-expr.c b/tests/scc/execute/0009-expr.c diff --git a/tests/execute/0010-goto.c b/tests/scc/execute/0010-goto.c diff --git a/tests/execute/0011-assign.c b/tests/scc/execute/0011-assign.c diff --git a/tests/execute/0012-expr.c b/tests/scc/execute/0012-expr.c diff --git a/tests/execute/0013-addridx.c b/tests/scc/execute/0013-addridx.c diff --git a/tests/execute/0014-assignidx.c b/tests/scc/execute/0014-assignidx.c diff --git a/tests/execute/0015-localarray.c b/tests/scc/execute/0015-localarray.c diff --git a/tests/execute/0016-addrarray.c b/tests/scc/execute/0016-addrarray.c diff --git a/tests/execute/0017-struct.c b/tests/scc/execute/0017-struct.c diff --git a/tests/execute/0018-structptr.c b/tests/scc/execute/0018-structptr.c diff --git a/tests/execute/0019-selfrefstruct.c b/tests/scc/execute/0019-selfrefstruct.c diff --git a/tests/execute/0020-ptrptr.c b/tests/scc/execute/0020-ptrptr.c diff --git a/tests/execute/0021-intfunc.c b/tests/scc/execute/0021-intfunc.c diff --git a/tests/execute/0022-typedef.c b/tests/scc/execute/0022-typedef.c diff --git a/tests/execute/0023-global.c b/tests/scc/execute/0023-global.c diff --git a/tests/execute/0024-typedefstruct.c b/tests/scc/execute/0024-typedefstruct.c diff --git a/tests/execute/0025-string.c b/tests/scc/execute/0025-string.c diff --git a/tests/execute/0026-implicitret.c b/tests/scc/execute/0026-implicitret.c diff --git a/tests/execute/0027-charval.c b/tests/scc/execute/0027-charval.c diff --git a/tests/execute/0028-bor.c b/tests/scc/execute/0028-bor.c diff --git a/tests/execute/0029-band.c b/tests/scc/execute/0029-band.c diff --git a/tests/execute/0030-bxor.c b/tests/scc/execute/0030-bxor.c diff --git a/tests/execute/0031-relop.c b/tests/scc/execute/0031-relop.c diff --git a/tests/execute/0032-indec.c b/tests/scc/execute/0032-indec.c diff --git a/tests/execute/0033-ptrindec.c b/tests/scc/execute/0033-ptrindec.c diff --git a/tests/execute/0034-logandor.c b/tests/scc/execute/0034-logandor.c diff --git a/tests/execute/0035-breakcont.c b/tests/scc/execute/0035-breakcont.c diff --git a/tests/execute/0036-notneg.c b/tests/scc/execute/0036-notneg.c diff --git a/tests/execute/0037-assignop.c b/tests/scc/execute/0037-assignop.c diff --git a/tests/execute/0038-ptradd.c b/tests/scc/execute/0038-ptradd.c diff --git a/tests/execute/0039-sizeof.c b/tests/scc/execute/0039-sizeof.c diff --git a/tests/execute/0040-cast.c b/tests/scc/execute/0040-cast.c diff --git a/tests/execute/0041-queen.c b/tests/scc/execute/0041-queen.c diff --git a/tests/execute/0042-prime.c b/tests/scc/execute/0042-prime.c diff --git a/tests/execute/0043-union.c b/tests/scc/execute/0043-union.c diff --git a/tests/execute/0044-struct.c b/tests/scc/execute/0044-struct.c diff --git a/tests/execute/0045-struct.c b/tests/scc/execute/0045-struct.c diff --git a/tests/execute/0046-inits.c b/tests/scc/execute/0046-inits.c diff --git a/tests/execute/0047-anonexport.c b/tests/scc/execute/0047-anonexport.c diff --git a/tests/execute/0048-inits.c b/tests/scc/execute/0048-inits.c diff --git a/tests/execute/0049-inits.c b/tests/scc/execute/0049-inits.c diff --git a/tests/execute/0050-inits.c b/tests/scc/execute/0050-inits.c diff --git a/tests/execute/0051-inits.c b/tests/scc/execute/0051-inits.c diff --git a/tests/execute/0052-switch.c b/tests/scc/execute/0052-switch.c diff --git a/tests/execute/0053-struct.c b/tests/scc/execute/0053-struct.c diff --git a/tests/execute/0054-struct.c b/tests/scc/execute/0054-struct.c diff --git a/tests/execute/0055-enum.c b/tests/scc/execute/0055-enum.c diff --git a/tests/execute/0056-enum.c b/tests/scc/execute/0056-enum.c diff --git a/tests/execute/0057-duff.c b/tests/scc/execute/0057-duff.c diff --git a/tests/execute/0058-bug.c b/tests/scc/execute/0058-bug.c diff --git a/tests/execute/0059-multistring.c b/tests/scc/execute/0059-multistring.c diff --git a/tests/execute/0060-charlit.c b/tests/scc/execute/0060-charlit.c diff --git a/tests/execute/0061-comments.c b/tests/scc/execute/0061-comments.c diff --git a/tests/execute/0062-include.c b/tests/scc/execute/0062-include.c diff --git a/tests/execute/0063-define.c b/tests/scc/execute/0063-define.c diff --git a/tests/execute/0064-sysinclude.c b/tests/scc/execute/0064-sysinclude.c diff --git a/tests/execute/0065-ifdef.c b/tests/scc/execute/0065-ifdef.c diff --git a/tests/execute/0066-cppelse.c b/tests/scc/execute/0066-cppelse.c diff --git a/tests/execute/0067-define.c b/tests/scc/execute/0067-define.c diff --git a/tests/execute/0068-funclikemacro.c b/tests/scc/execute/0068-funclikemacro.c diff --git a/tests/execute/0069-funclikemacro.c b/tests/scc/execute/0069-funclikemacro.c diff --git a/tests/execute/0070-cppif.c b/tests/scc/execute/0070-cppif.c diff --git a/tests/execute/0071-cppelif.c b/tests/scc/execute/0071-cppelif.c diff --git a/tests/execute/0072-cppelif.c b/tests/scc/execute/0072-cppelif.c diff --git a/tests/execute/0073-ifndef.c b/tests/scc/execute/0073-ifndef.c diff --git a/tests/execute/0074-undef.c b/tests/scc/execute/0074-undef.c diff --git a/tests/execute/0075-ptraddasn.c b/tests/scc/execute/0075-ptraddasn.c diff --git a/tests/execute/0076-ptrsubasn.c b/tests/scc/execute/0076-ptrsubasn.c diff --git a/tests/execute/0077-defined.c b/tests/scc/execute/0077-defined.c diff --git a/tests/execute/0078-dirifexpr.c b/tests/scc/execute/0078-dirifexpr.c diff --git a/tests/execute/0079-cond.c b/tests/scc/execute/0079-cond.c diff --git a/tests/execute/0080-arrays.c b/tests/scc/execute/0080-arrays.c diff --git a/tests/execute/0081-calls.c b/tests/scc/execute/0081-calls.c diff --git a/tests/execute/0082-bug.c b/tests/scc/execute/0082-bug.c diff --git a/tests/execute/0083-voidret.c b/tests/scc/execute/0083-voidret.c diff --git a/tests/execute/0084-longlong.c b/tests/scc/execute/0084-longlong.c diff --git a/tests/execute/0085-ulonglong.c b/tests/scc/execute/0085-ulonglong.c diff --git a/tests/execute/0086-variadic.c b/tests/scc/execute/0086-variadic.c diff --git a/tests/execute/0087-variadic.c b/tests/scc/execute/0087-variadic.c diff --git a/tests/execute/0088-macros.c b/tests/scc/execute/0088-macros.c diff --git a/tests/execute/0089-short.c b/tests/scc/execute/0089-short.c diff --git a/tests/execute/0090-fptr.c b/tests/scc/execute/0090-fptr.c diff --git a/tests/execute/0091-fptr.c b/tests/scc/execute/0091-fptr.c diff --git a/tests/execute/0092-fptr.c b/tests/scc/execute/0092-fptr.c diff --git a/tests/execute/0093-arrayinit.c b/tests/scc/execute/0093-arrayinit.c diff --git a/tests/execute/0094-arrayinit.c b/tests/scc/execute/0094-arrayinit.c diff --git a/tests/execute/0095-arrayselector.c b/tests/scc/execute/0095-arrayselector.c diff --git a/tests/execute/0096-inferredarraysize.c b/tests/scc/execute/0096-inferredarraysize.c diff --git a/tests/execute/0097-extern.c b/tests/scc/execute/0097-extern.c diff --git a/tests/execute/0098-tentative.c b/tests/scc/execute/0098-tentative.c diff --git a/tests/execute/0099-tentative.c b/tests/scc/execute/0099-tentative.c diff --git a/tests/execute/0100-redeclaremacro.c b/tests/scc/execute/0100-redeclaremacro.c diff --git a/tests/execute/0101-wcharlit.c b/tests/scc/execute/0101-wcharlit.c diff --git a/tests/execute/0102-bug.c b/tests/scc/execute/0102-bug.c diff --git a/tests/execute/0103-voidparm.c b/tests/scc/execute/0103-voidparm.c diff --git a/tests/execute/0104-qbebug.c b/tests/scc/execute/0104-qbebug.c diff --git a/tests/execute/0105-shl.c b/tests/scc/execute/0105-shl.c diff --git a/tests/execute/0106-ppcast.c b/tests/scc/execute/0106-ppcast.c diff --git a/tests/execute/0107-bnot.c b/tests/scc/execute/0107-bnot.c diff --git a/tests/execute/0108-bug.c b/tests/scc/execute/0108-bug.c diff --git a/tests/execute/0109-struct.c b/tests/scc/execute/0109-struct.c diff --git a/tests/execute/0110-typedefcast.c b/tests/scc/execute/0110-typedefcast.c diff --git a/tests/execute/0111-doubledef.c b/tests/scc/execute/0111-doubledef.c diff --git a/tests/execute/0112-cond.c b/tests/scc/execute/0112-cond.c diff --git a/tests/execute/0113-externredecl.c b/tests/scc/execute/0113-externredecl.c diff --git a/tests/execute/0114-shortassig.c b/tests/scc/execute/0114-shortassig.c diff --git a/tests/execute/0115-null-comparision.c b/tests/scc/execute/0115-null-comparision.c diff --git a/tests/execute/0116-floatcmp.c b/tests/scc/execute/0116-floatcmp.c diff --git a/tests/execute/0117-pointarith.c b/tests/scc/execute/0117-pointarith.c diff --git a/tests/execute/0118-voidmain.c b/tests/scc/execute/0118-voidmain.c diff --git a/tests/execute/0119-macrostr.c b/tests/scc/execute/0119-macrostr.c diff --git a/tests/execute/0120-funpar.c b/tests/scc/execute/0120-funpar.c diff --git a/tests/execute/0121-localinit.c b/tests/scc/execute/0121-localinit.c diff --git a/tests/execute/0122-localinit.c b/tests/scc/execute/0122-localinit.c diff --git a/tests/execute/0123-doubleconst.c b/tests/scc/execute/0123-doubleconst.c diff --git a/tests/execute/0124-enumstruct.c b/tests/scc/execute/0124-enumstruct.c diff --git a/tests/execute/0125-fundcl.c b/tests/scc/execute/0125-fundcl.c diff --git a/tests/execute/0126-macropar.c b/tests/scc/execute/0126-macropar.c diff --git a/tests/execute/0127-doublecte.c b/tests/scc/execute/0127-doublecte.c diff --git a/tests/execute/0128-kr_names.c b/tests/scc/execute/0128-kr_names.c diff --git a/tests/execute/0129-initi.c b/tests/scc/execute/0129-initi.c diff --git a/tests/execute/0130-mulpars.c b/tests/scc/execute/0130-mulpars.c diff --git a/tests/execute/0131-hello.c b/tests/scc/execute/0131-hello.c diff --git a/tests/execute/0132-forward.c b/tests/scc/execute/0132-forward.c diff --git a/tests/execute/0133-ftn-ptr.c b/tests/scc/execute/0133-ftn-ptr.c diff --git a/tests/execute/0134-arith.c b/tests/scc/execute/0134-arith.c diff --git a/tests/execute/0135-unary.c b/tests/scc/execute/0135-unary.c diff --git a/tests/scc/execute/0136-if.c b/tests/scc/execute/0136-if.c @@ -0,0 +1,21 @@ +int c; + +int +main() +{ + if(0) { + return 1; + } else if(0) { + /* empty */ + } else { + if(1) { + if(c) + return 1; + else + return 0; + } else { + return 1; + } + } + return 1; +} diff --git a/tests/scc/execute/0137-int-cast.c b/tests/scc/execute/0137-int-cast.c @@ -0,0 +1,273 @@ +/* +name: TEST013 +description: Basic test of integer types and integer conversions +comments: This test depends of the configuration in the type system. + With the current configuration char is equal to unsigned char, + short is equal to int, and unsigned short is equal to unsigned. +error: +output: +G1 I "a +G2 N "b +G3 K "c +G4 C "d +G5 K "e +G6 W "f +G7 Z "g +G8 Q "h +G9 O "i +G10 I "j +G11 N "k +G13 I F "main +{ +\ + G1 G2 gI :I + G1 G3 gI :I + G1 G4 gI :I + G1 G5 gI :I + G1 G6 gI :I + G1 G7 gI :I + G1 G8 gI :I + G1 G9 gI :I + G1 G10 :I + G1 G11 gI :I + G2 G1 gN :N + G2 G3 gN :N + G2 G4 gN :N + G2 G5 gN :N + G2 G6 gN :N + G2 G7 gN :N + G2 G8 gN :N + G2 G9 gN :N + G2 G10 gN :N + G2 G11 :N + G3 G1 gK :K + G3 G2 gK :K + G3 G4 gK :K + G3 G5 :K + G3 G6 gK :K + G3 G7 gK :K + G3 G8 gK :K + G3 G9 gK :K + G3 G10 gK :K + G3 G11 gK :K + G4 G1 gC :C + G4 G2 gC :C + G4 G3 gC :C + G4 G5 gC :C + G4 G6 gC :C + G4 G7 gC :C + G4 G8 gC :C + G4 G9 gC :C + G4 G10 gC :C + G4 G11 gC :C + G5 G1 gK :K + G5 G2 gK :K + G5 G3 :K + G5 G4 gK :K + G5 G6 gK :K + G5 G7 gK :K + G5 G8 gK :K + G5 G9 gK :K + G5 G10 gK :K + G5 G11 gK :K + G6 G1 gW :W + G6 G2 gW :W + G6 G3 gW :W + G6 G4 gW :W + G6 G5 gW :W + G6 G7 gW :W + G6 G8 gW :W + G6 G9 gW :W + G6 G10 gW :W + G6 G11 gW :W + G7 G1 gZ :Z + G7 G2 gZ :Z + G7 G3 gZ :Z + G7 G4 gZ :Z + G7 G5 gZ :Z + G7 G6 gZ :Z + G7 G8 gZ :Z + G7 G9 gZ :Z + G7 G10 gZ :Z + G7 G11 gZ :Z + G8 G1 gQ :Q + G8 G2 gQ :Q + G8 G3 gQ :Q + G8 G4 gQ :Q + G8 G5 gQ :Q + G8 G6 gQ :Q + G8 G7 gQ :Q + G8 G9 gQ :Q + G8 G10 gQ :Q + G8 G11 gQ :Q + G9 G1 gO :O + G9 G2 gO :O + G9 G3 gO :O + G9 G4 gO :O + G9 G5 gO :O + G9 G6 gO :O + G9 G7 gO :O + G9 G8 gO :O + G9 G10 gO :O + G9 G11 gO :O + G10 G1 :I + G10 G2 gI :I + G10 G3 gI :I + G10 G4 gI :I + G10 G5 gI :I + G10 G6 gI :I + G10 G7 gI :I + G10 G8 gI :I + G10 G9 gI :I + G10 G11 gI :I + G11 G1 gN :N + G11 G2 :N + G11 G3 gN :N + G11 G4 gN :N + G11 G5 gN :N + G11 G6 gN :N + G11 G7 gN :N + G11 G8 gN :N + G11 G10 gN :N + G11 G9 gN :N +} +*/ + +int a; +unsigned b; +char c; +signed char d; +unsigned char e; +long f; +unsigned long g; +long long h; +unsigned long long i; +short j; +unsigned short k; + +int +main(void) +{ + a = b; + a = c; + a = d; + a = e; + a = f; + a = g; + a = h; + a = i; + a = j; + a = k; + + b = a; + b = c; + b = d; + b = e; + b = f; + b = g; + b = h; + b = i; + b = j; + b = k; + + c = a; + c = b; + c = d; + c = e; + c = f; + c = g; + c = h; + c = i; + c = j; + c = k; + + d = a; + d = b; + d = c; + d = e; + d = f; + d = g; + d = h; + d = i; + d = j; + d = k; + + e = a; + e = b; + e = c; + e = d; + e = f; + e = g; + e = h; + e = i; + e = j; + e = k; + + f = a; + f = b; + f = c; + f = d; + f = e; + f = g; + f = h; + f = i; + f = j; + f = k; + + g = a; + g = b; + g = c; + g = d; + g = e; + g = f; + g = h; + g = i; + g = j; + g = k; + + h = a; + h = b; + h = c; + h = d; + h = e; + h = f; + h = g; + h = i; + h = j; + h = k; + + i = a; + i = b; + i = c; + i = d; + i = e; + i = f; + i = g; + i = h; + i = j; + i = k; + + j = a; + j = b; + j = c; + j = d; + j = e; + j = f; + j = g; + j = h; + j = i; + j = k; + + k = a; + k = b; + k = c; + k = d; + k = e; + k = f; + k = g; + k = h; + k = j; + k = i; + + return 0; +} diff --git a/tests/scc/execute/0138-namespace.c b/tests/scc/execute/0138-namespace.c @@ -0,0 +1,30 @@ +typedef struct s s; + +struct s { + struct s1 { + int s; + struct s2 { + int s; + } s1; + } s; +} s2; + +#define s s + +int +main(void) +{ +#undef s + goto s; + struct s s; + { + int s; + return s; + } + return s.s.s + s.s.s1.s; + s: + { + return 0; + } + return 1; +} diff --git a/tests/scc/execute/0139-ptr-ary.c b/tests/scc/execute/0139-ptr-ary.c @@ -0,0 +1,22 @@ +int +main() +{ + char arr[2][4], (*p)[4], *q; + int v[4]; + + p = arr; + q = &arr[1][3]; + arr[1][3] = 2; + v[0] = 2; + + if (arr[1][3] != 2) + return 1; + if (p[1][3] != 2) + return 1; + if (*q != 2) + return 1; + if (*v != 2) + return 1; + + return 0; +} diff --git a/tests/scc/execute/0140-int-fold.c b/tests/scc/execute/0140-int-fold.c @@ -0,0 +1,27 @@ +int +main(void) +{ + int i; + + i = 1 + 2; + i = 2 - 1; + i = 3 * 6; + i = 10 / 5; + i = 10 % 5; + i = i % 0; + i = i % 0; + i = 1 << 3; + i = 8 >> 2; + i = 12 & 4; + i = 8 | 4; + i = 12 ^ 4; + i = -(3); + i = ~12; + i = 1 < 3; + i = 2 > 3; + i = 2 >= 3; + i = 2 <= 3; + i = 1 == 0; + + return 0; +} diff --git a/tests/scc/execute/0141-int-iden.c b/tests/scc/execute/0141-int-iden.c @@ -0,0 +1,37 @@ +int +main(void) +{ + int i; + + i = i || 0; + i = i || 4; + i = 4 || i; + i = 0 || i; + i = i && 0; + i = i && 4; + i = 4 && i; + i = 0 && i; + i = i << 0; + i = 0 << i; + i = i >> 0; + i = 0 >> i; + i = i + 0; + i = 0 + i; + i = i - 0; + i = 0 - i; + i = i | 0; + i = 0 | i; + i = i ^ 0; + i = 0 ^ i; + i = i * 0; + i = 0 * i; + i = i * 1; + i = 1 * i; + i = i / 1; + i = 1 / i; + i = i & ~0; + i = ~0 & i; + i = i % 1; + i = i / 0; + i = i % 0; +} diff --git a/tests/scc/execute/0142-char-const.c b/tests/scc/execute/0142-char-const.c @@ -0,0 +1,40 @@ +int +main(void) +{ + unsigned char uc; + signed char sc; + + uc = -1; + if ((uc & 0xFF) != 0xFF) + return 1; + + uc = '\x23'; + if (uc != 36) + return 1; + + uc = 1u; + if (uc != (1025 & 0xFF) + return 1; + + uc = 'A'; + if (uc != 0x41) + return 1; + + sc = -1; + if ((sc & 0xFF) != 0xFF) + return 1; + + sc = '\x23'; + if (sc != 36) + return 1; + + sc = 1u; + if (uc != (1025 & 0xFF) + return 1; + + sc = 'A'; + if (uc != 0x41) + return 1; + + return 0; +} diff --git a/tests/scc/execute/0143-int-const.c b/tests/scc/execute/0143-int-const.c @@ -0,0 +1,24 @@ +main(void) +{ + int i; + unsigned u; + + i = 1; + i = -1; + i = -1l; + i = -1u; + i = -1ll; + i = 32766 + 1 & 3; + i = (int) 32768 < 0; + i = -1u < 0; + + u = 1; + u = -1; + u = -1l; + u = -1u; + u = -1ll; + u = (unsigned) 32768 < 0; + u = 32766 + 1 & 3; + u = -1u < 0; + return 0; +} diff --git a/tests/scc/execute/0144-long-const.c b/tests/scc/execute/0144-long-const.c @@ -0,0 +1,25 @@ +int +main(void) +{ + long i; + unsigned long u; + + i = 1; + i = -1; + i = -1l; + i = -1u; + i = -1ll; + i = (1ll << 32) - 1 & 3; + i = (long) ((1ll << 32) - 1) < 0; + i = -1u < 0; + + u = 1; + u = -1; + u = -1l; + u = -1u; + u = -1ll; + u = (1ll << 32) - 1 & 3; + u = (long) ((1ll << 32) - 1) < 0; + u = -1u < 0; + return 0; +} diff --git a/tests/scc/execute/0145-llong-const.c b/tests/scc/execute/0145-llong-const.c @@ -0,0 +1,23 @@ +int +main(void) +{ + long long i; + unsigned long long u; + + i = 1; + i = -1; + i = -1l; + i = -1u; + i = -1ll; + i = -1ll & 3; + i = -1ll < 0; + + u = 1; + u = -1; + u = -1l; + u = -1u; + u = -1ll; + u = -1llu & 3; + u = -1llu < 0; + return 0; +} diff --git a/tests/scc/execute/0146-ifdef.c b/tests/scc/execute/0146-ifdef.c @@ -0,0 +1,52 @@ +#define FOO + +#ifdef FOO + int a; + int b; + #undef FOO + #ifndef FOO + int c; + int d; + #else + int e; + int f; + #endif + int e; + int f; + #ifdef FOO + int c_; + int d_; + #else + int e_; + int f_; + #endif + int e_; + int f_; +int +main() +{ + return 0; +} +#else + int j; + int k; + #ifdef FOO + int j; + int k; + #else + int n; + int o; + #endif + int n; + int o; + #ifndef FOO + int r; + int s; + #else + int t; + int u; + #endif + int t; + int u; + #error bad branch +#endif diff --git a/tests/scc/execute/0147-intern-cpp.c b/tests/scc/execute/0147-intern-cpp.c @@ -0,0 +1,19 @@ +#define x(y) (y) + +int +main(void) +{ + int y; + char *p; + + p = __FILE__; + y = __LINE__; + p = __DATE__; + y = __STDC__; + p = __TIME__; + y = __STDC_HOSTED__; + y = __SCC__; + y = x(1); + + return 0; +} diff --git a/tests/scc/execute/0148-cpp-string.c b/tests/scc/execute/0148-cpp-string.c @@ -0,0 +1,10 @@ +#define x(y) #y + +int +main(void) +{ + char *p; + p = x(hello) " is better than bye"; + + return (*p == 'h') ? 0 : 1; +} diff --git a/tests/scc/execute/0149-define.c b/tests/scc/execute/0149-define.c @@ -0,0 +1,10 @@ +#define M(x) x +#define A(a,b) a(b) + +int +main(void) +{ + char *a = A(M,"hi"); + + return (a[1] == 'i') ? 0 : 1; +} diff --git a/tests/scc/execute/0150-define.c b/tests/scc/execute/0150-define.c @@ -0,0 +1,15 @@ +/* + * f(2) will expand to 2*g, which will expand to 2*f, and in this + * moment f will not be expanded because the macro definition is + * a function alike macro, and in this case there is no arguments. + */ +#define f(a) a*g +#define g f + +int +main(void) +{ + int f = 0; + + return f(2); +} diff --git a/tests/scc/execute/0151-vararg.c b/tests/scc/execute/0151-vararg.c @@ -0,0 +1,25 @@ +struct foo { + int i, j, k; + char *p; + float v; +}; + +int +f1(struct foo f, struct foo *p, int n, ...) +{ + if (f.i != p->i) + return 0; + return p->j + n; +} + +int +main(void) +{ + struct foo f; + + f.i = f.j = 1; + f1(f, &f, 2); + f1(f, &f, 2, 1, f, &f); + + return 0; +} diff --git a/tests/scc/execute/0152-cat.c b/tests/scc/execute/0152-cat.c @@ -0,0 +1,14 @@ +#define CAT(x,y) x ## y +#define XCAT(x,y) CAT(x,y) +#define FOO foo +#define BAR bar + +int +main(void) +{ + int foo, bar, foobar; + + CAT(foo,bar) = foo + bar; + XCAT(FOO,BAR) = foo + bar; + return 0; +} diff --git a/tests/scc/execute/0153-cpp-string.c b/tests/scc/execute/0153-cpp-string.c @@ -0,0 +1,13 @@ +#define M1(x) "This is a string $ or # or ## " ## #x +#define STR "This is a string $ or # or ## and it is ok!" + +int +main(void) +{ + char *s, *t = M1(and it is ok!); + + for (s = STR; *s && *s == *t; ++s) + ++t; + + return *s; +} diff --git a/tests/scc/execute/0154-if-defined b/tests/scc/execute/0154-if-defined @@ -0,0 +1,15 @@ +#if defined(FOO) +int a; +#elif !defined(FOO) && defined(BAR) +int b; +#elif !defined(FOO) && !defined(BAR) +int c; +#else +int d; +#endif + +int +main(void) +{ + return c; +} diff --git a/tests/scc/execute/0155-struct-compl.c b/tests/scc/execute/0155-struct-compl.c @@ -0,0 +1,16 @@ +extern struct X x; +int foo(); + +int main() +{ + extern struct X x; + return &x != 0; +} + +struct X {int v;}; + +int foo() +{ + x.v = 0; + return x.v; +} diff --git a/tests/scc/execute/0156-duff2.c b/tests/scc/execute/0156-duff2.c @@ -0,0 +1,35 @@ +/* + * Disgusting, no? But it compiles and runs just fine. I feel a + * combination of pride and revulsion at this discovery. If no one's + * thought of it before, I think I'll name it after myself. It amazes + * me that after 10 years of writing C there are still little corners + * that I haven't explored fully. + * - Tom Duff + */ +send(to, from, count) + register short *to, *from; + register count; +{ + register n=(count+7)/8; + switch(count%8){ + case 0: do{*to = *from++; + case 7: *to = *from++; + case 6: *to = *from++; + case 5: *to = *from++; + case 4: *to = *from++; + case 3: *to = *from++; + case 2: *to = *from++; + case 1: *to = *from++; + }while(--n>0); + } +} + +int +main() +{ + short a, b[40]; + + send(&a, b, 40); + + return (a == b[39]) ? 0 : 1; +} diff --git a/tests/scc/execute/0157-list.c b/tests/scc/execute/0157-list.c @@ -0,0 +1,14 @@ +typedef struct List List; +struct List { + int len; + struct List *head; + List *back; +}; + +int +main(void) +{ + List List; + + return List.len; +} diff --git a/tests/scc/execute/0158-ternary.c b/tests/scc/execute/0158-ternary.c @@ -0,0 +1,17 @@ +int +main(void) +{ + int i, *q; + void *p; + + i = i ? 0 : 0l; + p = i ? (void *) 0 : 0; + p = i ? 0 : (void *) 0; + p = i ? 0 : (const void *) 0; + q = i ? 0 : p; + q = i ? p : 0; + q = i ? q : 0; + q = i ? 0 : q; + + return (int) q; +} diff --git a/tests/scc/execute/0159-typedef.c b/tests/scc/execute/0159-typedef.c @@ -0,0 +1,24 @@ +/* Taken from plan9 kernel */ + +typedef struct Clock0link Clock0link; +typedef struct Clock0link { + int (*clock)(void); + Clock0link* link; +} Clock0link; + + +int +f(void) +{ + return 0; +} + +Clock0link cl0 = { + .clock = f; +}; + +int +main(void) +{ + return (*cl0.clock)(); +} diff --git a/tests/scc/execute/0160-cpp-if.c b/tests/scc/execute/0160-cpp-if.c @@ -0,0 +1,17 @@ +#if 0 != (0 && (0/0)) + #error 0 != (0 && (0/0)) +#endif + +#if 1 != (-1 || (0/0)) + #error 1 != (-1 || (0/0)) +#endif + +#if 3 != (-1 ? 3 : (0/0)) + #error 3 != (-1 ? 3 : (0/0)) +#endif + +int +main() +{ + return 0; +} diff --git a/tests/scc/execute/0161-struct.c b/tests/scc/execute/0161-struct.c @@ -0,0 +1,12 @@ +struct S { int a; int b; }; +struct S s = (struct S){1, 2}; + +int +main() +{ + if(s.a != 1) + return 1; + if(s.b != 2) + return 2; + return 0; +} diff --git a/tests/scc/execute/0162-array.c b/tests/scc/execute/0162-array.c @@ -0,0 +1,13 @@ +int arr[3] = {[2] = 2, [0] = 0, [1] = 1}; + +int +main() +{ + if(arr[0] != 0) + return 1; + if(arr[1] != 1) + return 2; + if(arr[2] != 2) + return 3; + return 0; +} diff --git a/tests/scc/execute/0163-array.c b/tests/scc/execute/0163-array.c @@ -0,0 +1,16 @@ +struct S {int a; int b;}; +struct S arr[2] = {[1] = {3, 4}, [0] = {1, 2}}; + +int +main() +{ + if(arr[0].a != 1) + return 1; + if(arr[0].b != 2) + return 2; + if(arr[1].a != 3) + return 3; + if(arr[1].b != 4) + return 4; + return 0; +} diff --git a/tests/scc/execute/0164-struct.c b/tests/scc/execute/0164-struct.c @@ -0,0 +1,12 @@ +struct S { int a; int b; }; +struct S *s = &(struct S) { 1, 2 }; + +int +main() +{ + if(s->a != 1) + return 1; + if(s->b != 2) + return 2; + return 0; +} diff --git a/tests/scc/execute/0165-struct.c b/tests/scc/execute/0165-struct.c @@ -0,0 +1,33 @@ +struct S1 { + int a; + int b; +}; +struct S2 { + struct S1 s1; + struct S1 *ps1; + int arr[2]; +}; +struct S1 gs1 = (struct S1) {.a = 1, 2}; +struct S2 *s = &(struct S2) { + {.b = 2, .a = 1}, + &gs1, + {[0] = 1, 1+1} +}; + +int +main() +{ + if(s->s1.a != 1) + return 1; + if(s->s1.b != 2) + return 2; + if(s->ps1->a != 1) + return 3; + if(s->ps1->b != 2) + return 4; + if(s->arr[0] != 1) + return 5; + if(s->arr[1] != 2) + return 6; + return 0; +} diff --git a/tests/scc/execute/0166-desig.c b/tests/scc/execute/0166-desig.c @@ -0,0 +1,18 @@ +struct S { + int a, b, c; + char d[3]; + int e; +} s = { + .a = 1, + .b = 2, + .d = {[0] = 3, [2] = 5}, + .d = {[0] = 4, [1] = 6} +}; + +char m[] = {}; + +int +main(void) +{ + return sizeof(m) == s.d[2]; +} diff --git a/tests/scc/execute/0167-array.c b/tests/scc/execute/0167-array.c @@ -0,0 +1,15 @@ +int arr1[][3] = { + { 2, 7, 5, }, + { 5, 1, 2, }, +}; + +int arr2[2][3] = { + 2, 7, 5, + 5, 1, 2 +}; + +int +main(void) +{ + return !(arr1[1][2] == arr2[1][3]); +} diff --git a/tests/scc/execute/0168-array.c b/tests/scc/execute/0168-array.c @@ -0,0 +1,16 @@ +int arr[][3][5] = { + { + { 0, 0, 3, 5 }, + { 1, [3] = 6, 7 }, + }, + { + { 1, 2 }, + { [4] = 7, }, + }, +}; + +int +main(void) +{ + return !(arr[0][1][4] == arr[1][1][4]); +} diff --git a/tests/scc/execute/0169-string.c b/tests/scc/execute/0169-string.c @@ -0,0 +1,27 @@ +char s0[] = "foo"; +char s1[7] = "foo"; +char s2[2] = "foo"; +char s3[] = {"foo"}; +char *p = "foo"; + +int +cmp(char *s1, char *s2) +{ + while (*s1 && *s1++ != *s2++) + ; + return *s1; +} + +int +main() +{ + if (sizeof(s0) != 4 || cmp(s0, "foo")) + return 1; + if (cmp(s1, "foo")) + return 1; + if (s2[0] != 'f' || s2[1] != 'o') + return 1; + if (sizeof(s3) != 4 || cmp(s3, "foo")) + return 1; + return 0; +} diff --git a/tests/scc/execute/0170-line.c b/tests/scc/execute/0170-line.c @@ -0,0 +1,13 @@ +#undef line +#define line 1000 + +#line line +#if 1000 != __LINE__ + #error " # line line" not work as expected +#endif + +int +main() +{ + return 0; +} diff --git a/tests/scc/execute/0171-macros.c b/tests/scc/execute/0171-macros.c @@ -0,0 +1,10 @@ +#define X (2) +#define L (0) +#define H (1) +#define Q(x) x + +int +main(void) +{ + return X == L + H + Q(1); +} diff --git a/tests/scc/execute/0172-hexa.c b/tests/scc/execute/0172-hexa.c @@ -0,0 +1,10 @@ +int +main(void) +{ + return 0xa == 0xA && + 0xb == 0xB && + 0xc == 0xC && + 0xd == 0xD && + 0xe == 0xE && + 0xf == 0xF; +} diff --git a/tests/scc/execute/0173-macro.c b/tests/scc/execute/0173-macro.c @@ -0,0 +1,13 @@ +#define x f +#define y() f + +typedef struct { int f; } S; + +int +main() +{ + S s; + + s.x = 0; + return s.y(); +} diff --git a/tests/scc/execute/0174-decay.c b/tests/scc/execute/0174-decay.c @@ -0,0 +1,24 @@ +int +main(int argc, char *argv[]) +{ + int v[1]; + int (*p)[]; + int (*f1)(int ,char *[]); + int (*f2)(int ,char *[]); + + v[0] = 0; + p = &v; + f1 = &main; + f2 = main; + if (argc == 0) + return 1; + if ((****main)(0, 0)) + return 2; + if ((****f1)(0, 0)) + return 3; + if ((****f2)(0, 0)) + return 4; + if (!(*p)[0]) + return 0; + return 1; +} diff --git a/tests/execute/0077-defined.c b/tests/scc/execute/0175-defined.c diff --git a/tests/scc/execute/0176-macro.c b/tests/scc/execute/0176-macro.c @@ -0,0 +1,21 @@ +#ifdef __STDC__ +#define __(proto) proto +#else +#define __(proto) () +#endif + +extern int func __((int, int)); + +int +main() +{ + int (*fun)(int,int) = func; + + return (*func)(1, 2); +} + +int +func(int a, int b) +{ + return a - b - 1; +} diff --git a/tests/scc/execute/0177-literal.c b/tests/scc/execute/0177-literal.c @@ -0,0 +1,9 @@ +void boo(int *p) +{ + return (*p[1] == 2) ? 0 : 1; +} + +int main() +{ + return boo((int[]) {0, 2}); +} diff --git a/tests/scc/execute/Makefile b/tests/scc/execute/Makefile @@ -0,0 +1,10 @@ +.POSIX: + +all: tests + +tests: + CFLAGS='' SCCPREFIX=../../rootdir/ PATH=../../rootdir/bin:$$PATH ./chktest.sh scc-tests.lst + +clean: + rm -f *.as *.o *.ir *.qbe *core test.log + diff --git a/tests/error/README b/tests/scc/execute/README diff --git a/tests/scc/execute/chktest.sh b/tests/scc/execute/chktest.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +file=${1?' empty input file'} +ttyflags=`stty -g` +trap "stty $ttyflags;tabs -8;rm -f a.out; exit 1" 0 1 2 3 15 +stty tabs +tabs 40 +ulimit -c 0 +rm -f test.log + +cat $file | +while read i state +do + echo $i >>test.log + printf "%s\t" $i + printf "%s" $state + rm -f a.out + (scc -Isysinclude $CFLAGS "$i" && ./a.out) 2>test.log && + echo "[OK]" || echo "[FAILED]" +done diff --git a/tests/scc/execute/compose.sh b/tests/scc/execute/compose.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +rm -f tmp_test.c +rm -f tests.h +rm -f tmp_*.c + +(echo '#include "tests.h"' +echo 'int main()' +echo '{' + +for i in *-*.c +do + n=`echo $i | sed 's/\(.*\)-.*\.c/\1/'` + sed s/main/main_$n/ < $i > tmp_$n.c + echo "int main_$n();" >> tests.h + echo "main_$n();" + +done + +echo 'return 0;' +echo '}' +) > tmp_test.c + diff --git a/tests/scc/execute/include/0062-include.h b/tests/scc/execute/include/0062-include.h @@ -0,0 +1,5 @@ +#include "0062-include2.h" + +int +main() +{ diff --git a/tests/scc/execute/include/0062-include2.h b/tests/scc/execute/include/0062-include2.h @@ -0,0 +1,2 @@ +int x; + diff --git a/tests/scc/execute/scc-tests.lst b/tests/scc/execute/scc-tests.lst @@ -0,0 +1,170 @@ +0001-sanity.c +0002-expr.c +0003-local.c +0004-pointer.c +0005-ifstmt.c +0006-whilestmt.c +0007-forstmt.c +0008-dowhilestmt.c +0009-expr.c +0010-goto.c +0011-assign.c +0012-expr.c +0013-addridx.c +0014-assignidx.c +0015-localarray.c +0016-addrarray.c +0017-struct.c +0018-structptr.c +0019-selfrefstruct.c +0020-ptrptr.c +0021-intfunc.c +0022-typedef.c +0023-global.c +0024-typedefstruct.c +0025-string.c +0026-implicitret.c +0027-charval.c +0028-bor.c +0029-band.c +0030-bxor.c +0031-relop.c +0032-indec.c +0033-ptrindec.c +0034-logandor.c +0035-breakcont.c +0036-notneg.c +0037-assignop.c +0038-ptradd.c +0039-sizeof.c +0040-cast.c +0041-queen.c +0042-prime.c +0043-union.c +0044-struct.c +0045-struct.c +0046-inits.c +0048-inits.c +0049-inits.c +0050-inits.c +0052-switch.c +0053-struct.c +0054-struct.c +0055-enum.c +0056-enum.c +0057-duff.c +0058-bug.c +0059-multistring.c +0060-charlit.c +0061-comments.c +0062-include.c +0063-define.c +0064-sysinclude.c +0065-ifdef.c +0066-cppelse.c +0067-define.c +0068-funclikemacro.c +0069-funclikemacro.c +0070-cppif.c +0071-cppelif.c +0072-cppelif.c +0073-ifndef.c +0074-undef.c +0075-ptraddasn.c +0076-ptrsubasn.c +0077-defined.c +0078-dirifexpr.c +0079-cond.c +0080-arrays.c +0081-calls.c +0082-bug.c +0083-voidret.c +0084-longlong.c +0085-ulonglong.c +0089-short.c +0090-fptr.c +0091-fptr.c +0092-fptr.c +0093-arrayinit.c +0094-arrayinit.c [TODO] +0095-arrayselector.c +0096-inferredarraysize.c +0097-extern.c +0098-tentative.c [TODO] +0099-tentative.c [TODO] +0102-bug.c +0103-voidparm.c +0104-qbebug.c +0105-shl.c +0106-ppcast.c +0107-bnot.c +0108-bug.c +0109-struct.c +0110-typedefcast.c +0111-doubledef.c +0112-cond.c +0113-externredecl.c +0114-shortassig.c [TODO] +0115-null-comparision.c +0116-floatcmp.c [TODO] +0117-pointarith.c +0118-voidmain.c [TODO] +0119-macrostr.c +0120-funpar.c +0121-localinit.c [TODO] +0122-localinit.c [TODO] +0123-doubleconst.c [TODO] +0124-enumstruct.c [TODO] +0125-fundcl.c +0126-macropar.c [TODO] +0127-doublecte.c [TODO] +0128-kr_names.c +0129-initi.c [TODO] +0130-mulpars.c +0131-hello.c [TODO] +0132-forward.c [TODO] +0133-ftn-ptr.c [TODO] +0134-arith.c [TODO] +0135-unary.c [TODO] +0136-if.c [TODO] +0137-int-cast.c [TODO] +0138-namespace.c [TODO] +0139-ptr-ary.c [TODO] +0140-int-fold.c [TODO] +0141-int-iden.c [TODO] +0142-char-const.c [TODO] +0143-int-const.c [TODO] +0144-long-const.c [TODO] +0145-llong-const.c [TODO] +0146-ifdef.c [TODO] +0147-intern-cpp.c [TODO] +0148-cpp-string.c [TODO] +0149-define.c [TODO] +0150-define.c [TODO] +0151-vararg.c [TODO] +0152-cat.c [TODO] +0153-cpp-string.c [TODO] +0154-if-defined [TODO] +0155-struct-compl.c [TODO] +0156-duff2.c [TODO] +0157-list.c [TODO] +0158-ternary.c [TODO] +0159-typedef.c [TODO] +0160-cpp-if.c [TODO] +0161-struct.c [TODO] +0162-array.c [TODO] +0163-array.c [TODO] +0164-struct.c [TODO] +0165-struct.c [TODO] +0166-desig.c [TODO] +0167-array.c [TODO] +0168-array.c [TODO] +0169-string.c [TODO] +0170-line.c [TODO] +0171-macros.c [TODO] +0172-hexa.c [TODO] +0173-macro.c [TODO] +0174-decay.c [TODO] +0175-defined.c [TODO] +0176-macro.c [TODO] +0177-literal.c [TODO] diff --git a/tests/scc/execute/sysinclude/0064-sysinclude.h b/tests/scc/execute/sysinclude/0064-sysinclude.h @@ -0,0 +1,4 @@ +#include "0064-sysinclude2.h" + +int x = 2; + diff --git a/tests/scc/execute/sysinclude/0064-sysinclude2.h b/tests/scc/execute/sysinclude/0064-sysinclude2.h @@ -0,0 +1 @@ +int y = 2;