mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-08 02:07:53 +02:00
* prevent warning for val with second parameter not being a longint
git-svn-id: trunk@1463 -
This commit is contained in:
parent
a357bef5e5
commit
5abb9d68f6
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -6273,6 +6273,7 @@ tests/webtbs/tw3971.pp svneol=native#text/plain
|
||||
tests/webtbs/tw3973.pp svneol=native#text/plain
|
||||
tests/webtbs/tw3977.pp svneol=native#text/plain
|
||||
tests/webtbs/tw3977.txt svneol=native#text/plain
|
||||
tests/webtbs/tw4006.pp svneol=native#text/plain
|
||||
tests/webtbs/tw4007.pp svneol=native#text/plain
|
||||
tests/webtbs/tw4009.pp svneol=native#text/plain
|
||||
tests/webtbs/tw4010.pp svneol=native#text/plain
|
||||
|
@ -1037,11 +1037,13 @@ implementation
|
||||
{ its right field is nil }
|
||||
sourcepara.right := sizepara;
|
||||
|
||||
{ create the call and assign the result to dest }
|
||||
{ (val helpers are functions) }
|
||||
{ the assignment will take care of rangechecking }
|
||||
{ create the call and assign the result to dest (val helpers are functions).
|
||||
Use a trick to prevent a type size mismatch warning to be generated by the
|
||||
assignment node. First convert implicitly to the resulttype. This will insert
|
||||
the range check. The Second conversion is done explicitly to hide the implicit conversion
|
||||
for the assignment node and therefor preventing the warning (PFV) }
|
||||
addstatement(newstatement,cassignmentnode.create(
|
||||
destpara.left,ccallnode.createintern(procname,newparas)));
|
||||
destpara.left,ctypeconvnode.create_internal(ctypeconvnode.create(ccallnode.createintern(procname,newparas),destpara.left.resulttype),destpara.left.resulttype)));
|
||||
|
||||
{ dispose of the enclosing paranode of the destination }
|
||||
destpara.left := nil;
|
||||
|
61
tests/webtbs/tw4006.pp
Executable file
61
tests/webtbs/tw4006.pp
Executable file
@ -0,0 +1,61 @@
|
||||
{ %opt=-Sew }
|
||||
|
||||
{ Source provided for Free Pascal Bug Report 4006 }
|
||||
{ Submitted by "Torsten Kildal" on 2005-05-23 }
|
||||
{ e-mail: kildal@mx }
|
||||
program Val_Test;
|
||||
{$IFDEF FPC}
|
||||
{$MODE TP} {BP/TP compatible}
|
||||
{$H-} {short strings!}
|
||||
{$ENDIF}
|
||||
|
||||
{$R+}
|
||||
|
||||
VAR
|
||||
s : string;
|
||||
iVar : smallint;
|
||||
lVar : longint; { BP7 = Borland Pascal }
|
||||
rVar : real; { 1010 = FPC 1.0.10 }
|
||||
iCode : integer; { 196 = FPC 1.9.6 }
|
||||
wCode : word; { 200 = FPC 2.0.0 }
|
||||
|
||||
begin
|
||||
s:='3.14'; {content plays no roll}
|
||||
|
||||
VAL(s,iVar,iCode);
|
||||
{BP7 : ok}
|
||||
{1010: ok}
|
||||
{196 : Warning: Type size mismatch, possible loss of data / range check error}
|
||||
{200 : Warning: Type size mismatch, possible loss of data / range check error}
|
||||
|
||||
VAL(s,lVar,iCode);
|
||||
{BP7 : ok}
|
||||
{1010: ok}
|
||||
{196 : ok}
|
||||
{200 : ok}
|
||||
|
||||
VAL(s,rVar,iCode);
|
||||
{BP7 : ok}
|
||||
{1010: ok}
|
||||
{196 : Warning: Type size mismatch, possible loss of data / range check error}
|
||||
{200 : Warning: Type size mismatch, possible loss of data / range check error}
|
||||
(*
|
||||
VAL(s,iVar,wCode);
|
||||
{BP7 : ok}
|
||||
{1010: ok}
|
||||
{196 : Warning: Type size mismatch, possible loss of data / range check error}
|
||||
{200 : Warning: Type size mismatch, possible loss of data / range check error}
|
||||
|
||||
VAL(s,lVar,wCode);
|
||||
{BP7 : ok}
|
||||
{1010: ok}
|
||||
{196 : ok}
|
||||
{200 : ok}
|
||||
|
||||
VAL(s,rVar,wCode);
|
||||
{BP7 : ok}
|
||||
{1010: ok}
|
||||
{196 : Warning: Type size mismatch, possible loss of data / range check error}
|
||||
{200 : Warning: Type size mismatch, possible loss of data / range check error}
|
||||
*)
|
||||
end.
|
Loading…
Reference in New Issue
Block a user