From c81a6a0c7a8ee70b85070c746a95d7c1c7e2588e Mon Sep 17 00:00:00 2001 From: ceriel Date: Mon, 13 Mar 1989 15:04:05 +0000 Subject: [PATCH] better warnings for unused/undefined parameters --- lang/m2/comp/Version.c | 2 +- lang/m2/comp/enter.c | 5 ++--- lang/m2/comp/walk.c | 15 ++++++++++++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lang/m2/comp/Version.c b/lang/m2/comp/Version.c index a8b24e900..014e54a6a 100644 --- a/lang/m2/comp/Version.c +++ b/lang/m2/comp/Version.c @@ -1 +1 @@ -static char Version[] = "ACK Modula-2 compiler Version 0.45"; +static char Version[] = "ACK Modula-2 compiler Version 0.46"; diff --git a/lang/m2/comp/enter.c b/lang/m2/comp/enter.c index 0c7723242..6c584acc8 100644 --- a/lang/m2/comp/enter.c +++ b/lang/m2/comp/enter.c @@ -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; diff --git a/lang/m2/comp/walk.c b/lang/m2/comp/walk.c index fbe39b274..4907fd261 100644 --- a/lang/m2/comp/walk.c +++ b/lang/m2/comp/walk.c @@ -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); } }