Report error when trying to declare class methods with static lifetime

Class methods with static lifetime are not allowed in SystemVerilog. Report
an error when such a method is declared.

Note that this is different from static class methods
E.g.
```
class C;
  task static t; endtask // Class method with static lifetime, forbidden
  static task t; endtask // Static class method, allowed
```

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2022-12-18 16:11:54 -08:00
parent 54a4e7ff0b
commit 3302ced608
1 changed files with 14 additions and 0 deletions

View File

@ -517,7 +517,14 @@ static void elaborate_scope_class(Design*des, NetScope*scope, PClass*pclass)
hname_t use_name (cur->first);
NetScope*method_scope = new NetScope(class_scope, use_name, NetScope::TASK);
// Task methods are always automatic...
if (!cur->second->is_auto()) {
cerr << "error: Lifetime of method `"
<< scope_path(method_scope)
<< "` must not be static" << endl;
des->errors += 1;
}
method_scope->is_auto(true);
method_scope->set_line(cur->second);
method_scope->add_imports(&cur->second->explicit_imports);
@ -536,7 +543,14 @@ static void elaborate_scope_class(Design*des, NetScope*scope, PClass*pclass)
hname_t use_name (cur->first);
NetScope*method_scope = new NetScope(class_scope, use_name, NetScope::FUNC);
// Function methods are always automatic...
if (!cur->second->is_auto()) {
cerr << "error: Lifetime of method `"
<< scope_path(method_scope)
<< "` must not be static" << endl;
des->errors += 1;
}
method_scope->is_auto(true);
method_scope->set_line(cur->second);
method_scope->add_imports(&cur->second->explicit_imports);