]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Fix signature of array_contains for inline arrays
authorDaiki Ueno <ueno@unixuser.org>
Thu, 15 Mar 2012 04:01:03 +0000 (13:01 +0900)
committerJürg Billeter <j@bitron.ch>
Wed, 1 Aug 2012 19:11:59 +0000 (21:11 +0200)
Fixes bug 672116.

codegen/valaccodebasemodule.vala
tests/basic-types/arrays.vala

index 3b1b2ee6ff6f2497aaba0a886422aceceb0a8388..9a82e5d3f6e8a9985a373c93d5110bcbac5bee31 100644 (file)
@@ -5292,7 +5292,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                var function = new CCodeFunction (array_contains_func, "gboolean");
                function.modifiers = CCodeModifiers.STATIC;
 
-               function.add_parameter (new CCodeParameter ("stack", get_ccode_name (array_type)));
+               function.add_parameter (new CCodeParameter ("stack", "%s*".printf (get_ccode_name (array_type.element_type))));
                function.add_parameter (new CCodeParameter ("stack_length", "int"));
                if (array_type.element_type is StructValueType) {
                        function.add_parameter (new CCodeParameter ("needle", get_ccode_name (array_type.element_type) + "*"));
index 5d4d0c4f93cd0478578c8a1f8999a211e4e4259f..be0ca236f0c4beffe6fdcffd02708828d17359ca 100644 (file)
@@ -107,6 +107,11 @@ void test_length_assignment () {
        assert (b.length[0] == 5);
 }
 
+void test_inline_array () {
+       const int a[] = { 1, 2, 3 };
+       assert (1 in a);
+}
+
 void main () {
        test_integer_array ();
        test_string_array ();
@@ -114,5 +119,6 @@ void main () {
        test_static_array ();
        test_reference_transfer ();
        test_length_assignment ();
+       test_inline_array ();
 }