[vala] codegen: Fix va_start argument in methods throwing errors



commit 3cda0bdebb78d57b357ca784265cea3dd810d7f7
Author: JÃrg Billeter <j bitron ch>
Date:   Wed Aug 1 11:39:40 2012 +0200

    codegen: Fix va_start argument in methods throwing errors
    
    Fixes bug 620673.

 ccode/valaccodefunction.vala     |   10 +++++++++-
 codegen/valaccodebasemodule.vala |   11 +++++++++--
 2 files changed, 18 insertions(+), 3 deletions(-)
---
diff --git a/ccode/valaccodefunction.vala b/ccode/valaccodefunction.vala
index ddbc812..d54215b 100644
--- a/ccode/valaccodefunction.vala
+++ b/ccode/valaccodefunction.vala
@@ -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.
 	 *
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 4762f57..ba30e4f 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -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));
+						}
 					}
 				}
 			}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]