Skip to content

Commit 94e13b6

Browse files
committed
ast-node-conv: Eliminate unnecessary pointer handling code
The SELECT CASE on both code paths won't be reached anymore in case the dtype they check respectively is a pointer.
1 parent afd78c4 commit 94e13b6

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/compiler/ast-node-conv.bas

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ function astCheckConvNonPtrToPtr _
115115
assert( typeIsPtr( to_dtype ) )
116116
assert( typeIsPtr( expr_dtype ) = FALSE )
117117

118-
select case as const typeGet( expr_dtype )
118+
select case as const( typeGetDtAndPtrOnly( expr_dtype ) )
119119
case FB_DATATYPE_INTEGER, FB_DATATYPE_UINT, FB_DATATYPE_ENUM, _
120120
FB_DATATYPE_LONG, FB_DATATYPE_ULONG, _
121121
FB_DATATYPE_LONGINT, FB_DATATYPE_ULONGINT
@@ -160,23 +160,17 @@ private function hCheckPtr _
160160

161161
'' from pointer? only allow integers of same size and pointers
162162
elseif( typeIsPtr( expr_dtype ) ) then
163-
select case as const typeGet( to_dtype )
163+
select case as const( typeGetDtAndPtrOnly( to_dtype ) )
164164
case FB_DATATYPE_INTEGER, FB_DATATYPE_UINT, FB_DATATYPE_ENUM, _
165165
FB_DATATYPE_LONG, FB_DATATYPE_ULONG, _
166166
FB_DATATYPE_LONGINT, FB_DATATYPE_ULONGINT
167167
'' Allow pointer-to-integer casts if same size
168168
if( typeGetSize( to_dtype ) = env.pointersize ) then
169169
exit function
170170
end if
171-
return hGetTypeMismatchErrMsg( options )
172-
173-
case FB_DATATYPE_POINTER
174-
'' Both are pointers, fall through to checks below
175-
176-
case else
177-
'' Nothing else allowed (strings, structs)
178-
return hGetTypeMismatchErrMsg( options )
179171
end select
172+
173+
return hGetTypeMismatchErrMsg( options )
180174
else
181175
'' No pointers at all, nothing to do
182176
exit function

0 commit comments

Comments
 (0)