Skip to content

Commit 1417aed

Browse files
committed
error recovery for the duplicate enum
1 parent 3a52e21 commit 1417aed

File tree

12 files changed

+334
-321
lines changed

12 files changed

+334
-321
lines changed

src/parser/ds2_parser.cpp

Lines changed: 100 additions & 100 deletions
Large diffs are not rendered by default.

src/parser/ds2_parser.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ union DAS2_YYSTYPE
324324
AnnotationList * faList;
325325
MakeStruct * pMakeStruct;
326326
Enumeration * pEnum;
327+
Enumeration * pEnumList;
327328
EnumPair * pEnumPair;
328329
Structure * pStructure;
329330
Function * pFuncDecl;

src/parser/ds2_parser.output

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2064,7 +2064,7 @@ Nonterminals, with rules where they appear
20642064
commas (395)
20652065
on left: 642 643
20662066
on right: 643 646 660 737 738
2067-
enum_list <pEnum> (396)
2067+
enum_list <pEnumList> (396)
20682068
on left: 644 645 646
20692069
on right: 646 668
20702070
optional_public_or_private_alias <b> (397)

src/parser/ds2_parser.ypp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@
144144
AnnotationList * faList;
145145
MakeStruct * pMakeStruct;
146146
Enumeration * pEnum;
147+
Enumeration * pEnumList;
147148
EnumPair * pEnumPair;
148149
Structure * pStructure;
149150
Function * pFuncDecl;
@@ -166,7 +167,8 @@
166167
%destructor { delete $$; } <fa>
167168
%destructor { delete $$; } <faList>
168169
%destructor { delete $$; } <pMakeStruct>
169-
%destructor { if ( $$->use_count()==1 ) delete $$; } <pEnum>
170+
%destructor { $$->delRef(); } <pEnum>
171+
%destructor { delete $$; } <pEnumList>
170172
%destructor { delete $$; } <pEnumPair>
171173
%destructor { delete $$; } <pCapt>
172174
%destructor { delete $$; } <pCaptList>
@@ -453,7 +455,7 @@
453455

454456
%type <i> copy_or_move_or_clone
455457

456-
%type <pEnum> enum_list
458+
%type <pEnumList> enum_list
457459
%type <pEnumPair> enum_expression
458460

459461
%type <pExpression> expr

src/parser/ds_parser.cpp

Lines changed: 107 additions & 107 deletions
Large diffs are not rendered by default.

src/parser/ds_parser.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ union DAS_YYSTYPE
328328
AnnotationList * faList;
329329
MakeStruct * pMakeStruct;
330330
Enumeration * pEnum;
331+
Enumeration * pEnumList;
331332
Structure * pStructure;
332333
Function * pFuncDecl;
333334
CaptureEntry * pCapt;

src/parser/ds_parser.output

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2105,7 +2105,7 @@ Nonterminals, with rules where they appear
21052105
$@41 (401)
21062106
on left: 661
21072107
on right: 662
2108-
enum_list <pEnum> (402)
2108+
enum_list <pEnumList> (402)
21092109
on left: 663 664 665 666
21102110
on right: 664 665 666 683 686
21112111
optional_public_or_private_alias <b> (403)

src/parser/ds_parser.ypp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
AnnotationList * faList;
126126
MakeStruct * pMakeStruct;
127127
Enumeration * pEnum;
128+
Enumeration * pEnumList;
128129
Structure * pStructure;
129130
Function * pFuncDecl;
130131
CaptureEntry * pCapt;
@@ -146,7 +147,8 @@
146147
%destructor { delete $$; } <fa>
147148
%destructor { delete $$; } <faList>
148149
%destructor { delete $$; } <pMakeStruct>
149-
%destructor { if ( $$->use_count()==1 ) delete $$; } <pEnum>
150+
%destructor { $$->delRef(); } <pEnum>
151+
%destructor { delete $$; } <pEnumList>
150152
%destructor { delete $$; } <pCapt>
151153
%destructor { delete $$; } <pCaptList>
152154
%destructor { delete $$.firstType; delete $$.secondType; } <aTypePair>
@@ -443,7 +445,7 @@
443445

444446
%type <i> copy_or_move_or_clone
445447

446-
%type <pEnum> enum_list
448+
%type <pEnumList> enum_list
447449

448450
%type <pExpression> expr
449451
%type <pExpression> expr_mtag

src/parser/parser_impl.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,10 @@ namespace das {
490490
}
491491

492492
void ast_enumDeclaration ( yyscan_t scanner, AnnotationList * annL, const LineInfo & atannL, bool pubE, Enumeration * pEnum, Enumeration * pE, Type ebt ) {
493+
if ( !pEnum->module ) {
494+
pEnum->delRef();
495+
return;
496+
}
493497
pEnum->baseType = ebt;
494498
pEnum->isPrivate = !pubE;
495499
pEnum->list = das::move(pE->list);

utils/dasFormatter/ds_parser.cpp

Lines changed: 106 additions & 106 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)