Browse Source

* take "varags" into account when checking for the correct number of
formal parameters of an Objective-C method

git-svn-id: trunk@15430 -

Jonas Maebe 15 years ago
parent
commit
8c1a63fb80
3 changed files with 18 additions and 0 deletions
  1. 1 0
      .gitattributes
  2. 2 0
      compiler/symdef.pas
  3. 15 0
      tests/test/tobjc16a.pp

+ 1 - 0
.gitattributes

@@ -9266,6 +9266,7 @@ tests/test/tobjc13b.pp svneol=native#text/plain
 tests/test/tobjc14.pp svneol=native#text/plain
 tests/test/tobjc14.pp svneol=native#text/plain
 tests/test/tobjc15.pp svneol=native#text/plain
 tests/test/tobjc15.pp svneol=native#text/plain
 tests/test/tobjc16.pp svneol=native#text/plain
 tests/test/tobjc16.pp svneol=native#text/plain
+tests/test/tobjc16a.pp svneol=native#text/plain
 tests/test/tobjc17.pp svneol=native#text/plain
 tests/test/tobjc17.pp svneol=native#text/plain
 tests/test/tobjc18.pp svneol=native#text/plain
 tests/test/tobjc18.pp svneol=native#text/plain
 tests/test/tobjc19.pp svneol=native#text/plain
 tests/test/tobjc19.pp svneol=native#text/plain

+ 2 - 0
compiler/symdef.pas

@@ -4848,6 +4848,8 @@ implementation
                   if not(vo_is_hidden_para in tparavarsym(pd.paras[i]).varoptions) and
                   if not(vo_is_hidden_para in tparavarsym(pd.paras[i]).varoptions) and
                      not is_array_of_const(tparavarsym(pd.paras[i]).vardef) then
                      not is_array_of_const(tparavarsym(pd.paras[i]).vardef) then
                     dec(paracount);
                     dec(paracount);
+                { varargs parameter }
+                dec(paracount,ord(po_varargs in tprocdef(def).procoptions));
                 if (paracount<>0) then
                 if (paracount<>0) then
                   MessagePos(pd.fileinfo,sym_e_objc_para_mismatch);
                   MessagePos(pd.fileinfo,sym_e_objc_para_mismatch);
 
 

+ 15 - 0
tests/test/tobjc16a.pp

@@ -0,0 +1,15 @@
+{ %norun }
+{ %target=darwin }
+{ %cpu=powerpc,powerpc64,i386,x86_64,arm }
+
+{ Written by Jonas Maebe in 2010, released into the public domain }
+
+{$modeswitch objectivec1}
+
+type
+  ta = objcclass
+    procedure test(a: longint); varargs; message 'test:a:';
+  end; external name 'NSObject';
+
+begin
+end.