1987-04-29 10:22:07 +00:00
|
|
|
/*
|
|
|
|
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
|
|
|
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
|
|
|
*
|
|
|
|
* Author: Ceriel J.H. Jacobs
|
|
|
|
*/
|
|
|
|
|
1986-04-17 09:28:09 +00:00
|
|
|
/* U S E R O P T I O N - H A N D L I N G */
|
|
|
|
|
1994-06-24 14:02:31 +00:00
|
|
|
/* $Id$ */
|
1987-04-29 10:22:07 +00:00
|
|
|
|
2013-05-14 21:24:38 +00:00
|
|
|
#include "parameters.h"
|
1986-04-17 09:28:09 +00:00
|
|
|
|
1986-05-01 19:06:53 +00:00
|
|
|
#include <em_arith.h>
|
|
|
|
#include <em_label.h>
|
1987-05-18 15:57:33 +00:00
|
|
|
#include <alloc.h>
|
1986-05-01 19:06:53 +00:00
|
|
|
|
1986-04-17 09:28:09 +00:00
|
|
|
#include "type.h"
|
1986-04-25 10:14:08 +00:00
|
|
|
#include "main.h"
|
1986-11-05 14:33:00 +00:00
|
|
|
#include "warning.h"
|
1988-03-21 17:43:54 +00:00
|
|
|
#include "class.h"
|
1986-04-17 09:28:09 +00:00
|
|
|
|
1986-11-17 11:41:28 +00:00
|
|
|
#define MINIDFSIZE 14
|
|
|
|
|
|
|
|
#if MINIDFSIZE < 14
|
|
|
|
You fouled up! MINIDFSIZE has to be at least 14 or the compiler will not
|
|
|
|
recognize some keywords!
|
|
|
|
#endif
|
|
|
|
|
1986-04-17 09:28:09 +00:00
|
|
|
extern int idfsize;
|
1987-04-29 10:22:07 +00:00
|
|
|
static int ndirs = 1;
|
1988-07-05 19:06:40 +00:00
|
|
|
int warning_classes = W_INITIAL;
|
1995-12-04 15:29:42 +00:00
|
|
|
int gdb_flag;
|
1986-04-25 10:14:08 +00:00
|
|
|
|
1986-05-01 19:06:53 +00:00
|
|
|
DoOption(text)
|
1986-10-06 20:36:30 +00:00
|
|
|
register char *text;
|
1986-04-17 09:28:09 +00:00
|
|
|
{
|
|
|
|
switch(*text++) {
|
|
|
|
|
1987-04-29 10:22:07 +00:00
|
|
|
case '-':
|
|
|
|
options[*text]++; /* debug options etc. */
|
1986-04-17 09:28:09 +00:00
|
|
|
break;
|
|
|
|
|
1988-03-21 17:43:54 +00:00
|
|
|
case 'U': /* allow underscores in identifiers */
|
|
|
|
inidf['_'] = 1;
|
|
|
|
break;
|
1987-04-29 10:22:07 +00:00
|
|
|
case 'L': /* no fil/lin */
|
1987-08-11 10:50:30 +00:00
|
|
|
case 'R': /* no range checks */
|
1988-03-21 17:43:54 +00:00
|
|
|
case 'A': /* extra array bound checks, for machines that do not
|
|
|
|
implement it in AAR/LAR/SAR
|
|
|
|
*/
|
1987-04-29 10:22:07 +00:00
|
|
|
case 'n': /* no register messages */
|
|
|
|
case 'x': /* every name global */
|
1987-06-23 17:12:25 +00:00
|
|
|
case 's': /* symmetric: MIN(INTEGER) = -MAX(INTEGER) */
|
1987-10-19 11:28:37 +00:00
|
|
|
case '3': /* strict 3rd edition Modula-2 */
|
1989-03-03 16:13:45 +00:00
|
|
|
case 'l': /* local additions enabled */
|
1987-04-29 10:22:07 +00:00
|
|
|
options[text[-1]]++;
|
|
|
|
break;
|
1986-04-17 09:28:09 +00:00
|
|
|
|
1991-02-18 17:18:36 +00:00
|
|
|
#ifdef DBSYMTAB
|
1990-08-01 14:35:07 +00:00
|
|
|
case 'g': /* generate symbol table for debugger */
|
|
|
|
options['g']++;
|
1995-12-04 15:29:42 +00:00
|
|
|
if (*text == 'd') {
|
|
|
|
/* Assume -gdb. */
|
|
|
|
gdb_flag = 1;
|
|
|
|
}
|
1990-08-01 14:35:07 +00:00
|
|
|
options['n']++; /* no register vars ??? */
|
|
|
|
break;
|
1991-02-18 17:18:36 +00:00
|
|
|
#endif /* DBSYMTAB */
|
1990-08-01 14:35:07 +00:00
|
|
|
|
1986-11-05 14:33:00 +00:00
|
|
|
case 'w':
|
|
|
|
if (*text) {
|
|
|
|
while (*text) {
|
|
|
|
switch(*text++) {
|
1987-10-19 11:28:37 +00:00
|
|
|
#ifndef STRICT_3RD_ED
|
1986-11-05 14:33:00 +00:00
|
|
|
case 'O':
|
|
|
|
warning_classes &= ~W_OLDFASHIONED;
|
|
|
|
break;
|
1987-10-19 11:28:37 +00:00
|
|
|
#endif
|
1987-11-09 16:11:04 +00:00
|
|
|
#ifndef NOSTRICT
|
1986-11-05 14:33:00 +00:00
|
|
|
case 'R':
|
|
|
|
warning_classes &= ~W_STRICT;
|
|
|
|
break;
|
1987-11-09 10:17:20 +00:00
|
|
|
#endif
|
1986-11-05 14:33:00 +00:00
|
|
|
case 'W':
|
|
|
|
warning_classes &= ~W_ORDINARY;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1988-01-22 12:04:27 +00:00
|
|
|
else warning_classes = W_ALWAYS;
|
1986-11-05 14:33:00 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'W':
|
1987-07-21 13:54:33 +00:00
|
|
|
if (*text) {
|
|
|
|
while (*text) {
|
|
|
|
switch(*text++) {
|
1987-10-19 11:28:37 +00:00
|
|
|
#ifndef STRICT_3RD_ED
|
1987-07-21 13:54:33 +00:00
|
|
|
case 'O':
|
|
|
|
warning_classes |= W_OLDFASHIONED;
|
|
|
|
break;
|
1987-10-19 11:28:37 +00:00
|
|
|
#endif
|
1987-11-09 16:11:04 +00:00
|
|
|
#ifndef NOSTRICT
|
1987-07-21 13:54:33 +00:00
|
|
|
case 'R':
|
|
|
|
warning_classes |= W_STRICT;
|
|
|
|
break;
|
1987-11-09 10:17:20 +00:00
|
|
|
#endif
|
1987-07-21 13:54:33 +00:00
|
|
|
case 'W':
|
|
|
|
warning_classes |= W_ORDINARY;
|
|
|
|
break;
|
|
|
|
}
|
1986-11-05 14:33:00 +00:00
|
|
|
}
|
|
|
|
}
|
1988-01-22 12:04:27 +00:00
|
|
|
else warning_classes = W_ALL;
|
1986-11-05 14:33:00 +00:00
|
|
|
break;
|
|
|
|
|
1986-10-06 20:36:30 +00:00
|
|
|
case 'M': { /* maximum identifier length */
|
1988-03-21 17:43:54 +00:00
|
|
|
#ifndef SQUEEZE
|
1986-10-06 20:36:30 +00:00
|
|
|
char *t = text; /* because &text is illegal */
|
|
|
|
|
|
|
|
idfsize = txt2int(&t);
|
|
|
|
if (*t || idfsize <= 0)
|
1986-04-17 09:28:09 +00:00
|
|
|
fatal("malformed -M option");
|
1986-11-17 11:41:28 +00:00
|
|
|
if (idfsize > IDFSIZE) {
|
|
|
|
idfsize = IDFSIZE;
|
|
|
|
warning(W_ORDINARY,"maximum identifier length is %d", IDFSIZE);
|
|
|
|
}
|
|
|
|
if (idfsize < MINIDFSIZE) {
|
|
|
|
warning(W_ORDINARY, "minimum identifier length is %d", MINIDFSIZE);
|
|
|
|
idfsize = MINIDFSIZE;
|
|
|
|
}
|
1988-03-21 17:43:54 +00:00
|
|
|
#endif
|
1986-10-06 20:36:30 +00:00
|
|
|
}
|
1986-04-17 09:28:09 +00:00
|
|
|
break;
|
|
|
|
|
1986-04-25 10:14:08 +00:00
|
|
|
case 'I' :
|
1986-12-09 17:41:06 +00:00
|
|
|
if (*text) {
|
1987-05-11 14:38:37 +00:00
|
|
|
register int i;
|
1986-12-09 17:41:06 +00:00
|
|
|
register char *new = text;
|
1987-05-11 14:38:37 +00:00
|
|
|
|
1993-01-18 16:14:43 +00:00
|
|
|
if (nDEF > mDEF) {
|
1990-06-28 18:06:16 +00:00
|
|
|
DEFPATH = (char **)
|
1991-02-19 15:28:48 +00:00
|
|
|
Realloc((char *)DEFPATH,(unsigned)(mDEF+=10)*sizeof(char *));
|
1987-05-11 14:38:37 +00:00
|
|
|
}
|
|
|
|
|
1990-09-27 17:01:01 +00:00
|
|
|
for (i = ndirs++; i < nDEF; i++) {
|
1990-06-28 18:06:16 +00:00
|
|
|
char *tmp = DEFPATH[i];
|
1986-12-09 17:41:06 +00:00
|
|
|
|
1990-09-27 17:01:01 +00:00
|
|
|
DEFPATH[i] = new;
|
1986-12-09 17:41:06 +00:00
|
|
|
new = tmp;
|
|
|
|
}
|
1993-01-18 16:14:43 +00:00
|
|
|
++nDEF;
|
1986-04-25 10:14:08 +00:00
|
|
|
}
|
1986-12-09 17:41:06 +00:00
|
|
|
else DEFPATH[ndirs] = 0;
|
1986-04-25 10:14:08 +00:00
|
|
|
break;
|
|
|
|
|
1986-04-17 09:28:09 +00:00
|
|
|
case 'V' : /* set object sizes and alignment requirements */
|
1987-11-09 11:29:48 +00:00
|
|
|
#ifndef NOCROSS
|
1986-04-17 09:28:09 +00:00
|
|
|
{
|
1987-07-13 10:30:37 +00:00
|
|
|
register int size;
|
1988-09-05 15:51:35 +00:00
|
|
|
register int algn;
|
1986-04-17 09:28:09 +00:00
|
|
|
char c;
|
1986-10-06 20:36:30 +00:00
|
|
|
char *t;
|
1986-04-17 09:28:09 +00:00
|
|
|
|
|
|
|
while (c = *text++) {
|
2006-07-23 20:01:02 +00:00
|
|
|
char *strchr();
|
1987-05-21 09:37:28 +00:00
|
|
|
|
1986-10-06 20:36:30 +00:00
|
|
|
t = text;
|
|
|
|
size = txt2int(&t);
|
1988-09-05 15:51:35 +00:00
|
|
|
algn = 0;
|
1986-10-06 20:36:30 +00:00
|
|
|
if (*(text = t) == '.') {
|
|
|
|
t = text + 1;
|
1988-09-05 15:51:35 +00:00
|
|
|
algn = txt2int(&t);
|
1986-10-06 20:36:30 +00:00
|
|
|
text = t;
|
1986-04-17 09:28:09 +00:00
|
|
|
}
|
2006-07-23 20:01:02 +00:00
|
|
|
if (! strchr("wislfdpS", c)) {
|
1987-05-21 09:37:28 +00:00
|
|
|
error("-V: bad type indicator %c\n", c);
|
|
|
|
}
|
|
|
|
if (size != 0) switch (c) {
|
1986-04-17 09:28:09 +00:00
|
|
|
|
|
|
|
case 'w': /* word */
|
1987-05-21 09:37:28 +00:00
|
|
|
word_size = size;
|
|
|
|
dword_size = 2 * size;
|
1986-04-17 09:28:09 +00:00
|
|
|
break;
|
|
|
|
case 'i': /* int */
|
1987-05-21 09:37:28 +00:00
|
|
|
int_size = size;
|
1986-04-17 09:28:09 +00:00
|
|
|
break;
|
1986-11-17 11:41:28 +00:00
|
|
|
case 's': /* short (subranges) */
|
1987-05-21 09:37:28 +00:00
|
|
|
short_size = size;
|
1986-11-17 11:41:28 +00:00
|
|
|
break;
|
1986-04-17 09:28:09 +00:00
|
|
|
case 'l': /* longint */
|
1987-05-21 09:37:28 +00:00
|
|
|
long_size = size;
|
1986-04-17 09:28:09 +00:00
|
|
|
break;
|
|
|
|
case 'f': /* real */
|
1987-05-21 09:37:28 +00:00
|
|
|
float_size = size;
|
1986-04-17 09:28:09 +00:00
|
|
|
break;
|
|
|
|
case 'd': /* longreal */
|
1987-05-21 09:37:28 +00:00
|
|
|
double_size = size;
|
1986-04-17 09:28:09 +00:00
|
|
|
break;
|
|
|
|
case 'p': /* pointer */
|
1987-05-21 09:37:28 +00:00
|
|
|
pointer_size = size;
|
|
|
|
break;
|
|
|
|
}
|
1988-09-05 15:51:35 +00:00
|
|
|
if (algn != 0) switch (c) {
|
1987-05-21 09:37:28 +00:00
|
|
|
|
|
|
|
case 'w': /* word */
|
1988-09-05 15:51:35 +00:00
|
|
|
word_align = algn;
|
1987-05-21 09:37:28 +00:00
|
|
|
break;
|
|
|
|
case 'i': /* int */
|
1988-09-05 15:51:35 +00:00
|
|
|
int_align = algn;
|
1987-05-21 09:37:28 +00:00
|
|
|
break;
|
|
|
|
case 's': /* short (subranges) */
|
1988-09-05 15:51:35 +00:00
|
|
|
short_align = algn;
|
1987-05-21 09:37:28 +00:00
|
|
|
break;
|
|
|
|
case 'l': /* longint */
|
1988-09-05 15:51:35 +00:00
|
|
|
long_align = algn;
|
1987-05-21 09:37:28 +00:00
|
|
|
break;
|
|
|
|
case 'f': /* real */
|
1988-09-05 15:51:35 +00:00
|
|
|
float_align = algn;
|
1987-05-21 09:37:28 +00:00
|
|
|
break;
|
|
|
|
case 'd': /* longreal */
|
1988-09-05 15:51:35 +00:00
|
|
|
double_align = algn;
|
1987-05-21 09:37:28 +00:00
|
|
|
break;
|
|
|
|
case 'p': /* pointer */
|
1988-09-05 15:51:35 +00:00
|
|
|
pointer_align = algn;
|
1986-04-17 09:28:09 +00:00
|
|
|
break;
|
|
|
|
case 'S': /* initial record alignment */
|
1988-09-05 15:51:35 +00:00
|
|
|
struct_align = algn;
|
1986-04-17 09:28:09 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1991-12-17 14:36:35 +00:00
|
|
|
#endif /* NOCROSS */
|
1987-11-09 11:29:48 +00:00
|
|
|
break;
|
1986-04-17 09:28:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1988-03-21 17:43:54 +00:00
|
|
|
#if (!SQUEEZE) | (!NOCROSS)
|
1986-04-17 09:28:09 +00:00
|
|
|
int
|
|
|
|
txt2int(tp)
|
1986-10-06 20:36:30 +00:00
|
|
|
register char **tp;
|
1986-04-17 09:28:09 +00:00
|
|
|
{
|
|
|
|
/* the integer pointed to by *tp is read, while increasing
|
|
|
|
*tp; the resulting value is yielded.
|
|
|
|
*/
|
|
|
|
register int val = 0;
|
|
|
|
register int ch;
|
|
|
|
|
|
|
|
while (ch = **tp, ch >= '0' && ch <= '9') {
|
|
|
|
val = val * 10 + ch - '0';
|
|
|
|
(*tp)++;
|
|
|
|
}
|
|
|
|
return val;
|
|
|
|
}
|
1988-03-21 17:43:54 +00:00
|
|
|
#endif
|