mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-21 18:09:30 +02:00
* give an error if the number of formal parameters of an obj-c method
does not match the number of colons in the message name git-svn-id: branches/objc@13668 -
This commit is contained in:
parent
fc40e1fe5b
commit
bcfcf30e04
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -8223,6 +8223,7 @@ tests/test/tobjc12.pp svneol=native#text/plain
|
||||
tests/test/tobjc13.pp svneol=native#text/plain
|
||||
tests/test/tobjc14.pp svneol=native#text/plain
|
||||
tests/test/tobjc15.pp svneol=native#text/plain
|
||||
tests/test/tobjc16.pp svneol=native#text/plain
|
||||
tests/test/tobjc2.pp svneol=native#text/plain
|
||||
tests/test/tobjc3.pp svneol=native#text/plain
|
||||
tests/test/tobjc4.pp svneol=native#text/plain
|
||||
|
@ -4385,7 +4385,8 @@ implementation
|
||||
var
|
||||
def: tdef absolute data;
|
||||
pd: tprocdef absolute data;
|
||||
i: longint;
|
||||
i,
|
||||
paracount: longint;
|
||||
begin
|
||||
if (def.typ=procdef) then
|
||||
begin
|
||||
@ -4397,7 +4398,21 @@ implementation
|
||||
{ Mangled name is already set in case this is a copy of
|
||||
another type. }
|
||||
if not(po_has_mangledname in pd.procoptions) then
|
||||
pd.setmangledname(pd.objcmangledname)
|
||||
begin
|
||||
{ check whether the number of formal parameters is correct }
|
||||
paracount:=0;
|
||||
for i:=1 to length(pd.messageinf.str^) do
|
||||
if pd.messageinf.str^[i]=':' then
|
||||
inc(paracount);
|
||||
for i:=0 to pd.paras.count-1 do
|
||||
if not(vo_is_hidden_para in tparavarsym(pd.paras[i]).varoptions) and
|
||||
not is_array_of_const(tparavarsym(pd.paras[i]).vardef) then
|
||||
dec(paracount);
|
||||
if (paracount<>0) then
|
||||
MessagePos(pd.fileinfo,sym_e_objc_para_mismatch);
|
||||
|
||||
pd.setmangledname(pd.objcmangledname);
|
||||
end
|
||||
else
|
||||
{ all checks already done }
|
||||
exit;
|
||||
|
28
tests/test/tobjc16.pp
Normal file
28
tests/test/tobjc16.pp
Normal file
@ -0,0 +1,28 @@
|
||||
{ %fail }
|
||||
{ %opt=-vh -Seh }
|
||||
{ %target=darwin }
|
||||
{ %cpu=powerpc,i386 }
|
||||
|
||||
{$modeswitch objectivec1}
|
||||
|
||||
type
|
||||
ta = objcclass
|
||||
{ should give an error about a wrong number of parameters --
|
||||
the message name suggests two parameters, but the procedure
|
||||
has only one. }
|
||||
procedure test(a: longint); message 'test:a:';
|
||||
end; external;
|
||||
|
||||
var
|
||||
a: ta;
|
||||
b: nsobject;
|
||||
c: id;
|
||||
begin
|
||||
{ avoid hints about unused types/variables/units }
|
||||
a:=nil;
|
||||
if (a<>nil) then
|
||||
exit;
|
||||
c:=nil;
|
||||
b:=c;
|
||||
b.isEqual_(b);
|
||||
end.
|
Loading…
Reference in New Issue
Block a user