LLmessage.c
SmallPars
BigPars
+LintPars
align.h
arith.c
arith.h
type.str
util.str
util.c
+acklint
+l_class.h
+l_comment.c
+l_ev_ord.c
+l_lint.c
+l_lint.h
+l_misc.c
+l_outdef.c
+l_outdef.str
+l_state.str
+l_states.c
LoadChar(ch);
if (ch != nch) {
PushBack();
- lexerror("illegal combination '=%c'",
- nch);
+ lexerror("illegal operator '=%c%c'",
+ nch, ch);
}
return ptok->tk_symb =
nch == '<' ? LEFTAB : RIGHTAB;
semantics of C is a mess.
*/
-#include "botch_free.h"
#include <alloc.h>
#include "nofloat.h"
#include "nobitfield.h"
else /* !oldi && !i */
float2float(expp, tp);
#else NOFLOAT
- else
+ else {
crash("(ch7cast) floats not implemented\n");
+ /*NOTREACHED*/
+ }
#endif NOFLOAT
}
else
/* apply binary operator oper between *expp and expr.
NB: don't swap operands if op is one of the op= operators!!!
*/
+
any2opnd(expp, oper);
any2opnd(&expr, oper);
switch (oper) {
break;
case '&':
if ((*expp)->ex_type->tp_fund == ARRAY) {
- warning("& before array: ignored");
+ warning("& before array ignored");
array2pointer(*expp);
}
else
if ((*expp)->ex_type->tp_fund == FUNCTION) {
- warning("& before function: ignored");
+ warning("& before function ignored");
function2pointer(*expp);
}
else
#include "assert.h"
#include "noRoption.h"
#include "file_info.h"
-
label lab_count = 1;
label datlab_count = 1;
#endif USE_TMP
extern char options[];
-char *symbol2str();
+extern char *symbol2str();
init_code(dst_file)
char *dst_file;
C_insertpart(tmp_id = C_getid());
#endif USE_TMP
}
-
static struct string_cst *str_list = 0;
code_string(val, len, dlb)
break;
default:
crash("bad local storage class");
- break;
+ /*NOTREACHED*/
}
}
}
case ARRAY:
case STRUCT:
case UNION:
- error("no automatic aggregate initialisation");
+ error("automatic %s cannot be initialized in declaration",
+ symbol2str(tp->tp_fund));
free_expression(e);
return;
}
#endif NOFLOAT
default:
crash("(conversion) illegal type conversion");
+ /*NOTREACHED*/
}
if ((int)(to_type->tp_size) < (int)word_size
#ifndef NOFLOAT
#include "expr.h"
#include "sizes.h"
#include "level.h"
-
extern char options[];
}
arith size = expr->VL_VALUE;
if (size < 0) {
- error("negative number of array elements");
+ error("array size is negative");
expr->VL_VALUE = (arith)1;
}
else
if (size == 0) {
- warning("empty array declaration");
+ warning("array size is 0");
}
else
if (size & ~max_unsigned) { /* absolutely ridiculous */
/* D E C L A R A T I O N S P E C I F I E R C H E C K I N G */
#include "nofloat.h"
+#include "assert.h"
#include "Lpars.h"
#include "decspecs.h"
#include "arith.h"
*/
register struct type *tp = ds->ds_type;
- if (level == L_FORMAL1)
- crash("do_decspecs");
+ ASSERT(level != L_FORMAL1);
if ( level == L_GLOBAL &&
(ds->ds_sc == AUTO || ds->ds_sc == REGISTER)
char df_alloc; /* 0, ALLOC_SEEN or ALLOC_DONE */
char df_used; /* set if idf is used */
char *df_file; /* file containing the definition */
- long df_line; /* line number of the definition */
+ unsigned int df_line; /* line number of the definition */
char df_formal_array; /* to warn if sizeof is taken */
arith df_address;
};
*/
/* error classes */
-#define ERROR 1
-#define WARNING 2
-#define LEXERROR 3
-#define LEXWARNING 4
-#define CRASH 5
-#define FATAL 6
+#define WARNING 1
+#define ERROR 2
+#define CRASH 3
+#define FATAL 4
int err_occurred = 0;
-extern char *symbol2str();
extern char options[];
-
/* There are three general error-message functions:
lexerror() lexical and pre-processor error messages
error() syntactic and semantic error messages
expression, whereas other errors use the information in the token.
*/
+static _error();
+
/*VARARGS*/
error(va_alist) /* fmt, args */
va_dcl
va_start(ap);
{
- _error(ERROR, NILEXPR, ap);
+ _error(ERROR, dot.tk_file, dot.tk_line, ap);
}
va_end(ap);
}
if (!(expr->ex_flags & EX_ERROR)) {
/* to prevent proliferation */
- _error(ERROR, expr, ap);
+ _error(ERROR, expr->ex_file, expr->ex_line, ap);
expr->ex_flags |= EX_ERROR;
}
}
va_start(ap);
{
- _error(WARNING, NILEXPR, ap);
+ _error(WARNING, dot.tk_file, dot.tk_line, ap);
}
va_end(ap);
}
if (!(expr->ex_flags & EX_ERROR)) {
/* to prevent proliferation */
- _error(WARNING, expr, ap);
+ _error(WARNING, expr->ex_file, expr->ex_line, ap);
}
}
va_end(ap);
va_start(ap);
{
- _error(LEXERROR, NILEXPR, ap);
+ _error(ERROR, FileName, LineNumber, ap);
}
va_end(ap);
}
va_start(ap);
{
- _error(LEXWARNING, NILEXPR, ap);
+ _error(WARNING, FileName, LineNumber, ap);
}
va_end(ap);
}
va_start(ap);
{
- _error(CRASH, NILEXPR, ap);
+ _error(CRASH, FileName, LineNumber, ap);
}
va_end(ap);
va_start(ap);
{
- _error(FATAL, NILEXPR, ap);
+ _error(FATAL, FileName, LineNumber, ap);
}
va_end(ap);
if (C_busy()) C_close();
sys_stop(S_EXIT);
+ /*NOTREACHED*/
}
-_error(class, expr, ap)
+static
+_error(class, fn, ln, ap)
int class;
- struct expr *expr;
+ char *fn;
+ unsigned int ln;
va_list ap;
{
/* _error attempts to limit the number of error messages
static char *last_fn = 0;
static unsigned int last_ln = 0;
static int e_seen = 0;
- char *fn = 0;
- unsigned int ln = 0;
- char *remark = 0;
+ char *remark;
char *fmt = va_arg(ap, char *);
/* Since name and number are gathered from different places
*/
/* preliminaries */
switch (class) {
+ case WARNING:
+ if (options['w'])
+ return;
+ break;
+
case ERROR:
- case LEXERROR:
case CRASH:
case FATAL:
if (C_busy())
C_ms_err();
err_occurred = 1;
break;
-
- case WARNING:
- case LEXWARNING:
- if (options['w'])
- return;
- break;
}
/* the remark */
switch (class) {
case WARNING:
- case LEXWARNING:
remark = "(warning)";
break;
+
+ case ERROR:
+ remark = 0;
+ break;
+
case CRASH:
remark = "CRASH\007";
break;
+
case FATAL:
remark = "fatal error --";
break;
- }
-
- /* the place */
- switch (class) {
- case WARNING:
- case ERROR:
- fn = expr ? expr->ex_file : dot.tk_file;
- ln = expr ? expr->ex_line : dot.tk_line;
- break;
- case LEXWARNING:
- case LEXERROR:
- case CRASH:
- case FATAL:
- fn = FileName;
- ln = LineNumber;
- break;
+ default:
+ /*NOTREACHED*/;
}
if (ln == last_ln && fn && last_fn && strcmp(fn, last_fn) == 0) {
}
else {
register struct idf *id = expr->VL_IDF;
- register struct def *df;
+ register struct def *df = id->id_def;
ASSERT(expr->VL_CLASS == Name);
- if ((df = id->id_def)->df_type->tp_fund == FUNCTION)
+ if (df->df_type->tp_fund == FUNCTION) {
/* the previous statement tried to catch a function
identifier, which may be cast to a pointer to a
function.
ASSERT(!(rvalue)); ???
*/
C_lpi(id->id_text);
+ }
else
if (df->df_level == L_GLOBAL) {
if (rvalue) {
#endif NOFLOAT
default:
crash("bad conversion to expression");
- break;
+ /*NOTREACHED*/
}
}
break;
default:
crash("(intexpr) bad fund %s\n", symbol2str(fund));
+ /*NOTREACHED*/
}
ex->ex_class = Value;
ex->VL_CLASS = Const;
sc = GLOBAL;
else
if (sc == REGISTER) {
- error("function has illegal storage class");
+ error("function storage class cannot be register");
ds->ds_sc = sc = GLOBAL;
}
}
break;
default:
crash("bad storage class");
- break;
+ /*NOTREACHED*/
}
break;
case GLOBAL:
break;
default:
crash("bad storage class");
- break;
+ /*NOTREACHED*/
}
break;
case STATIC:
break;
default:
crash("bad storage class");
- break;
+ /*NOTREACHED*/
}
break;
case IMPLICIT:
break;
default:
crash("bad storage class");
- break;
+ /*NOTREACHED*/
}
break;
case ENUM:
break;
default:
crash("bad storage class");
- break;
+ /*NOTREACHED*/
}
}
int id_resmac; /* if nonzero: keyword of macroproc. */
#endif NOPP
int id_reserved; /* non-zero for reserved words */
- char *id_file; /* used for warnings */
- long id_line;
+ char *id_file; /* file containing the occurrence */
+ unsigned int id_line; /* line number of the occurrence */
struct def *id_def; /* variables, typedefs, enum-constants */
struct sdef *id_sdef; /* selector tags */
struct tag *id_struct; /* struct and union tags */
#include "noRoption.h"
#include "estack.h"
#include "code.h"
-
#define con_nullbyte() C_con_ucon("0", (arith)1)
#define aggregate_type(tp) ((tp)->tp_fund == ARRAY || (tp)->tp_fund == STRUCT)
break;
default:
crash("check_ival");
+ /*NOTREACHED*/
}
}
hash_stat();
#endif DEBUG
- exit(err_occurred);
+ sys_stop(err_occurred ? S_EXIT : S_END);
+ /*NOTREACHED*/
}
char *source = 0;
{
char *result;
register char *destination = 0;
-
#ifdef DEBUG
#ifndef NOPP
int pp_only = options['E'] || options['P'] || options['C'];
#endif
fatal("%s: destination file not specified", prog_name);
break;
+
case 2:
destination = argv[1];
break;
fatal("use: %s source destination [namelist]", prog_name);
break;
}
+
if (strcmp(argv[0], "-"))
FileName = source = argv[0];
else {
FileName = "standard input";
}
- if (destination && strcmp(destination, "-") == 0)
- destination = 0;
if (!InsertFile(source, (char **) 0, &result)) /* read the source file */
fatal("%s: no source file %s\n", prog_name, FileName);
File_Inserted = 1;
#endif NOPP
#endif DEBUG
{
-
- init_code(destination);
-
+ init_code(destination && strcmp(destination, "-") != 0 ?
+ destination : 0);
/* compile the source text */
C_program();
char options[128]; /* one for every char */
extern int idfsize;
-int txt2int();
+static int txt2int();
do_option(text)
char *text;
{
register char opt;
+next_option: /* to allow combined one-char options */
switch (opt = *text++) {
+ case 0: /* to end the goto next_option loop */
+ break;
+
default:
fatal("illegal option: %c", opt);
break;
+
case '-':
- options[*text] = 1; /* flags, debug options etc. */
- break;
+ options[*text++] = 1; /* flags, debug options etc. */
+ goto next_option;
#ifdef DATAFLOW
case 'd':
case 'R': /* strict version */
#endif
options[opt] = 1;
- break;
-
+ goto next_option;
#ifdef NOROPTION
case 'R':
warning("-R option not implemented");
- break;
+ goto next_option;
#endif
#ifdef ___XXX___
}
}
-int
+static int
txt2int(tp)
register char **tp;
{
#include "code.h"
#include "expr.h"
#include "def.h"
-
#ifndef NOPP
extern arith ifval;
#endif NOPP
break;
default :
crash("(macro_func)");
+ /*NOTREACHED*/
}
}
copy(EOS);
if (++nr_of_params >= NPARAMS) {
- fatal("(getact) too many actuals");
+ fatal("too many actual parameters");
}
actparams[nr_of_params] = aptr;
if (options['t'])
dumpidftab("before unstackidfs", 0);
#endif DEBUG
+
/* The implementation below is more careful than strictly
necessary. Optimists may optimize it afterwards.
*/
#include "code.h"
#include "stack.h"
#include "def.h"
-
extern int level;
}
asm_statement
;
+
expression_statement
{ struct expr *expr;
}
';'
{
#ifdef DEBUG
- print_expr("Full expression", expr);
+ print_expr("expression_statement", expr);
#endif DEBUG
code_expr(expr, RVAL, FALSE, NO_LABEL, NO_LABEL);
free_expression(expr);
';'
expression(&e_incr)?
')'
- {
- }
+ {
+ }
statement
{
C_df_ilb(l_continue);
default:
/* wrong type altogether */
- error("illegal field type (%s)",
+ error("field type cannot be %s",
symbol2str((*fdtpp)->tp_fund));
*fdtpp = error_type;
return field_offset;
{
register struct switch_hdr *sh = switch_stack;
- if (sh == 0)
- error("default not in switch");
- else
- if (sh->sh_default != 0)
+ if (sh == 0) {
+ error("default statement not in switch");
+ return;
+ }
+ if (sh->sh_default != 0) {
error("multiple entry for default in switch");
- else
- C_df_ilb(sh->sh_default = text_label());
+ return;
+ }
+
+ C_df_ilb(sh->sh_default = text_label());
}