better warnings for unused/undefined parameters

This commit is contained in:
ceriel 1989-03-13 15:04:05 +00:00
parent 0975784c8d
commit c81a6a0c7a
3 changed files with 15 additions and 7 deletions

View file

@ -1 +1 @@
static char Version[] = "ACK Modula-2 compiler Version 0.45"; static char Version[] = "ACK Modula-2 compiler Version 0.46";

View file

@ -215,13 +215,12 @@ EnterParamList(ppr, Idlist, type, VARp, off)
else df = new_def(); else df = new_def();
pr->par_def = df; pr->par_def = df;
df->df_type = type; df->df_type = type;
df->df_flags |= (VARp | D_DEFINED); df->df_flags |= VARp;
if (df->df_flags & D_VARPAR) df->df_flags |= D_USED;
if (IsConformantArray(type)) { if (IsConformantArray(type)) {
/* we need room for the base address and a descriptor /* we need room for the base address and a descriptor
*/ */
*off += pointer_size + 3 * word_size; *off += pointer_size + word_size + dword_size;
} }
else if (VARp == D_VARPAR) { else if (VARp == D_VARPAR) {
*off += pointer_size; *off += pointer_size;

View file

@ -897,24 +897,33 @@ UseWarnings(df)
if (! (df->df_kind & (D_VARIABLE|D_PROCEDURE|D_TYPE|D_CONST))) { if (! (df->df_kind & (D_VARIABLE|D_PROCEDURE|D_TYPE|D_CONST))) {
return; return;
} }
switch(df->df_flags & (D_USED|D_DEFINED)) { switch(df->df_flags & (D_USED|D_DEFINED|D_VALPAR|D_VARPAR)) {
case 0: case 0:
case D_VALPAR:
case D_VARPAR:
warning = "never used/assigned"; warning = "never used/assigned";
break; break;
case D_USED|D_VARPAR:
warning = "never assigned, could be value parameter";
break;
case D_USED: case D_USED:
warning = "never assigned"; warning = "never assigned";
break; break;
case D_DEFINED: case D_DEFINED:
case D_DEFINED|D_VALPAR:
warning = "never used"; warning = "never used";
break; break;
case D_USED|D_DEFINED: default:
return; return;
} }
warn: warn:
if (warning) { if (warning) {
node_warning(df->df_scope->sc_end, node_warning(df->df_scope->sc_end,
W_ORDINARY, W_ORDINARY,
"identifier \"%s\" %s", "%s \"%s\" %s",
(df->df_flags & D_VALPAR) ? "value parameter" :
(df->df_flags & D_VARPAR) ? "variable parameter" :
"identifier",
df->df_idf->id_text, warning); df->df_idf->id_text, warning);
} }
} }