Skip to content

Commit 1d70384

Browse files
committed
Fixed CORE-6385 - Wrong line and column information after IF statement.
1 parent 59da064 commit 1d70384

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

src/dsql/Parser.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,7 @@ class Parser : public Firebird::PermanentStorage
201201
private:
202202
template <typename T> T* setupNode(Node* node)
203203
{
204-
node->line = yyposn.firstLine;
205-
node->column = yyposn.firstColumn;
204+
setNodeLineColumn(node);
206205
return static_cast<T*>(node);
207206
}
208207

@@ -365,6 +364,8 @@ class Parser : public Firebird::PermanentStorage
365364
void yyMoreStack(yyparsestate* yyps);
366365
yyparsestate* yyNewState(int size);
367366

367+
void setNodeLineColumn(Node* node);
368+
368369
private:
369370
int parseAux();
370371
int yylex1();
@@ -392,6 +393,7 @@ class Parser : public Firebird::PermanentStorage
392393
Position yyretposn;
393394

394395
int yynerrs;
396+
int yym;
395397

396398
// Current parser state
397399
yyparsestate* yyps;

src/dsql/btyacc_fb.ske

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,20 @@ void Parser::yyFreeState(Parser::yyparsestate* p)
179179
}
180180

181181

182+
void Parser::setNodeLineColumn(Node* node)
183+
{
184+
// Check if we are not accessing the position stack below its base.
185+
if (&YYPOSNARG(1) >= yyps->ps)
186+
{
187+
node->line = YYPOSNARG(1).firstLine;
188+
node->column = YYPOSNARG(1).firstColumn;
189+
}
190+
}
191+
192+
182193
int Parser::parseAux()
183194
{
184-
int yym, yyn, yystate, yychar, yynewerrflag;
195+
int yyn, yystate, yychar, yynewerrflag;
185196
yyparsestate *yyerrctx = NULL;
186197
int reduce_posn;
187198

@@ -552,9 +563,6 @@ yyreduce:
552563

553564
reduce_posn = TRUE;
554565

555-
yyposn.firstLine = YYPOSNARG(1).firstLine;
556-
yyposn.firstColumn = YYPOSNARG(1).firstColumn;
557-
558566
switch (yyn) {
559567

560568
%% trailer

0 commit comments

Comments
 (0)