From 673f690a37f6673a3262e933709c79de8a66f48c Mon Sep 17 00:00:00 2001 From: Robert de Bath Date: Mon, 22 Jul 2002 23:35:31 +0200 Subject: Import Dev86src-0.16.4.tar.gz --- bcc/assign.c | 2 +- bcc/bcc.bugs | 169 --------------------------------------------------------- bcc/bcc.c | 76 +++++++++++++++++--------- bcc/declare.c | 20 ++++++- bcc/patch.file | 157 +++++++++++++++++++++++++++++++++++++++++++++++++++++ bcc/proto.h | 2 +- bcc/q | 112 ++++++++++++++++++++++++++++++++++++++ bcc/scan.h | 1 + bcc/table.c | 3 +- bcc/type.c | 19 +++++++ 10 files changed, 360 insertions(+), 201 deletions(-) delete mode 100644 bcc/bcc.bugs create mode 100644 bcc/patch.file create mode 100644 bcc/q (limited to 'bcc') diff --git a/bcc/assign.c b/bcc/assign.c index 5f25cc0..2dce7c4 100644 --- a/bcc/assign.c +++ b/bcc/assign.c @@ -316,7 +316,7 @@ struct symstruct *target; extend(target); load(target, DREG); target->storage = targreg = getindexreg(); - if (oldscalar & (UNSIGNED | CHAR) || + if (oldscalar & UNSIGNED || target->type->constructor & (ARRAY | FUNCTION | POINTER)) uitol(targreg); else diff --git a/bcc/bcc.bugs b/bcc/bcc.bugs deleted file mode 100644 index 52f6958..0000000 --- a/bcc/bcc.bugs +++ /dev/null @@ -1,169 +0,0 @@ -compiler limitations --------------------- - -These are not implemented: - -a. bit fields - kludgily implemented (everything padded to char, int or long; can store - values wider than the specified field width) - -g. signed char type, other ANSI extensions - -compiler bugs -------------- - -6. weird but doable casts are not always done for initializers - -15. calls to a (casted) absolute address produce an immediate prefix. as386 - doesn't mind this but complains about the absolute address. as09 complains - about the prefix but can handle the absolute address - -23. char *f(); &f() is accepted as f() but produces botched nodetype - (calc char **). - -31. null byte in string initialiser should be ignored if it doesn't fit - Non-null bytes which don't fit should be ignored with a warning - -32. static char c = "xyz"; is allowed, and bad FCB is generated - -37. init of union will store multiple comma-separated entries - -38. arrays sizes larger than the amount of memory are accepted - -40. structure and union definitions are confused with each other. So - struct foo may be used in a declaration like "union foo bar;" - -42. pointer arithmetic is performed on pointers to undefined structures - (of unknown size). Size is taken as 0 although alignmask is set early - -59. preprocessor stuff (# lines or macro names) between the identifier for - a label and the colon for the label messes up the label - -60. some things involving switches are now broken for 6809 due to lack of - frame pointer - -61. assembler may get lost on lines of length exactly (?) 256 - -65. expressions in emum lists or not properly checked for overflow. They - should fit in ints. The ordinal number is allowed to overflow - -66. sizeof has type int instead of size_t - -68. "return expr;" in a function returning a void is reported as a compiler - bug not as a semantic error - -69. an argument declared as float is (correctly) promoted to double, but - not demoted to float when it is used - -71. identifiers longer than 64 are botched (scanning of the identifier is - stopped but the remaining characters in the identifier are left to - mess up the input stream - -72. check for too many macro parameters is not working - -74. union { char a, b; } foo; gives the wrong offset for b. Unions work OK - if the declaration lists have length 1 - -75. stack gets cleaned up too early in bee = foo ? bar : baz() where baz() - returns a struct although there is kludge to make plain bee = baz() work - -76. have reintroduced reduced-type bugs, so sizeof(1 ? 1 : 2) is 1 - -78. fix to require comma in arg list may be half-baked - -79. compiler starts trying to load the void expression (i ? (void)0 : (void)0) - -80. (unsigned char *) - (char *) causes error and message is obscure - -81. 'defined' is a reserved word - -82. conditionals with voids don't work - -83. float = 1e100 gets overflow exception - -84. #endif seems to be seen in -#if 1 -foo #endif bar - -85. line numbers from cpp are not quite right. - -bugs that may be fixed ----------------------- - -41. typedef's are not scoped properly - -nonstandard things that are not done quite right ------------------------------------------------- - -3. arguments declared as register are not being dumped by #asm, register - vars anyway not being passed to #asm - -26. should clear label ptrs when starting #asm - -things that have to be be done better -------------------------------------- - -11. push order reversed in genloads.c (temp) - might try to get DP order right - -12. need to clean up handling of sc specs (maybe rename flags to sc) - And local statics and externs - -24. gvarsc is not returned properly for struct/union since the members - affect gvarsc (incorrectly). There should be a flag set when - inside a struct/union definition to disable sc specs. This could - replace the tests in abdeclarator and declselt - Best may be to carry the sc along with the type a bit more (in a - global symbol structure). Also, the symbol should record sc in a better - way than now - -25. need to check stack sometimes. Xenix cc does it when allocating >= 100 - bytes locals and this is essential in Xenix as the stack is grown - dynamically - -68. overflow checking for constants - -things that could be done better --------------------------------- - -4. install new 6809 code for branch patching (after redundancy checks) - -5. can improve code for compare with global adr in non-posindependent case - -6. char *s; long *pl; - code for *s += *pl is poor, for *s += (int) *pl is good - -7. most mov's from to ax would be faster and smaller done by xchg's - -7a. check ptr add/sub operations earlier - -8. tests for against 1 and -1 can sometimes be done with dec's and inc's - -9. __opreg is used unnec when the ptr is already in it - -9a. double indirect ptrs should maybe be made direct rather than singly - indirect by makelessindirect - -10. in cmpsmallconst(), the comparison constant should be incorporated in - the offset if the indcount is 0 and lea() called. It is harmless to - use the lea() trick for non-small constants - -20. when saved registers are popped in assign() they may overwrite the - expression value, anywhere else? May be fixed now - -27. better if loadexpression returned the register used - -28. better if source.c did not #include storage.h - it only references - DEFINITION, in some blank-skipping code which could be moved to - scan.c or preproc.c. preproc.c, scan.c and type.c also #include - storage.h, just to get at the DEFINITION and KEYWORD definitions - -29. need nodetype() to know about all optimisations in advance, including - int % small power of 2 (including 0, 1). Need to delete all type - assignments in final code gen, specially the one that convert short - to int - -30. overflow checking at runtime - -31. Use more than the first char from multiple character constants - -56. --i++ is not detected as an error in the parser diff --git a/bcc/bcc.c b/bcc/bcc.c index 4717315..36024df 100644 --- a/bcc/bcc.c +++ b/bcc/bcc.c @@ -143,6 +143,7 @@ void newfilename P((struct file_list * file, int last_stage, int new_extn, int u void run_unlink P((void)); void append_file P((char * filename, int ftype)); void append_option P((char * option, int otype)); +void prepend_option P((char * option, int otype)); char * expand_tilde P((char * str)); void * xalloc P((int size)); void Usage P((void)); @@ -182,8 +183,7 @@ char * exec_prefixs[] = { #endif "~/lib/", "~/bin/", - "/usr/bin/", - 0 + 0 /* Last chance is contents of $PATH */ }; char * libc = "-lc"; @@ -397,6 +397,7 @@ struct file_list * file; command_reset(); newfilename(file, !do_link, 'o', 1); command_opt("-r"); + command_opt("-N"); run_command(file); } } @@ -654,7 +655,7 @@ char ** argv; do_unproto = 1; opt_e = 1; /* NOTE I'm setting this to zero, this isn't a _real_ STDC */ - append_option("-D__STDC__=0", 'p'); + prepend_option("-D__STDC__=0", 'p'); } else Usage(); @@ -750,7 +751,7 @@ char ** argv; do_optim=1; break; - case 'G': opt_M = 'G'; break; + case 'G': opt_M = 'g'; break; case 'v': opt_v++; break; case 'V': opt_V++; break; @@ -762,8 +763,8 @@ char ** argv; case 'W': opt_W++; break; - case '0': opt_arch=0; opt_M='x'; break; - case '3': opt_arch=1; opt_M='x'; break; + case '0': opt_arch=0; break; + case '3': opt_arch=1; break; case 'w': /*IGNORED*/ break; case 'g': /*IGNORED*/ break; @@ -809,55 +810,57 @@ char ** argv; if (opt_M==0) opt_M = (opt_arch==1 ?'l':'n'); switch(opt_M) { - case 'n': - append_option("-D__ELKS__", 'p'); - append_option("-D__unix__", 'p'); + case 'n': /* Normal Elks */ + prepend_option("-D__unix__", 'p'); + prepend_option("-D__ELKS__", 'p'); libc="-lc"; break; - case 'f': - append_option("-D__ELKS__", 'p'); - append_option("-D__unix__", 'p'); + case 'f': /* Fast Call Elks */ + prepend_option("-D__unix__", 'p'); + prepend_option("-D__ELKS__", 'p'); append_option("-c", 'p'); append_option("-f", 'p'); libc="-lc_f"; break; - case 'c': - append_option("-D__ELKS__", 'p'); - append_option("-D__unix__", 'p'); + case 'c': /* Caller saves Elks */ + prepend_option("-D__unix__", 'p'); + prepend_option("-D__ELKS__", 'p'); append_option("-c", 'p'); libc="-lc"; break; - case 's': - append_option("-D__STANDALONE__", 'p'); + case 's': /* Standalone 8086 */ + prepend_option("-D__STANDALONE__", 'p'); libc="-lc_s"; break; - case 'd': - append_option("-D__MSDOS__", 'p'); + case 'd': /* DOS COM file */ + prepend_option("-D__MSDOS__", 'p'); libc="-ldos"; append_option("-d", 'l'); append_option("-T100", 'l'); break; - case 'l': + case 'l': /* 386 Linux a.out */ opt_arch=1; - append_option("-D__linux__", 'p'); - append_option("-D__unix__", 'p'); + prepend_option("-D__unix__", 'p'); + prepend_option("-D__linux__", 'p'); libc="-lc"; append_option("-N", 'l'); break; - case 'G': + case 'g': /* 386 Linux object using gcc as linker */ opt_arch = 2; + prepend_option("-D__unix__", 'p'); + prepend_option("-D__linux__", 'p'); break; - case '8': + case '8': /* Use 'c386' program as compiler */ opt_arch = 3; opt_e = 1; break; - case '9': + case '9': /* 6809 compiler */ opt_arch = 4; default_libdir0 = "-L~/lib/bcc/m09/"; optim_rules = "-d~/lib/bcc/m09"; add_prefix("~/lib/bcc/m09/"); break; - case '0': + case '0': /* Plain old Unix V7 style */ opt_arch = 5; opt_e = 1; opt_I = 1; @@ -952,6 +955,20 @@ int otype; } } +void +prepend_option (option, otype) +char * option; +int otype; +{ + struct opt_list * newopt = xalloc(sizeof(struct opt_list)); + + newopt->opt = copystr(option); + newopt->opttype = otype; + + newopt->next = options; + options = newopt; +} + char * expand_tilde(str) char * str; { @@ -1039,11 +1056,13 @@ void reset_localprefix() strcpy(temp, s); strcat(temp, "/"); strcat(temp, progname); +#ifndef __BCC__ if( realpath(temp, buf) != 0 ) { free(temp); temp = copystr(buf); } +#endif if( access(temp, X_OK) == 0 ) break; d++; } @@ -1119,7 +1138,10 @@ static char ** minienviron[] = { #ifdef __BCC__ execve(command.fullpath, command.arglist, minienviron); #else - execv(command.fullpath, command.arglist); + if (command.fullpath[0] =='/') + execv(command.fullpath, command.arglist); + else + execvp(command.fullpath, command.arglist); #endif fprintf(stderr, "Unable to execute %s.\n", command.fullpath); exit(1); diff --git a/bcc/declare.c b/bcc/declare.c index 73a8524..40175e6 100644 --- a/bcc/declare.c +++ b/bcc/declare.c @@ -412,12 +412,13 @@ ts_s_newtypelist += sizeof *newtypelist; PRIVATE bool_pt declspec() { unsigned nsc; + unsigned nsigned; unsigned ntype; unsigned nunsigned; gvarsc = NULLDECL; gvartype = itype; - nunsigned = ntype = nsc = 0; + nsigned = nunsigned = ntype = nsc = 0; while (TRUE) { switch (sym) @@ -484,6 +485,10 @@ PRIVATE bool_pt declspec() gvartype = gsymptr->type; nextsym(); break; + case SIGNDECL: + ++nsigned; + nextsym(); + break; case UNSIGNDECL: ++nunsigned; nextsym(); @@ -493,6 +498,17 @@ PRIVATE bool_pt declspec() } } break2: + if (nsigned > 0) + { + if (ntype == 0) + { + gvartype = itype; + ntype = 1; + } + gvartype = tosigned(gvartype); + if (nsigned > 1 || nunsigned > 0) + ntype = 2; + } if (nunsigned > 0) { if (ntype == 0) @@ -501,7 +517,7 @@ break2: ntype = 1; } gvartype = tounsigned(gvartype); - if (nunsigned > 1) + if (nunsigned > 1 || nsigned > 0) ntype = 2; } if (nsc > 0) diff --git a/bcc/patch.file b/bcc/patch.file new file mode 100644 index 0000000..20a3174 --- /dev/null +++ b/bcc/patch.file @@ -0,0 +1,157 @@ +diff -u5 -r bcc~/declare.c bcc/declare.c +--- bcc~/declare.c Fri Dec 17 17:51:13 1999 ++++ bcc/declare.c Thu Jun 6 13:27:00 2002 +@@ -410,16 +410,17 @@ + } + + PRIVATE bool_pt declspec() + { + unsigned nsc; ++ unsigned nsigned; + unsigned ntype; + unsigned nunsigned; + + gvarsc = NULLDECL; + gvartype = itype; +- nunsigned = ntype = nsc = 0; ++ nsigned = nunsigned = ntype = nsc = 0; + while (TRUE) + { + switch (sym) + { + case AUTODECL: +@@ -482,29 +483,37 @@ + goto break2; + ++ntype; + gvartype = gsymptr->type; + nextsym(); + break; ++ case SIGNDECL: ++ ++nsigned; ++ nextsym(); ++ break; + case UNSIGNDECL: + ++nunsigned; + nextsym(); + break; + default: + goto break2; + } + } ++ + break2: ++ if (nsigned > 0) ++ { ++ if (ntype++ == 0) ++ gvartype = itype; ++ else ++ gvartype = tosigned(gvartype); ++ } + if (nunsigned > 0) + { +- if (ntype == 0) +- { ++ if (ntype++ == 0) + gvartype = uitype; +- ntype = 1; +- } +- gvartype = tounsigned(gvartype); +- if (nunsigned > 1) +- ntype = 2; ++ else ++ gvartype = tounsigned(gvartype); + } + if (nsc > 0) + { + if (ntype == 0) + ntype = 1; +diff -u5 -r bcc~/proto.h bcc/proto.h +--- bcc~/proto.h Sun Jan 11 12:18:36 1998 ++++ bcc/proto.h Thu Jun 6 00:46:24 2002 +@@ -360,8 +360,8 @@ + void outntypechar P((struct typestruct *type)); + struct typestruct *pointype P((struct typestruct *type)); + struct typestruct *prefix P((constr_pt constructor, uoffset_T size, + struct typestruct *type)); + struct typestruct *promote P((struct typestruct *type)); ++struct typestruct *tosigned P((struct typestruct *type)); + struct typestruct *tounsigned P((struct typestruct *type)); + void typeinit P((void)); +- +diff -u5 -r bcc~/scan.h bcc/scan.h +--- bcc~/scan.h Sat Jul 24 14:27:42 1999 ++++ bcc/scan.h Thu Jun 6 00:32:20 2002 +@@ -134,10 +134,11 @@ + + #define LASTOP PTRSUBOP + + ENUMDECL, + NULLDECL, ++ SIGNDECL, + STRUCTDECL, + TYPEDECL, + TYPEDEFNAME, + UNIONDECL, + UNSIGNDECL, +diff -u5 -r bcc~/table.c bcc/table.c +--- bcc~/table.c Sun Sep 28 09:57:30 1997 ++++ bcc/table.c Thu Jun 6 00:29:36 2002 +@@ -28,11 +28,11 @@ + #define MAXEXPR 125 + #else + #define MAXEXPR 500 + #endif + #define MAXLOCAL 100 +-#define NKEYWORDS 35 ++#define NKEYWORDS 36 + #ifdef NOFLOAT + #define NSCALTYPES 10 + #else + #define NSCALTYPES 12 + #endif +@@ -88,11 +88,12 @@ + PRIVATE struct keywordstruct keywords[NKEYWORDS] = + { + { "enum", ENUMDECL, }, + { "struct", STRUCTDECL, }, + { "union", UNIONDECL, }, + { "unsigned", UNSIGNDECL, }, ++ { "signed", SIGNDECL, }, + + { "auto", AUTODECL, }, + { "extern", EXTERNDECL, }, + { "register", REGDECL, }, + { "static", STATICDECL, }, +diff -u5 -r bcc~/type.c bcc/type.c +--- bcc~/type.c Sun Jan 11 12:18:37 1998 ++++ bcc/type.c Thu Jun 6 00:49:06 2002 +@@ -155,10 +155,29 @@ + if (type->constructor & FUNCTION) + return pointype(type); + return type; + } + ++PUBLIC struct typestruct *tosigned(type) ++struct typestruct *type; ++{ ++ switch (type->scalar & ~(UNSIGNED | DLONG)) ++ { ++ case CHAR: ++ return sctype; ++ case SHORT: ++ return stype; ++ case INT: ++ return itype; ++ case LONG: ++ return ltype; ++ default: ++ error("signed only applies to integral types"); ++ return type; ++ } ++} ++ + PUBLIC struct typestruct *tounsigned(type) + struct typestruct *type; + { + switch (type->scalar & ~(UNSIGNED | DLONG)) + { diff --git a/bcc/proto.h b/bcc/proto.h index e4a6b38..d5bbb7d 100644 --- a/bcc/proto.h +++ b/bcc/proto.h @@ -362,6 +362,6 @@ struct typestruct *pointype P((struct typestruct *type)); struct typestruct *prefix P((constr_pt constructor, uoffset_T size, struct typestruct *type)); struct typestruct *promote P((struct typestruct *type)); +struct typestruct *tosigned P((struct typestruct *type)); struct typestruct *tounsigned P((struct typestruct *type)); void typeinit P((void)); - diff --git a/bcc/q b/bcc/q new file mode 100644 index 0000000..e124394 --- /dev/null +++ b/bcc/q @@ -0,0 +1,112 @@ +diff -u5 -r bcc~/declare.c bcc/declare.c +--- bcc~/declare.c Fri Dec 17 17:51:13 1999 ++++ bcc/declare.c Thu Jun 6 13:27:00 2002 +@@ -410,16 +410,17 @@ + } + + PRIVATE bool_pt declspec() + { + unsigned nsc; ++ unsigned nsigned; + unsigned ntype; + unsigned nunsigned; + + gvarsc = NULLDECL; + gvartype = itype; +- nunsigned = ntype = nsc = 0; ++ nsigned = nunsigned = ntype = nsc = 0; + while (TRUE) + { + switch (sym) + { + case AUTODECL: +diff -u5 -r bcc~/proto.h bcc/proto.h +--- bcc~/proto.h Sun Jan 11 12:18:36 1998 ++++ bcc/proto.h Thu Jun 6 00:46:24 2002 +@@ -360,8 +360,8 @@ + void outntypechar P((struct typestruct *type)); + struct typestruct *pointype P((struct typestruct *type)); + struct typestruct *prefix P((constr_pt constructor, uoffset_T size, + struct typestruct *type)); + struct typestruct *promote P((struct typestruct *type)); ++struct typestruct *tosigned P((struct typestruct *type)); + struct typestruct *tounsigned P((struct typestruct *type)); + void typeinit P((void)); +- +diff -u5 -r bcc~/scan.h bcc/scan.h +--- bcc~/scan.h Sat Jul 24 14:27:42 1999 ++++ bcc/scan.h Thu Jun 6 00:32:20 2002 +@@ -134,10 +134,11 @@ + + #define LASTOP PTRSUBOP + + ENUMDECL, + NULLDECL, ++ SIGNDECL, + STRUCTDECL, + TYPEDECL, + TYPEDEFNAME, + UNIONDECL, + UNSIGNDECL, +diff -u5 -r bcc~/table.c bcc/table.c +--- bcc~/table.c Sun Sep 28 09:57:30 1997 ++++ bcc/table.c Thu Jun 6 00:29:36 2002 +@@ -28,11 +28,11 @@ + #define MAXEXPR 125 + #else + #define MAXEXPR 500 + #endif + #define MAXLOCAL 100 +-#define NKEYWORDS 35 ++#define NKEYWORDS 36 + #ifdef NOFLOAT + #define NSCALTYPES 10 + #else + #define NSCALTYPES 12 + #endif +@@ -88,11 +88,12 @@ + PRIVATE struct keywordstruct keywords[NKEYWORDS] = + { + { "enum", ENUMDECL, }, + { "struct", STRUCTDECL, }, + { "union", UNIONDECL, }, + { "unsigned", UNSIGNDECL, }, ++ { "signed", SIGNDECL, }, + + { "auto", AUTODECL, }, + { "extern", EXTERNDECL, }, + { "register", REGDECL, }, + { "static", STATICDECL, }, +diff -u5 -r bcc~/type.c bcc/type.c +--- bcc~/type.c Sun Jan 11 12:18:37 1998 ++++ bcc/type.c Thu Jun 6 00:49:06 2002 +@@ -155,10 +155,29 @@ + if (type->constructor & FUNCTION) + return pointype(type); + return type; + } + ++PUBLIC struct typestruct *tosigned(type) ++struct typestruct *type; ++{ ++ switch (type->scalar & ~(UNSIGNED | DLONG)) ++ { ++ case CHAR: ++ return sctype; ++ case SHORT: ++ return stype; ++ case INT: ++ return itype; ++ case LONG: ++ return ltype; ++ default: ++ error("signed only applies to integral types"); ++ return type; ++ } ++} ++ + PUBLIC struct typestruct *tounsigned(type) + struct typestruct *type; + { + switch (type->scalar & ~(UNSIGNED | DLONG)) + { diff --git a/bcc/scan.h b/bcc/scan.h index e318e9e..849610b 100644 --- a/bcc/scan.h +++ b/bcc/scan.h @@ -136,6 +136,7 @@ enum scan_states ENUMDECL, NULLDECL, + SIGNDECL, STRUCTDECL, TYPEDECL, TYPEDEFNAME, diff --git a/bcc/table.c b/bcc/table.c index 8b9bfb8..68cbc6a 100644 --- a/bcc/table.c +++ b/bcc/table.c @@ -30,7 +30,7 @@ #define MAXEXPR 500 #endif #define MAXLOCAL 100 -#define NKEYWORDS 35 +#define NKEYWORDS 36 #ifdef NOFLOAT #define NSCALTYPES 10 #else @@ -91,6 +91,7 @@ PRIVATE struct keywordstruct keywords[NKEYWORDS] = { "struct", STRUCTDECL, }, { "union", UNIONDECL, }, { "unsigned", UNSIGNDECL, }, + { "signed", SIGNDECL, }, { "auto", AUTODECL, }, { "extern", EXTERNDECL, }, diff --git a/bcc/type.c b/bcc/type.c index 97d88d7..10db803 100644 --- a/bcc/type.c +++ b/bcc/type.c @@ -157,6 +157,25 @@ struct typestruct *type; return type; } +PUBLIC struct typestruct *tosigned(type) +struct typestruct *type; +{ + switch (type->scalar & ~(UNSIGNED | DLONG)) + { + case CHAR: + return sctype; + case SHORT: + return stype; + case INT: + return itype; + case LONG: + return ltype; + default: + error("signed only applies to integral types"); + return type; + } +} + PUBLIC struct typestruct *tounsigned(type) struct typestruct *type; { -- cgit v1.2.1