SystemVerilog: The last coverpoint definition of covergroup caused Error Scope conditionally
When last coverpoint definition of covergroup cover a variable for a hierarchical index (for example from interface), in addition, it has bins definition with {...}, this will cause error scope of subsequent tags parser. For details, see what I've commented on in the follow code (recur.sv).
class A;
covergroup A0;
coverpoint intf.x {
bins foo = { 0 };
bins bar = { 1 };
}
coverpoint intf.y {
bins foo = { 0 };
bins bar = { 1 };
}
// empty bins definition, end of ';', everything is OK.
coverpoint intf.z;
endgroup
covergroup A1;
coverpoint intf.a;
coverpoint intf.b;
// bins definition with '{}', but not a variable by hierarchical index, OK.
coverpoint no_sro {
bins foo = { 0 };
bins bar = { 1 };
}
endgroup
covergroup A2;
coverpoint intf.m {
bins foo = { 0 };
bins bar = { 1 };
}
coverpoint intf.n {
bins foo = { 0 };
bins bar = { 1 };
}
// exceptional, index by 'this', OK.
coverpoint this.t {
bins foo = { 0 };
bins bar = { 1 };
}
endgroup
covergroup A3;
coverpoint intf.r {
bins foo = { 0 };
bins bar = { 1 };
}
coverpoint intf.s {
bins foo = { 0 };
bins bar = { 1 };
}
// contain multiple hierarchical variable, OK.
cross intf.u, intf.v {
bins foo = { 0 };
bins bar = { 1 };
}
endgroup
covergroup A4;
coverpoint intf.p;
// last definition, hierarchical variable, bins definition with '{}'
// meet at the same time, subsequent parsers will all go WRONG.
coverpoint intf.q {
bins foo = { 0 };
bins bar = { 1 };
}
endgroup
// Error Scope >> covergroup:A.A4
covergroup A5;
coverpoint foo;
coverpoint bar;
endgroup
endclass
// Error Scope >> covergroup:A.A4
class B;
int one, two;
function new();
endfunction
endclass
// Error Scope >> covergroup:A.A4
typedef enum { FOO, BAR } E;
Outputs Error Hierarchy as follow:

The expected Correct Hierarchy as follow:

Other Information
The name of the parser: Verilog/SystemVerilog
The command line you used to run ctags: ctags --options=NONE recur.sv
Current tags output contents as follow:
A recur.sv /^class A;$/;" C
A0 recur.sv /^ covergroup A0;$/;" V class:A
A1 recur.sv /^ covergroup A1;$/;" V class:A
A2 recur.sv /^ covergroup A2;$/;" V class:A
A3 recur.sv /^ covergroup A3;$/;" V class:A
A4 recur.sv /^ covergroup A4;$/;" V class:A
A5 recur.sv /^ covergroup A5;$/;" V covergroup:A.A4
B recur.sv /^class B;$/;" C covergroup:A.A4
BAR recur.sv /^typedef enum { FOO, BAR } E;$/;" c typedef:A.A4.E
E recur.sv /^typedef enum { FOO, BAR } E;$/;" T covergroup:A.A4
FOO recur.sv /^typedef enum { FOO, BAR } E;$/;" c typedef:A.A4.E
new recur.sv /^ function new();$/;" f class:A.A4.B
one recur.sv /^ int one, two;$/;" r class:A.A4.B
two recur.sv /^ int one, two;$/;" r class:A.A4.B
The tags output you expect:
A recur.sv /^class A;$/;" C
A0 recur.sv /^ covergroup A0;$/;" V class:A
A1 recur.sv /^ covergroup A1;$/;" V class:A
A2 recur.sv /^ covergroup A2;$/;" V class:A
A3 recur.sv /^ covergroup A3;$/;" V class:A
A4 recur.sv /^ covergroup A4;$/;" V class:A
A5 recur.sv /^ covergroup A5;$/;" V class:A
B recur.sv /^class B;$/;" C
BAR recur.sv /^typedef enum { FOO, BAR } E;$/;" c typedef:E
E recur.sv /^typedef enum { FOO, BAR } E;$/;" T
FOO recur.sv /^typedef enum { FOO, BAR } E;$/;" c typedef:E
new recur.sv /^ function new();$/;" f class:B
one recur.sv /^ int one, two;$/;" r class:B
two recur.sv /^ int one, two;$/;" r class:B
How do you get ctags binary: win32 binary taken from Universal-ctags/ctags-win32 project
The version of ctags:
$ ctags --version
Universal Ctags 5.9.0(55e668a), Copyright (C) 2015-2022 Universal Ctags Team
Universal Ctags is derived from Exuberant Ctags.
Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
Compiled: Jul 25 2022, 03:23:16
URL: https://ctags.io/
Optional compiled features: +win32, +wildcards, +regex, +gnulib_regex, +internal-sort, +unix-path-separator, +iconv, +option-directory, +xpath, +json, +interactive, +yaml, +case-insensitive-filenames, +packcc, +optscript, +pcre2
Thank you for your report. I will take a look. Give me some days.
@roccomao,
I've sent a PR #3458, the fix for this bug.
Your detailed test-case helped me a lot.
At a glance I thought cross might have some issues. But it was not correct.
All of identifiers including '.' (intf.z in A0, this.f in A2, intf.u, intf.v in A3, and intf.q in A4) caused parse-errors internally.
Fortunately the errors are recovered, except for one in A4.
As the result only endgroup in A4 was ignored.
@masatake,
Please review it.
The fix was merged. If you still see any problem, let me know.
Let me close this.