better warnings for unused/undefined parameters
This commit is contained in:
parent
0975784c8d
commit
c81a6a0c7a
|
@ -1 +1 @@
|
|||
static char Version[] = "ACK Modula-2 compiler Version 0.45";
|
||||
static char Version[] = "ACK Modula-2 compiler Version 0.46";
|
||||
|
|
|
@ -215,13 +215,12 @@ EnterParamList(ppr, Idlist, type, VARp, off)
|
|||
else df = new_def();
|
||||
pr->par_def = df;
|
||||
df->df_type = type;
|
||||
df->df_flags |= (VARp | D_DEFINED);
|
||||
if (df->df_flags & D_VARPAR) df->df_flags |= D_USED;
|
||||
df->df_flags |= VARp;
|
||||
|
||||
if (IsConformantArray(type)) {
|
||||
/* 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) {
|
||||
*off += pointer_size;
|
||||
|
|
|
@ -897,24 +897,33 @@ UseWarnings(df)
|
|||
if (! (df->df_kind & (D_VARIABLE|D_PROCEDURE|D_TYPE|D_CONST))) {
|
||||
return;
|
||||
}
|
||||
switch(df->df_flags & (D_USED|D_DEFINED)) {
|
||||
switch(df->df_flags & (D_USED|D_DEFINED|D_VALPAR|D_VARPAR)) {
|
||||
case 0:
|
||||
case D_VALPAR:
|
||||
case D_VARPAR:
|
||||
warning = "never used/assigned";
|
||||
break;
|
||||
case D_USED|D_VARPAR:
|
||||
warning = "never assigned, could be value parameter";
|
||||
break;
|
||||
case D_USED:
|
||||
warning = "never assigned";
|
||||
break;
|
||||
case D_DEFINED:
|
||||
case D_DEFINED|D_VALPAR:
|
||||
warning = "never used";
|
||||
break;
|
||||
case D_USED|D_DEFINED:
|
||||
default:
|
||||
return;
|
||||
}
|
||||
warn:
|
||||
if (warning) {
|
||||
node_warning(df->df_scope->sc_end,
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue