for (int dim = 1; dim <= array_type.rank; dim++) {
cdecl = new CCodeDeclaration (length_ctype);
- cdecl.add_declarator (new CCodeVariableDeclarator (get_array_length_cname (get_ccode_name (f), dim)));
+ cdecl.add_declarator (new CCodeVariableDeclarator (get_variable_array_length_cname (f, dim)));
if (f.is_private_symbol ()) {
cdecl.modifiers = CCodeModifiers.STATIC;
} else if (context.hide_internal && f.is_internal_symbol ()) {
for (int dim = 1; dim <= array_type.rank; dim++) {
var len_def = new CCodeDeclaration (length_ctype);
- len_def.add_declarator (new CCodeVariableDeclarator (get_array_length_cname (get_ccode_name (f), dim), new CCodeConstant ("0")));
+ len_def.add_declarator (new CCodeVariableDeclarator (get_variable_array_length_cname (f, dim), new CCodeConstant ("0")));
if (!f.is_private_symbol ()) {
len_def.modifiers = CCodeModifiers.EXTERN;
} else {
basic-types/bug777697.test \
basic-types/bug787152.vala \
basic-types/bug788775.vala \
+ arrays/class-field-length-cname.vala \
+ arrays/field-global-length-cname.vala \
+ arrays/struct-field-length-cname.vala \
chainup/base-class-invalid.test \
chainup/base-enum-invalid.test \
chainup/base-invalid.test \
--- /dev/null
+class Bar {
+ [CCode (array_length_cname = "foo_len")]
+ public int[] foo;
+
+ // would cause a symbol clash
+ public int foo_length1;
+}
+
+void main () {
+ var bar = new Bar ();
+ bar.foo = { 23, 42 };
+ assert (bar.foo.length == 2);
+}
--- /dev/null
+[CCode (array_length_cname = "foo_len")]
+public int[] foo;
+
+// would cause a symbol clash
+int foo_length1;
+
+void main () {
+ foo = { 23, 42 };
+ assert (foo.length == 2);
+}
--- /dev/null
+struct Bar {
+ [CCode (array_length_cname = "foo_len")]
+ public int[] foo;
+
+ // would cause a symbol clash
+ public int foo_length1;
+}
+
+void main () {
+ Bar bar = {{ 23, 42 }, -1};
+ assert (bar.foo.length == 2);
+}