From 85edd8bb182809f297a01ae3ba2f06356dfc8ccd Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 4 Oct 2022 22:01:18 +0200 Subject: [PATCH] Handle calling void function from class method Calling a void function (or a regular function and ignoring the result) from within a class method will currently result in an error unless the void function itself is a method of the same class. This is because we add the implicit `this` as an object on which to search for the function and if we do not find it print an error. Change this to only print an error if the implicit this was not added and it was a method call on an object identifier. Signed-off-by: Lars-Peter Clausen --- elaborate.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/elaborate.cc b/elaborate.cc index 6a38d8b16..f23e796c4 100644 --- a/elaborate.cc +++ b/elaborate.cc @@ -3844,10 +3844,15 @@ NetProc* PCallTask::elaborate_method_(Design*des, NetScope*scope, if (const netclass_t*class_type = net->class_type()) { NetScope*task = class_type->method_from_name(method_name); if (task == 0) { - cerr << get_fileline() << ": error: " - << "Can't find task " << method_name - << " in class " << class_type->get_name() << endl; - des->errors += 1; + // If an implicit this was added it is not an error if we + // don't find a method. It might actually be a call to a + // function outside of the class. + if (!add_this_flag) { + cerr << get_fileline() << ": error: " + << "Can't find task " << method_name + << " in class " << class_type->get_name() << endl; + des->errors += 1; + } return 0; }