Skip to content

Commit a7b07d7

Browse files
authored
Merge pull request #4058 from hirooih/verilog-directive-in-enum-#4056
verilog: skip compiler directives in enum definition (#4056)
2 parents 268a0b5 + fa358f4 commit a7b07d7

File tree

4 files changed

+68
-0
lines changed

4 files changed

+68
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--sort=no
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
my_enum input.sv /^} my_enum;$/;" T
2+
OTHER_VAL1 input.sv /^ OTHER_VAL1,$/;" c typedef:my_enum
3+
OTHER_VAL2 input.sv /^ OTHER_VAL2$/;" c typedef:my_enum
4+
e input.sv /^my_enum e;$/;" r
5+
O input.sv /^class O;$/;" C
6+
complex0_s input.sv /^ } [1:0] complex0_s, complex1_s;$/;" S class:O
7+
a input.sv /^ logic a,b ;$/;" w struct:O.complex0_s
8+
b input.sv /^ logic a,b ;$/;" w struct:O.complex0_s
9+
s0 input.sv /^ logic [15:0] [7:0] s0 , s1;$/;" w struct:O.complex0_s
10+
s1 input.sv /^ logic [15:0] [7:0] s0 , s1;$/;" w struct:O.complex0_s
11+
struct0_s input.sv /^ } [15:0] [7:0] struct0_s, struct1_s;$/;" w struct:O.complex0_s
12+
struct1_s input.sv /^ } [15:0] [7:0] struct0_s, struct1_s;$/;" w struct:O.complex0_s
13+
enum00_e input.sv /^ enum user_t [1:0] { FOO, BAR, BAZ } [3:0] enum00_e, enum01_e ;$/;" w struct:O.complex0_s
14+
enum01_e input.sv /^ enum user_t [1:0] { FOO, BAR, BAZ } [3:0] enum00_e, enum01_e ;$/;" w struct:O.complex0_s
15+
enum10_e input.sv /^ enum logic unsigned{A,B,C}[1:0]enum10_e,enum11_e;$/;" w struct:O.complex0_s
16+
enum11_e input.sv /^ enum logic unsigned{A,B,C}[1:0]enum10_e,enum11_e;$/;" w struct:O.complex0_s
17+
d input.sv /^ bit[7:0][1:0]d,e;$/;" w struct:O.complex0_s
18+
e input.sv /^ bit[7:0][1:0]d,e;$/;" w struct:O.complex0_s
19+
complex1_s input.sv /^ } [1:0] complex0_s, complex1_s;$/;" S class:O
20+
a input.sv /^ logic a,b ;$/;" w struct:O.complex1_s
21+
b input.sv /^ logic a,b ;$/;" w struct:O.complex1_s
22+
s0 input.sv /^ logic [15:0] [7:0] s0 , s1;$/;" w struct:O.complex1_s
23+
s1 input.sv /^ logic [15:0] [7:0] s0 , s1;$/;" w struct:O.complex1_s
24+
struct0_s input.sv /^ } [15:0] [7:0] struct0_s, struct1_s;$/;" w struct:O.complex1_s
25+
struct1_s input.sv /^ } [15:0] [7:0] struct0_s, struct1_s;$/;" w struct:O.complex1_s
26+
enum00_e input.sv /^ enum user_t [1:0] { FOO, BAR, BAZ } [3:0] enum00_e, enum01_e ;$/;" w struct:O.complex1_s
27+
enum01_e input.sv /^ enum user_t [1:0] { FOO, BAR, BAZ } [3:0] enum00_e, enum01_e ;$/;" w struct:O.complex1_s
28+
enum10_e input.sv /^ enum logic unsigned{A,B,C}[1:0]enum10_e,enum11_e;$/;" w struct:O.complex1_s
29+
enum11_e input.sv /^ enum logic unsigned{A,B,C}[1:0]enum10_e,enum11_e;$/;" w struct:O.complex1_s
30+
d input.sv /^ bit[7:0][1:0]d,e;$/;" w struct:O.complex1_s
31+
e input.sv /^ bit[7:0][1:0]d,e;$/;" w struct:O.complex1_s
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// https://github.com/universal-ctags/ctags/issues/4056
2+
3+
typedef enum {
4+
`include "test1.txt"
5+
OTHER_VAL1,
6+
`include "test2.txt"
7+
OTHER_VAL2
8+
} my_enum;
9+
10+
my_enum e;
11+
12+
// from Units/parser-verilog.r/systemverilog-struct.d/input.sv
13+
class O;
14+
// complex struct
15+
struct packed signed {
16+
`include "test1.txt"
17+
logic a,b ;
18+
logic [15:0] [7:0] s0 , s1;
19+
`include "test1.txt"
20+
struct {
21+
`include "test1.txt"
22+
logic x, y; // not emitted
23+
`include "test1.txt"
24+
} [15:0] [7:0] struct0_s, struct1_s;
25+
`include "test1.txt"
26+
enum user_t [1:0] { FOO, BAR, BAZ } [3:0] enum00_e, enum01_e ;
27+
`include "test1.txt"
28+
enum logic unsigned{A,B,C}[1:0]enum10_e,enum11_e;
29+
bit[7:0][1:0]d,e;
30+
`include "test1.txt"
31+
} [1:0] complex0_s, complex1_s;
32+
endclass

parsers/verilog.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,6 +1614,7 @@ static int pushEnumNames (tokenInfo* token, int c)
16141614
c = skipWhite (vGetc ());
16151615
while (c != '}' && c != EOF)
16161616
{
1617+
c = skipMacro (c, token);
16171618
if (!isWordToken (c))
16181619
{
16191620
VERBOSE ("Unexpected input: %c\n", c);
@@ -1652,6 +1653,9 @@ static int pushMembers (tokenInfo* token, int c)
16521653
{
16531654
verilogKind kind = K_UNDEFINED; // set kind of context for processType()
16541655
bool not_used;
1656+
c = skipMacro (c, token);
1657+
if (c == '}')
1658+
break; // end of struct/union
16551659
if (!isWordToken (c))
16561660
{
16571661
VERBOSE ("Unexpected input: %c\n", c);

0 commit comments

Comments
 (0)