]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Fix va_start argument in methods throwing errors
authorJürg Billeter <j@bitron.ch>
Wed, 1 Aug 2012 09:39:40 +0000 (11:39 +0200)
committerJürg Billeter <j@bitron.ch>
Wed, 1 Aug 2012 09:39:40 +0000 (11:39 +0200)
Fixes bug 620673.

ccode/valaccodefunction.vala
codegen/valaccodebasemodule.vala

index ddbc8121ebe58d701d3914f02f0846438f574201..d54215b133591dff804147f927f198514ac00140 100644 (file)
@@ -1,6 +1,6 @@
 /* valaccodefunction.vala
  *
- * Copyright (C) 2006-2010  Jürg Billeter
+ * Copyright (C) 2006-2012  Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -80,6 +80,14 @@ public class Vala.CCodeFunction : CCodeNode {
                parameters.insert (position, param);
        }
 
+       public int get_parameter_count () {
+               return parameters.size;
+       }
+
+       public CCodeParameter get_parameter (int position) {
+               return parameters[position];
+       }
+
        /**
         * Returns a copy of this function.
         *
index 4762f574df32e96326b898ab048d0858142660bb..ba30e4f1bc249316b86a8617bf333a845ead09e1 100644 (file)
@@ -1,6 +1,6 @@
 /* valaccodebasemodule.vala
  *
- * Copyright (C) 2006-2011  Jürg Billeter
+ * Copyright (C) 2006-2012  Jürg Billeter
  * Copyright (C) 2006-2008  Raffaele Sandrini
  *
  * This library is free software; you can redistribute it and/or
@@ -4377,7 +4377,14 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                                                        }
                                                        last_param = param;
                                                }
-                                               creation_call.add_argument (new CCodeIdentifier (get_variable_cname (last_param.name)));
+                                               int nParams = ccode.get_parameter_count ();
+                                               if (nParams == 0 || !ccode.get_parameter (nParams - 1).ellipsis) {
+                                                       Report.error (expr.source_reference, "`va_list' used in method with fixed args");
+                                               } else if (nParams == 1) {
+                                                       Report.error (expr.source_reference, "`va_list' used in method without parameter");
+                                               } else {
+                                                       creation_call.add_argument (new CCodeIdentifier (ccode.get_parameter (nParams - 2).name));
+                                               }
                                        }
                                }
                        }