Commit 0fcdda74 authored by Rico Tzschichholz's avatar Rico Tzschichholz

codegen: Emit struct declaration typedef before resolving its fields

This a regression when compiling a circular dependency of delegates with
structs.

Regression of 7adb3a45

See #318
parent 9a7c621d
......@@ -66,6 +66,12 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
}
}
if (st.base_struct == null) {
decl_space.add_type_declaration (new CCodeTypeDefinition ("struct _%s".printf (get_ccode_name (st)), new CCodeVariableDeclarator (get_ccode_name (st))));
} else {
decl_space.add_type_declaration (new CCodeTypeDefinition (get_ccode_name (st.base_struct), new CCodeVariableDeclarator (get_ccode_name (st))));
}
var instance_struct = new CCodeStruct ("_%s".printf (get_ccode_name (st)));
instance_struct.modifiers |= (st.version.deprecated ? CCodeModifiers.DEPRECATED : 0);
......@@ -109,11 +115,7 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
}
if (st.base_struct == null) {
decl_space.add_type_declaration (new CCodeTypeDefinition ("struct _%s".printf (get_ccode_name (st)), new CCodeVariableDeclarator (get_ccode_name (st))));
decl_space.add_type_definition (instance_struct);
} else {
decl_space.add_type_declaration (new CCodeTypeDefinition (get_ccode_name (st.base_struct), new CCodeVariableDeclarator (get_ccode_name (st))));
}
var function = new CCodeFunction (get_ccode_dup_function (st), get_ccode_name (st) + "*");
......
......@@ -538,6 +538,7 @@ TESTS = \
ordering/delegate-enum.vala \
ordering/delegate-interface.vala \
ordering/delegate-struct.vala \
ordering/struct-delegate.vala \
semantic/array-stacked.test \
semantic/array-incompatible-initializer.test \
semantic/array-incompatible-initializer2.test \
......
......@@ -2,7 +2,7 @@
delegate Foo Func (Foo p);
struct Foo {
public int i;
public Func f;
}
void main () {
......
public struct Foo {
public unowned Func func;
}
[CCode (has_target = false)]
public delegate int Func (Foo foo);
void main () {
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment