From 75d51eb2fb05db415b7875f08a10e4a2ee0085ba Mon Sep 17 00:00:00 2001 From: Love Waern Date: Thu, 7 Apr 2022 09:04:01 +0200 Subject: [PATCH] Remove element restrictions of compile-time list expressions -- SIMICS-13113 --- RELEASENOTES.md | 2 ++ doc/1.4/language.md | 2 +- py/dml/codegen.py | 12 ++---------- py/dml/messages.py | 6 ------ test/1.2/errors/T_ECLST.dml | 26 -------------------------- 5 files changed, 5 insertions(+), 43 deletions(-) delete mode 100644 test/1.2/errors/T_ECLST.dml diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 17c8c812f..4b738732f 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -228,3 +228,5 @@ as Coverity support is enabled by passing `--coverity` to DMLC. - `release 6 6356` - `release 7 7060` +- `note 6` Elements of compile-time list expressions are now allowed to be + non-constant expressions (fixes SIMICS-13113). diff --git a/doc/1.4/language.md b/doc/1.4/language.md index 5f3619bf0..618687287 100644 --- a/doc/1.4/language.md +++ b/doc/1.4/language.md @@ -4163,7 +4163,7 @@ be consistent. A list is a *compile-time only* value, and is an ordered sequence -of zero or more compile-time constant values. Lists are in particular +of zero or more expressions. Lists are in particular used in combination with `foreach` and `select` statements. diff --git a/py/dml/codegen.py b/py/dml/codegen.py index 98018c0e8..f5b327940 100644 --- a/py/dml/codegen.py +++ b/py/dml/codegen.py @@ -1301,16 +1301,8 @@ def expr_slice(tree, location, scope): @expression_dispatcher def expr_list(tree, location, scope): [elts] = tree.args - values = [] - for elt in elts: - e = codegen_expression_maybe_nonvalue(elt, location, scope) - if e.constant or isinstance(e, (NodeRef, AbstractList, NodeArrayRef, - SessionVariableRef)): - values.append(e) - elif isinstance(e, NonValue): - raise e.exc() - else: - raise ECLST(e) + values = [codegen_expression_maybe_nonvalue(elt, location, scope) + for elt in elts] return mkList(tree.site, values) @expression_dispatcher diff --git a/py/dml/messages.py b/py/dml/messages.py index be503fed6..29c45dd57 100644 --- a/py/dml/messages.py +++ b/py/dml/messages.py @@ -530,12 +530,6 @@ class EAVAR(DMLError): """ fmt = "cannot use variable index in a constant list" -class ECLST(DMLError): - """ - Lists may only contain constants. - """ - fmt = "non-constant element in list" - class ENLST(DMLError): """ A list was expected. diff --git a/test/1.2/errors/T_ECLST.dml b/test/1.2/errors/T_ECLST.dml deleted file mode 100644 index 1f1fcc6d4..000000000 --- a/test/1.2/errors/T_ECLST.dml +++ /dev/null @@ -1,26 +0,0 @@ -/* - © 2021 Intel Corporation - SPDX-License-Identifier: MPL-2.0 -*/ -dml 1.2; -device test; - -extern int f(); - -port p0 { - /// ERROR ECLST - parameter l1 = [1,f(),3]; -} - -port p1 { - // No error here (but it used to be one) - parameter l2 = [1,$dev.name,3]; -} - -data int a[2]; -port p2 { - // This used to be permitted as a weird side-effect of unevalled - // expressions. - /// ERROR ECLST - parameter p1 = [$a[0]]; -}