From 0160b290c2236b29a1623d4f859f6ee2e640c1f9 Mon Sep 17 00:00:00 2001 From: Erik Carstensen Date: Thu, 5 Sep 2024 15:08:49 +0200 Subject: [PATCH 1/2] Remove obsolete warnings --- RELEASENOTES.md | 8 +++++++ messages_to_md.py | 2 +- py/dml/c_backend.py | 5 ----- py/dml/ctree.py | 4 +--- py/dml/dmlc.py | 7 ------ py/dml/messages.py | 55 +-------------------------------------------- py/dml/structure.py | 4 +--- 7 files changed, 12 insertions(+), 73 deletions(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index d886e86b5..86b546057 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -175,3 +175,11 @@ - `release 6 6316` - `release 7 7027` - `release 6 6138` +- `note 6` Removed the obsolete warning types `WSYSTEMC` and `WDUPEVENT`. These + warnings were never reported. This change will cause errors if existing + makefiles pass e.g. `--nowarn=WSYSTEMC`. +- `note 6` Removed the obsolete warning types `WSHALL`, `WNDOC`, and + `WNSHORTDESC`. These are all disabled by default and have no known uses, + typically because enabling them produced a overwhelming noise from false + positives. This change will cause errors if exiting makefiles pass e.g. + `--warn=WSHALL`. diff --git a/messages_to_md.py b/messages_to_md.py index 5ef7bd3f9..18cc38514 100644 --- a/messages_to_md.py +++ b/messages_to_md.py @@ -60,7 +60,7 @@ def print_messages(f, warnings, errors): ## Warning Messages The messages are listed in alphabetical order; the corresponding tags -are shown within brackets, e.g., `[WNDOC]`. +are shown within brackets, e.g., `[WNDOCRA]`. """) diff --git a/py/dml/c_backend.py b/py/dml/c_backend.py index 8e890ee9b..f6e221c30 100644 --- a/py/dml/c_backend.py +++ b/py/dml/c_backend.py @@ -512,8 +512,6 @@ def check_attribute(node, port, prefix): if (node.objtype in {'attribute', 'connect'} and config_param == 'required'): report(WNDOCRA(node, node.logname())) - elif node.objtype != 'register': - report(WNDOC(node, node.logname())) attrname = get_attr_name(prefix, node) register_attribute(node.site, port, attrname) if port and need_port_proxy_attrs(port): @@ -543,7 +541,6 @@ def generate_attribute_common(initcode, node, port, dimsizes, prefix, report(WNDOCRA(node, node.logname())) doc = "Undocumented" else: - report(WNDOC(node, node.logname())) doc = "Undocumented" # append the required interfaces to the docstring @@ -1954,8 +1951,6 @@ def generate_init(device, initcode, outprefix): out('.description = '+doc.read()+',\n') if sdoc: out('.short_desc = '+sdoc.read()+',\n') - else: - report(WNSHORTDESC(device.site)) out('};\n', preindent = -1) out('\n') out('conf_class_t *class = SIM_create_class("' diff --git a/py/dml/ctree.py b/py/dml/ctree.py index 31bddcfe8..f0095392d 100644 --- a/py/dml/ctree.py +++ b/py/dml/ctree.py @@ -2033,9 +2033,7 @@ def make_simple(site, lh, rh): etype = realtype(expr.ctype()) assert etype.is_int ltype = realtype(lh.ctype()) - if etype.bits < 1: - report(WSHALL(site, lh, rh)) - elif ltype.bits > 32 and etype.bits <= 32: + if ltype.bits > 32 and etype.bits <= 32: expr = mkCast(site, expr, etype) return expr diff --git a/py/dml/dmlc.py b/py/dml/dmlc.py index 86d4b138a..02f4f7b87 100644 --- a/py/dml/dmlc.py +++ b/py/dml/dmlc.py @@ -35,13 +35,6 @@ def prerr(msg): output_c = True -# Ignore some warnings by default -ignore_warning('WASSERT') -ignore_warning('WNDOC') -ignore_warning('WSHALL') -ignore_warning('WUNUSED') -ignore_warning('WNSHORTDESC') - if os.getenv('DMLC_DEBUG'): debug_mode = True else: diff --git a/py/dml/messages.py b/py/dml/messages.py index 8d7b9cc21..328b35dc4 100644 --- a/py/dml/messages.py +++ b/py/dml/messages.py @@ -1896,32 +1896,7 @@ class WNOVER(DMLWarning): """ fmt = "file has no version tag, assuming version 1.2" -class WSHALL(DMLWarning): """ - The result of the shift operation will always be zero. - (This warning is disabled by default.) - """ - fmt = "shifting away all data\n%s" - def __init__(self, node, lh, rh): - DMLWarning.__init__(self, node, binary_dump(lh, rh)) - -class WNDOC(DMLWarning): - """ - No documentation string was specified for the attribute. - (This warning is disabled by default.) - """ - fmt = "no documentation for '%s'" - def __init__(self, node, member): - DMLWarning.__init__(self, node, member) - -class WNSHORTDESC(DMLWarning): - """ - No short description string was specified using the 'desc' parameter. - (This warning is disabled by default.) - """ - fmt = "no 'desc' parameter specified for device" - def __init__(self, node): - DMLWarning.__init__(self, node) class WNDOCRA(DMLWarning): """ @@ -1939,16 +1914,6 @@ class WNEGOFFS(DMLWarning): """ fmt = "negative register offset: %d" -class WUNUSED(DMLWarning): - """ - The object is not referenced anywhere. - (This warning is disabled by default.; it typically causes many false - warnings.) - """ - fmt = "unused: %s" - def __init__(self, obj): - DMLWarning.__init__(self, obj, obj.identity()) - class WUNUSEDDEFAULT(DMLWarning): """ The object is not referenced anywhere but it matches a name of an @@ -1980,16 +1945,6 @@ class WUNUSED_DML12(DMLWarning): def __init__(self, obj): DMLWarning.__init__(self, obj, obj.name) -class WDUPEVENT(DMLWarning): - """ - Two or more events will be checkpointed using the same name, which - means that the checkpoint cannot be safely read back. - """ - fmt = "duplicate event checkpoint names: %s" - def __init__(self, site, objlist): - DMLWarning.__init__(self, site, - ", ".join(dollar(self.site) + o.logname() - for o in objlist)) class WSIZEOFTYPE(DMLWarning): """ @@ -2028,11 +1983,6 @@ class WCONFIDENTIAL(DMLWarning): def __init__(self, site): DMLWarning.__init__(self, site) -# Not used (see ctree.py class CopyData), not documented. -# class WASSIGN(DMLWarning): -# def __init__(self, site): -# DMLWarning.__init__(self, site, "cannot perform assignment") - class WOLDAST(DMLWarning): """ A precompiled DML file has an old time-stamp. This may happen if a @@ -2052,11 +2002,8 @@ class WWRNSTMT(DMLWarning): """ fmt = "%s" -class WSYSTEMC(DMLWarning): - """ SystemC specific warnings """ - fmt = "%s" - # This message should be removed, SIMICS-9886 +# This message should be removed, SIMICS-9886 class WREF(DMLWarning): """An unused parameter refers to an object that has not been declared. diff --git a/py/dml/structure.py b/py/dml/structure.py index a8b1b1473..239a64aa9 100644 --- a/py/dml/structure.py +++ b/py/dml/structure.py @@ -463,9 +463,7 @@ def check_unused_and_warn(node): not used. This usually applies to methods and parameters.""" if node.refcount == 0: - if not warning_is_ignored('WUNUSED'): - report(WUNUSED(node)) - elif is_unused_default(node): + if is_unused_default(node): report(WUNUSEDDEFAULT(node)) elif dml.globals.dml_version != (1, 2) and is_dml12_method(node): report(WUNUSED_DML12(node)) From e7406ad75d0c56c3db1d6e7e3e186273afe1e2a3 Mon Sep 17 00:00:00 2001 From: Erik Carstensen Date: Thu, 5 Sep 2024 15:09:03 +0200 Subject: [PATCH 2/2] Polished documentation for some warnings --- py/dml/messages.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/py/dml/messages.py b/py/dml/messages.py index 328b35dc4..363d1d158 100644 --- a/py/dml/messages.py +++ b/py/dml/messages.py @@ -1893,10 +1893,11 @@ def log(self): class WNOVER(DMLWarning): """ A DML file must start with a version statement, such as `dml 1.4;` - """ - fmt = "file has no version tag, assuming version 1.2" + This warning becomes an error in Simics API 8 and newer, when the + compatibility feature `optional_version_statement` is disabled. """ + fmt = "file has no version tag, assuming version 1.2" class WNDOCRA(DMLWarning): """ @@ -1916,10 +1917,11 @@ class WNEGOFFS(DMLWarning): class WUNUSEDDEFAULT(DMLWarning): """ - The object is not referenced anywhere but it matches a name of an - object automatically referenced in another scope. This is the same - as WUNUSED but only for known common errors and it will never be - emitted if WUNUSED is enabled. + In DML 1.2, it is usually a mistake to implement a method named + `after_write` in a field, because only register objects recognize that + method. The `WUNUSEDDEFAULT` warning captures this kind of mistake + by reporting a warning when a method is implemented that is unused, + but whose name matches a method commonly implemented in other objects. """ fmt = "unused: %s methods are not called automatically for %s objects in %s" def __init__(self, obj): @@ -1945,11 +1947,11 @@ class WUNUSED_DML12(DMLWarning): def __init__(self, obj): DMLWarning.__init__(self, obj, obj.name) - class WSIZEOFTYPE(DMLWarning): """ - The 'sizeof' operator is used on a type name, but expects an - expression. Use the 'sizeoftype' operator for types. + In DML 1.4 it is an error to pass a type name as the operand of `sizeof`. + In DML 1.2 it instead emits a `WSIZEOFTYPE` warning, for legacy reasons. + To get the size of a type, the `sizeoftype` operator should be used. """ fmt = "sizeof on a type is not legal, use sizeoftype instead" @@ -2007,8 +2009,8 @@ class WWRNSTMT(DMLWarning): class WREF(DMLWarning): """An unused parameter refers to an object that has not been declared. - This warning message will be replaced with a hard error in future - major versions of Simics. + This warning message is replaced with a hard error for modules compiled + with Simics API 6 or newer. """ instances = [] fmt = "unused parameter %s contains %s"