Skip to content

Commit

Permalink
parser: Don't abort when warning about mismatching parameter initiali…
Browse files Browse the repository at this point in the history
…zers

Since the "mismatching parameter initializers" warning was added in
301962f, it also caused hCheckPrototype() to abort, which caused
cProcHeader() to do "return CREATEFAKE( )" which it normally only does
for error recovery.

1. This should just be warning though, not an error.
2. The symbol created by CREATEFAKE() is not completely the same as what
would be produced in the absence of errors; for example it will use a
temporary identifier instead of the original. Because of this, the newly
added "warning" could even cause procedure bodies to be emitted under an
incorrect name, resulting in linker errors.
  • Loading branch information
dkl committed Aug 2, 2014
1 parent e032f71 commit e8ebd75
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/compiler/parser-proc.bas
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ private function hCheckPrototype _
if( symbGetIsOptional( proto_param ) and symbGetIsOptional( param ) ) then
if( astIsEqualParamInit( proto_param->param.optexpr, param->param.optexpr ) = FALSE ) then
errReportParamWarn( proc, i, NULL, FB_WARNINGMSG_MISMATCHINGPARAMINIT )
exit function
end if
end if

Expand Down
14 changes: 14 additions & 0 deletions tests/functions/paraminit-mismatch-warning-1.bas
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
' TEST_MODE : COMPILE_AND_RUN_OK

'' This should just show the "parameter initializer mismatch" warning, but not
'' cause any errors.

type UDT
i as integer
declare sub s(byval i0 as integer = 0)
end type

sub UDT.s(byval i0 as integer = 1)
i = i0
this.i = i0
end sub
11 changes: 11 additions & 0 deletions tests/functions/paraminit-mismatch-warning-2.bas
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
' TEST_MODE : COMPILE_AND_RUN_OK

'' This should just show the "parameter initializer mismatch" warning, but not
'' cause any compiler/linker errors.

declare sub f(byval i as integer = 0)

sub f(byval i as integer = 1)
end sub

f()
14 changes: 14 additions & 0 deletions tests/warnings/paraminit-method.bas
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'' This should just show the "parameter initializer mismatch" warning, but not
'' cause any errors.

#print "1 warning:"

type UDT
i as integer
declare sub s(byval i0 as integer = 0)
end type

sub UDT.s(byval i0 as integer = 1)
i = i0
this.i = i0
end sub
2 changes: 2 additions & 0 deletions tests/warnings/paraminit-method.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1 warning:
Mismatching parameter initializer, at parameter 1 (i0) of s()

0 comments on commit e8ebd75

Please sign in to comment.