diff options
author | Robert de Bath <rdebath@poboxes.com> | 2002-07-24 21:00:16 +0200 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2013-10-23 23:48:47 +0200 |
commit | 2060b4f4cc1c13975e495d088344825f7700181b (patch) | |
tree | 5efd3dbb269b09d4b3351fdb6b50d6dca0291d47 /bcc | |
parent | 673f690a37f6673a3262e933709c79de8a66f48c (diff) | |
download | dev86-2060b4f4cc1c13975e495d088344825f7700181b.tar.gz |
Import Dev86src-0.16.5.tar.gzv0.16.5
Diffstat (limited to 'bcc')
-rw-r--r-- | bcc/bcc.c | 58 | ||||
-rw-r--r-- | bcc/codefrag.c | 1 | ||||
-rw-r--r-- | bcc/declare.c | 4 | ||||
-rw-r--r-- | bcc/exptree.c | 5 | ||||
-rw-r--r-- | bcc/input.c | 1 | ||||
-rw-r--r-- | bcc/preproc.c | 66 | ||||
-rw-r--r-- | bcc/proto.h | 1 | ||||
-rw-r--r-- | bcc/scan.h | 1 | ||||
-rw-r--r-- | bcc/state.c | 3 | ||||
-rw-r--r-- | bcc/table.c | 4 |
10 files changed, 137 insertions, 7 deletions
@@ -141,6 +141,7 @@ void command_arch P((void)); void command_opts P((int opykey)); void newfilename P((struct file_list * file, int last_stage, int new_extn, int use_o)); void run_unlink P((void)); +void validate_link_opts 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)); @@ -200,6 +201,7 @@ char ** argv; reset_localprefix(); #endif getargs(argc, argv); + validate_link_opts(); default_include = expand_tilde(default_include); default_libdir0 = expand_tilde(default_libdir0); @@ -447,6 +449,60 @@ run_link() } void +validate_link_opt(char * option) +{ + int err = 0; + if (option[0] != '-') return; + + switch(option[1]) { + default: + err = 1; + break; + case '0': /* use 16-bit libraries */ + case '3': /* use 32-bit libraries */ + case 'M': /* print symbols linked */ + case 'i': /* separate I & D output */ + case 'm': /* print modules linked */ + case 's': /* strip symbols */ + case 't': /* trace modules linked */ + case 'z': /* unmapped zero page */ + case 'N': /* Native format a.out */ + case 'd': /* Make a headerless outfile */ + case 'c': /* Write header in CP/M-86 format */ + case 'y': /* Use a newer symbol table */ + if (option[2] != 0 && option[2] != '-') + err = 1; + break; + case 'C': /* startfile name */ + case 'L': /* library path */ + case 'O': /* library file name */ + case 'T': /* text base address */ + case 'D': /* data base address */ + case 'H': /* heap top address */ + case 'l': /* library name */ + case 'o': /* output file name */ + break; + } + if (err) + fprintf(stderr, "warning: linker option %s not unrecognised.\n", option); +} + +void +validate_link_opts() +{ + struct opt_list * ol; + struct file_list * next_file; + if (opt_arch>1) return; /* Only check ld86 options */ + + for(ol=options; ol; ol=ol->next) + if (ol->opttype == 'l') + validate_link_opt(ol->opt); + + for(next_file = files; next_file; next_file = next_file->next) + validate_link_opt(next_file->file); +} + +void command_reset() { #ifndef MAXPATHLEN @@ -868,6 +924,8 @@ char ** argv; opt_x = 1; append_option("/lib/crt0.o", 'l'); break; + default: + fatal("Unknown model specifier for -M"); } if (do_optim) diff --git a/bcc/codefrag.c b/bcc/codefrag.c index bdcb850..041a148 100644 --- a/bcc/codefrag.c +++ b/bcc/codefrag.c @@ -350,6 +350,7 @@ PUBLIC void sctoi() if (i386_32) { outmovsx(); + outaccum(); outncregname(BREG); } else diff --git a/bcc/declare.c b/bcc/declare.c index 40175e6..f61887f 100644 --- a/bcc/declare.c +++ b/bcc/declare.c @@ -493,6 +493,10 @@ PRIVATE bool_pt declspec() ++nunsigned; nextsym(); break; + case ASMSYM: + nextsym(); + doasm(); + break; default: goto break2; } diff --git a/bcc/exptree.c b/bcc/exptree.c index 427b5f4..04a4534 100644 --- a/bcc/exptree.c +++ b/bcc/exptree.c @@ -397,7 +397,12 @@ struct nodestruct *p2; if (target->storage == CONSTANT) { if (rscalar & CHAR) + { target->offset.offv &= CHMASKTO; + if (p2->nodetype == sctype && + target->offset.offv&((~CHMASKTO)>>1)) + target->offset.offv |= ~CHMASKTO; + } else if (rscalar & SHORT) { target->offset.offv &= shortmaskto; diff --git a/bcc/input.c b/bcc/input.c index 080c7bc..b89eb78 100644 --- a/bcc/input.c +++ b/bcc/input.c @@ -238,6 +238,7 @@ PUBLIC void include() if (ch == terminator) { gch1(); + blanks(); break; } if (charptr >= chartop) diff --git a/bcc/preproc.c b/bcc/preproc.c index 62302e8..e292329 100644 --- a/bcc/preproc.c +++ b/bcc/preproc.c @@ -40,6 +40,7 @@ struct macroposition char *paramspot; bool_t inparam; indn_t nparam; + struct symstruct *symptr; }; PRIVATE char dummyparam[] = { EOL, 0 }; @@ -51,8 +52,10 @@ PRIVATE struct ifstruct ifstack[MAX_IF]; PRIVATE struct macroposition macrostack[MAX_MACRO]; FORWARD void asmcontrol P((void)); +FORWARD void warningcntl P((void)); FORWARD void control P((void)); FORWARD void defineorundefinestring P((char *str, bool_pt defineflag)); +FORWARD void elifcontrol P((void)); FORWARD void elsecontrol P((void)); FORWARD void endif P((void)); FORWARD fastin_pt getparnames P((void)); @@ -154,6 +157,22 @@ PUBLIC void checknotinif() } } + +/* This is a major hack. It doesn't handle continued lines. + * It does let me avoid wrapping warning directives though. */ +PRIVATE void warningcntl() +{ + char *s = lineptr; + + while (*lineptr && (*lineptr != EOL)) { + ++lineptr; + } + write(2, "warning: #warning", 17); + write(2, s, lineptr - s); + write(2, "\n", 1); + ch = *lineptr; +} + /* control() - select and switch to control statement */ PRIVATE void control() @@ -193,7 +212,7 @@ PRIVATE void control() } ctlcase = symptr->offset.offsym; if (ifstate.ifflag == FALSE && - (ctlcase < ELSECNTL || ctlcase > IFNDEFCNTL)) + (ctlcase < ELIFCNTL || ctlcase > IFNDEFCNTL)) return; switch (ctlcase) { @@ -209,6 +228,9 @@ PRIVATE void control() case DEFINECNTL: define(); break; + case ELIFCNTL: + elifcontrol(); + break; case ELSECNTL: elsecontrol(); break; @@ -236,6 +258,9 @@ PRIVATE void control() case UNDEFCNTL: undef(); break; + case WARNINGCNTL: + warningcntl(); + break; } } @@ -344,8 +369,12 @@ ts_s_macstring += 2; { gch1(); skipcomment(); +#if 0 /* comment is space in modern cpp's but they have '##' too */ ch = *--lineptr = ' '; +#else + continue; +#endif } } #ifdef TS @@ -364,12 +393,13 @@ ts_s_macstring += 2; && (--rcp == macstring || *(rcp - 1) != EOL); ) charptr = rcp; } - if (charptr >= char1top) - macstring = growobject(macstring, 2); + if (charptr+1 >= char1top) + macstring = growobject(macstring, 3); #ifdef TS ++ts_n_macstring_term; -ts_s_macstring += 2; +ts_s_macstring += 3; #endif + *charptr++ = ' '; /* Added to prevent tail recursion on expansion */ *charptr++ = EOL; *charptr++ = 0; if (nparnames) @@ -498,6 +528,29 @@ PUBLIC void docontrol() } } +/* elifcontrol() - process #elif */ + +PRIVATE void elifcontrol() +{ + if (iflevel == 0) + { + error("elif without if"); + return; + } + if (ifstate.elseflag) { + register struct ifstruct *ifptr; + + ifptr = &ifstack[(int)--iflevel]; + ifstate.elseflag = ifptr->elseflag; + ifstate.ifflag = ifptr->ifflag; + + ifcontrol(IFCNTL); + } else { + ifstate.ifflag = ifstate.elseflag; + ifstate.elseflag = FALSE; + } +} + /* elsecontrol() - process #else */ PRIVATE void elsecontrol() @@ -547,6 +600,7 @@ PUBLIC void entermac() return; } symptr = gsymptr; + symptr->name.namea[0] |= 0x80; /* SMUDGE macro definition */ ngoodparams = 0; paramhead = NULL; if (symptr->indcount != 0) @@ -572,6 +626,7 @@ ts_s_macparam_tot += sizeof *paramlist * nparleft; { if (nparleft > 0) /* macro has params, doesn't match bare word */ { + symptr->name.namea[0] &= 0x7f; /* UnSMUDGE macro definition */ outstr(symptr->name.namea); return; } @@ -737,6 +792,8 @@ ts_s_macparam_string_tot -= charptr - oldparam; ch = *(lineptr = symptr->offset.offp); mpptr->inparam = FALSE; mpptr->nparam = ngoodparams; + mpptr->symptr = symptr; + mpptr->symptr->name.namea[0] |= 0x80; /* SMUDGE macro definition */ ++maclevel; } /* @@ -853,6 +910,7 @@ PUBLIC void leavemac() } else { + mpptr->symptr->name.namea[0] &= 0x7F;/* UnSMUDGE macro definition */ ch = *++lineptr; /* gch1() would mess up next param == EOL-1 */ if (ch != 0) { diff --git a/bcc/proto.h b/bcc/proto.h index d5bbb7d..36d5bdc 100644 --- a/bcc/proto.h +++ b/bcc/proto.h @@ -325,6 +325,7 @@ void softop P((op_pt op, struct symstruct *source, struct symstruct *target)); void compound P((void)); void outswoffset P((offset_T offset)); void outswstacklab P((void)); +void doasm P((void)); /* table.c */ struct symstruct *addglb P((char *name, struct typestruct *type)); @@ -171,6 +171,7 @@ enum scan_states INCLUDECNTL, LINECNTL, UNDEFCNTL, + WARNINGCNTL, ELIFCNTL, /* "IF" controls must be contiguous */ ELSECNTL, diff --git a/bcc/state.c b/bcc/state.c index c14ff7b..a290e43 100644 --- a/bcc/state.c +++ b/bcc/state.c @@ -72,7 +72,6 @@ FORWARD void doswitch P((void)); FORWARD void dowhile P((void)); FORWARD void jumptocases P((void)); FORWARD void statement P((void)); -FORWARD void doasm P((void)); /* --- utility routines --- */ @@ -233,7 +232,7 @@ PUBLIC void compound() /* have just seen "{" */ rbrace(); } -PRIVATE void doasm() +PUBLIC void doasm() { if (sym == LPAREN) nextsym(); if (sym!=STRINGCONST) diff --git a/bcc/table.c b/bcc/table.c index 68cbc6a..203b4fb 100644 --- a/bcc/table.c +++ b/bcc/table.c @@ -30,7 +30,7 @@ #define MAXEXPR 500 #endif #define MAXLOCAL 100 -#define NKEYWORDS 36 +#define NKEYWORDS 38 #ifdef NOFLOAT #define NSCALTYPES 10 #else @@ -117,6 +117,7 @@ PRIVATE struct keywordstruct keywords[NKEYWORDS] = { "#asm", ASMCNTL, }, { "#define", DEFINECNTL, }, + { "#elif", ELIFCNTL, }, { "#else", ELSECNTL, }, { "#endasm", ENDASMCNTL, }, { "#endif", ENDIFCNTL, }, @@ -126,6 +127,7 @@ PRIVATE struct keywordstruct keywords[NKEYWORDS] = { "#ifndef", IFNDEFCNTL, }, { "#line", LINECNTL, }, { "#undef", UNDEFCNTL, }, + { "#warning", WARNINGCNTL, }, { "defined", DEFINEDSYM, }, /* should be deactivated except in #if's */ }; |