Skip to content

Commit dcf88c5

Browse files
committed
parser: Remove unnecessary NULL checks above cStrIdxOrMemberDeref() calls
Now that cStrIdxOrMemberDeref() checks for NULL itself (85d8362), callers don't need to do it anymore.
1 parent 48c8947 commit dcf88c5

File tree

1 file changed

+7
-26
lines changed

1 file changed

+7
-26
lines changed

src/compiler/parser-expr-unary.bas

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -222,18 +222,12 @@ function cHighestPrecExpr _
222222
'' DerefExpr
223223
case FB_TK_DEREFCHAR
224224
expr = cDerefExpression( )
225-
if( expr = NULL ) then
226-
return NULL
227-
end if
228225

229226
'' ParentExpression
230227
case CHAR_LPRNT
231228
dim as integer is_opt = fbGetPrntOptional( )
232229

233230
expr = cParentExpression( )
234-
if( expr = NULL ) then
235-
return NULL
236-
end if
237231

238232
'' if parsing a SUB, don't call StrIdxOrMemberDeref() twice
239233
if( is_opt ) then
@@ -253,26 +247,17 @@ function cHighestPrecExpr _
253247
lexSkipToken( )
254248

255249
expr = hCast( 0 )
256-
if( expr = NULL ) then
257-
return NULL
258-
end if
259250

260251
'' CPTR '(' DataType ',' Expression{int|uint|ptr} ')'
261252
case FB_TK_CPTR
262253
'' CPTR
263254
lexSkipToken( )
264255

265256
expr = hCast( AST_CONVOPT_PTRONLY )
266-
if( expr = NULL ) then
267-
return NULL
268-
end if
269257

270258
'' OperatorNew
271259
case FB_TK_NEW
272260
expr = cOperatorNew( )
273-
if( expr = NULL ) then
274-
return NULL
275-
end if
276261

277262
'' Atom
278263
case else
@@ -705,15 +690,11 @@ function cAddrOfExpression( ) as ASTNODE ptr
705690

706691
end select
707692

708-
if( expr ) then
709-
'' Allow indexing on VARPTR()/STRPTR()/etc. directly, they look
710-
'' like functions so this isn't ambigious, while for @ it would
711-
'' mess up the operator precedence:
712-
'' @expr[i] should be @(expr[i]), not (@expr)[i]
713-
'' but for
714-
'' varptr(expr)[i], that problem doesn't exist.
715-
expr = cStrIdxOrMemberDeref( expr )
716-
end if
717-
718-
function = expr
693+
'' Allow indexing on VARPTR()/STRPTR()/etc. directly, they look
694+
'' like functions so this isn't ambigious, while for @ it would
695+
'' mess up the operator precedence:
696+
'' @expr[i] should be @(expr[i]), not (@expr)[i]
697+
'' but for
698+
'' varptr(expr)[i], that problem doesn't exist.
699+
function = cStrIdxOrMemberDeref( expr )
719700
end function

0 commit comments

Comments
 (0)