Skip to content

Commit

Permalink
Fix spcomp assertion on malformed if (#297)
Browse files Browse the repository at this point in the history
  • Loading branch information
dvander committed Dec 20, 2018
1 parent cf511f1 commit d890d13
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion compiler/expressions.cpp
Expand Up @@ -1054,7 +1054,8 @@ SC3ExpressionParser::hier14(value *lval1)
/* array assignment is permitted too (with restrictions) */
if (oper)
return error(23); /* array assignment must be simple assigment */
assert(lval1->sym!=NULL);
if (!lval1->sym)
return error(142);
if (array_totalsize(lval1->sym)==0)
return error(46,lval1->sym->name()); /* unknown array size */
lvalue=TRUE;
Expand Down
2 changes: 1 addition & 1 deletion compiler/messages.h
Expand Up @@ -166,7 +166,7 @@ static const char *errmsg[] = {
/*139*/ "could not find type \"%s\"\n",
/*140*/ "new-style array types cannot specify dimension sizes as part of their type\n",
/*141*/ "natives, forwards, and public functions cannot return arrays\n",
/*142*/ "unused142\n",
/*142*/ "unexpected array expression\n",
/*143*/ "new-style declarations should not have \"new\"\n",
/*144*/ "void cannot be used as a variable type\n",
/*145*/ "invalid type expression\n",
Expand Down
6 changes: 6 additions & 0 deletions tests/compile-only/fail-broken-if-conditional.sp
@@ -0,0 +1,6 @@
int main() {
if (
{
int b = c();
}
}
1 change: 1 addition & 0 deletions tests/compile-only/fail-broken-if-conditional.txt
@@ -0,0 +1 @@
(6) : error 054: unmatched closing brace ("}")

0 comments on commit d890d13

Please sign in to comment.