2008-02-03 Raffaele Sandrini <raffaele@sandrini.ch>
* tests/arrays.vala: extend the array test with an array of structs
declared through the "var" keyword
* vala/valasemanticanalyzer.vala: fix a memory management bug with
arrays of struct elements
svn path=/trunk/; revision=958
+2008-02-03 Raffaele Sandrini <raffaele@sandrini.ch>
+
+ * tests/arrays.vala: extend the array test with an array of structs
+ declared through the "var" keyword
+ * vala/valasemanticanalyzer.vala: fix a memory management bug with
+ arrays of struct elements
+
2008-02-03 Jürg Billeter <j@bitron.ch>
* vapigen/valagidlparser.vala: set requires_null_check for nullable
stdout.printf ("\n");
}
+ static void test_array_var_creation_with_structs () {
+ var ca = new char[16];
+ ca[5] = 'a';
+ assert (ca[5] == 'a');
+ }
+
static void test_array_creation_side_effects () {
int i = 5;
var arr = new int[i++];
test_element_access ();
test_array_length_of_array_constants ();
+
+ test_array_var_creation_with_structs ();
}
public static int inc () {
return;
}
+ /* arrays of struct type elements do not take ownership since they are copied into the array */
+ if (expr.element_type.data_type is Struct) {
+ expr.element_type.takes_ownership = false;
+ } else {
+ expr.element_type.takes_ownership = true;
+ }
+
expr.static_type = new ArrayType (expr.element_type, expr.rank);
expr.static_type.transfers_ownership = true;
expr.static_type.takes_ownership = true;
expr.static_type.add_type_argument (expr.element_type);
- expr.element_type.takes_ownership = true;
}
public override void visit_boolean_literal (BooleanLiteral! expr) {