Skip to content

Commit

Permalink
fix issue 17619: for statements without curly braces, default endloc …
Browse files Browse the repository at this point in the history
…to location of last token, not next token
  • Loading branch information
rainers committed Oct 7, 2017
1 parent cf3005b commit 056160d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/ddmd/lexer.d
Expand Up @@ -187,6 +187,7 @@ class Lexer
__gshared OutBuffer stringbuffer;

Loc scanloc; // for error messages
Loc prevloc; // location of token before current

const(char)* base; // pointer to start of buffer
const(char)* end; // pointer to last element of buffer
Expand Down Expand Up @@ -252,6 +253,7 @@ class Lexer

final TOK nextToken()
{
prevloc = token.loc;
if (token.next)
{
Token* t = token.next;
Expand Down
4 changes: 2 additions & 2 deletions src/ddmd/parse.d
Expand Up @@ -5016,7 +5016,7 @@ final class Parser(AST) : Lexer
* Input:
* flags PSxxxx
* Output:
* pEndloc if { ... statements ... }, store location of closing brace, otherwise loc of first token of next statement
* pEndloc if { ... statements ... }, store location of closing brace, otherwise loc of last token of statement
*/
AST.Statement parseStatement(int flags, const(char)** endPtr = null, Loc* pEndloc = null)
{
Expand Down Expand Up @@ -6015,7 +6015,7 @@ final class Parser(AST) : Lexer
break;
}
if (pEndloc)
*pEndloc = token.loc;
*pEndloc = prevloc;
return s;
}

Expand Down

0 comments on commit 056160d

Please sign in to comment.