summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBen Smith <binjimin@gmail.com>2018-10-30 16:19:26 -0700
committerGitHub <noreply@github.com>2018-10-30 16:19:26 -0700
commit39ceee53a9cd23451a28d4e56e151ef76044b5df (patch)
tree6e66cd1c5cc6bb3729a93685e450181fefbb2897 /src
parentbba180a8c1ea170341e8479ba6ceebeb7b97cf73 (diff)
downloadwabt-39ceee53a9cd23451a28d4e56e151ef76044b5df.tar.gz
wabt-39ceee53a9cd23451a28d4e56e151ef76044b5df.tar.bz2
wabt-39ceee53a9cd23451a28d4e56e151ef76044b5df.zip
Set `end_loc` in folded `if` expressions (#940)
Without this fix, some validation errors will not display the location properly.
Diffstat (limited to 'src')
-rw-r--r--src/wast-parser.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/wast-parser.cc b/src/wast-parser.cc
index 2697fab4..7b3b6e48 100644
--- a/src/wast-parser.cc
+++ b/src/wast-parser.cc
@@ -2006,6 +2006,7 @@ Result WastParser::ParseExpr(ExprList* exprs) {
if (MatchLpar(TokenType::Then)) {
CHECK_RESULT(ParseTerminatingInstrList(&expr->true_.exprs));
+ expr->true_.end_loc = GetLocation();
EXPECT(Rpar);
if (MatchLpar(TokenType::Else)) {
@@ -2014,10 +2015,13 @@ Result WastParser::ParseExpr(ExprList* exprs) {
} else if (PeekMatchExpr()) {
CHECK_RESULT(ParseExpr(&expr->false_));
}
+ expr->false_end_loc = GetLocation();
} else if (PeekMatchExpr()) {
CHECK_RESULT(ParseExpr(&expr->true_.exprs));
+ expr->true_.end_loc = GetLocation();
if (PeekMatchExpr()) {
CHECK_RESULT(ParseExpr(&expr->false_));
+ expr->false_end_loc = GetLocation();
}
} else {
ConsumeIfLpar();
@@ -2043,6 +2047,7 @@ Result WastParser::ParseExpr(ExprList* exprs) {
if (MatchLpar(TokenType::Then)) {
CHECK_RESULT(ParseTerminatingInstrList(&expr->true_.exprs));
+ expr->true_.end_loc = GetLocation();
EXPECT(Rpar);
if (MatchLpar(TokenType::Else)) {
@@ -2051,10 +2056,13 @@ Result WastParser::ParseExpr(ExprList* exprs) {
} else if (PeekMatchExpr()) {
CHECK_RESULT(ParseExpr(&expr->false_));
}
+ expr->false_end_loc = GetLocation();
} else if (PeekMatchExpr()) {
CHECK_RESULT(ParseExpr(&expr->true_.exprs));
+ expr->true_.end_loc = GetLocation();
if (PeekMatchExpr()) {
CHECK_RESULT(ParseExpr(&expr->false_));
+ expr->false_end_loc = GetLocation();
}
} else {
ConsumeIfLpar();