} else if (st != null && get_ccode_name (st) == "va_list") {
creation_call.add_argument (instance);
if (get_ccode_name (m) == "va_start") {
- if (in_creation_method) {
+ unowned Class? parent = current_method.parent_symbol as Class;
+ if (in_creation_method && parent != null && !parent.is_compact) {
creation_call = new CCodeFunctionCall (new CCodeIdentifier ("va_copy"));
creation_call.add_argument (instance);
creation_call.add_argument (new CCodeIdentifier ("_vala_va_list"));
* with _new in visit_creation_method).
*/
public override void visit_method (Method m) {
- string real_name = get_ccode_real_name (m);
- if (m is CreationMethod && m.is_variadic ()) {
- real_name = get_ccode_constructv_name ((CreationMethod) m);
- }
-
push_context (new EmitContext (m));
push_line (m.source_reference);
bool profile = m.get_attribute ("Profile") != null;
+ string real_name = get_ccode_real_name (m);
+
if (m is CreationMethod) {
- var cl = current_type_symbol as Class;
+ unowned Class? cl = m.parent_symbol as Class;
if (cl != null && !cl.is_compact) {
if (cl.base_class == null) {
in_fundamental_creation_method = true;
in_gobject_creation_method = true;
}
}
+ if (cl != null && !cl.is_compact && m.is_variadic ()) {
+ real_name = get_ccode_constructv_name ((CreationMethod) m);
+ }
}
var creturn_type = get_callable_creturn_type (m);
public override void visit_creation_method (CreationMethod m) {
push_line (m.source_reference);
- ellipses_to_valist = true;
+ unowned Class? cl = m.parent_symbol as Class;
+ if (cl != null && !cl.is_compact) {
+ ellipses_to_valist = true;
+ } else {
+ ellipses_to_valist = false;
+ }
visit_method (m);
ellipses_to_valist = false;
structs/struct-static-field-initializer.test \
structs/struct-static-property-initializer.test \
structs/structs.vala \
+ structs/constructor-variadic.vala \
structs/constructor-wrong-name.test \
structs/default-gtype.vala \
structs/gmutex.vala \
objects/compact-class-custom-ref.vala \
objects/constructor-abstract-public.test \
objects/constructor-inner-error.vala \
- objects/constructor-variadic.test \
+ objects/constructor-variadic.vala \
+ objects/constructor-variadic-invalid.test \
objects/constructor-wrong-name.test \
objects/constructors.vala \
objects/destructors.vala \
--- /dev/null
+class Foo {
+ public string s;
+
+ public Foo (string first_arg, ...) {
+ assert (first_arg == "foo");
+ va_list args = va_list ();
+ string second_arg = args.arg<string> ();
+ assert (second_arg == "bar");
+ s = first_arg + second_arg;
+ }
+}
+
+[Compact]
+class Bar {
+ public string s;
+
+ public Bar (string first_arg, ...) {
+ assert (first_arg == "bar");
+ va_list args = va_list ();
+ string second_arg = args.arg<string> ();
+ assert (second_arg == "foo");
+ s = first_arg + second_arg;
+ }
+}
+
+void main () {
+ {
+ var foo = new Foo ("foo", "bar");
+ assert (foo.s == "foobar");
+ }
+ {
+ var bar = new Bar ("bar", "foo");
+ assert (bar.s == "barfoo");
+ }
+}
--- /dev/null
+struct Foo {
+ public string s;
+
+ public Foo (string first_arg, ...) {
+ assert (first_arg == "foo");
+ va_list args = va_list ();
+ string second_arg = args.arg<string> ();
+ assert (second_arg == "bar");
+ s = first_arg + second_arg;
+ }
+}
+
+void main () {
+ {
+ var foo = Foo ("foo", "bar");
+ assert (foo.s == "foobar");
+ }
+}