From abc26eeaeb3194e01045235c8680318f351aee18 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 12 Oct 2022 15:54:22 +0200 Subject: [PATCH] Report error when calling void function in an expression Unlike normal functions void functions can not be called as part of an expression. Trying so will currently hit an internal assert. Make sure an error is reported instead. Signed-off-by: Lars-Peter Clausen --- elab_expr.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/elab_expr.cc b/elab_expr.cc index acd599a25..0c9c330aa 100644 --- a/elab_expr.cc +++ b/elab_expr.cc @@ -1642,6 +1642,9 @@ unsigned PECallFunction::test_width(Design*des, NetScope*scope, return 0; } + if (def->is_void()) + return 0; + NetScope*dscope = def->scope(); assert(dscope); @@ -2860,6 +2863,14 @@ NetExpr* PECallFunction::elaborate_base_(Design*des, NetScope*scope, NetScope*ds if (parm_errors) return 0; + if (def->is_void()) { + cerr << get_fileline() << ": error: void function `" + << dscope->basename() << "` can not be called in an expression." + << endl; + des->errors++; + return nullptr; + } + /* Look for the return value signal for the called function. This return value is a magic signal in the scope of the function, that has the name of the function. The