widl: Dereference operator in expr works on any declared pointer.

This commit is contained in:
Michael Karcher 2009-01-11 15:00:18 +01:00 committed by Alexandre Julliard
parent f80e4aa9d2
commit 1c56d293f0
3 changed files with 27 additions and 0 deletions

View File

@ -226,6 +226,23 @@ s_sum_conf_array(int x[], int n)
return sum;
}
int
s_sum_conf_ptr_by_conf_ptr(int n1, int *n2_then_x1, int *x2)
{
int i;
int sum = 0;
if(n1 == 0)
return 0;
for(i = 1; i < n1; ++i)
sum += n2_then_x1[i];
for(i = 0; i < *n2_then_x1; ++i)
sum += x2[i];
return sum;
}
int
s_sum_unique_conf_array(int x[], int n)
{
@ -1127,6 +1144,7 @@ array_tests(void)
{{1, -2, 3, -4}, {2, 3, 5, 7}, {-4, -1, -14, 4114}}
};
int c[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
int c2[] = {10, 100, 200};
vector_t vs[2] = {{1, -2, 3}, {4, -5, -6}};
cps_t cps;
cpsc_t cpsc;
@ -1147,6 +1165,11 @@ array_tests(void)
ok(sum_conf_array(&c[7], 1) == 7, "RPC sum_conf_array\n");
ok(sum_conf_array(&c[2], 0) == 0, "RPC sum_conf_array\n");
ok(sum_conf_ptr_by_conf_ptr(1, c2, c) == 45, "RPC sum_conf_ptr_by_conf_ptr");
ok(sum_conf_ptr_by_conf_ptr(3, c2, c) == 345, "RPC sum_conf_ptr_by_conf_ptr");
c2[0] = 0;
ok(sum_conf_ptr_by_conf_ptr(3, c2, c) == 300, "RPC sum_conf_ptr_by_conf_ptr");
ok(sum_unique_conf_array(ca, 4) == -2, "RPC sum_unique_conf_array\n");
ok(sum_unique_conf_ptr(ca, 5) == 3, "RPC sum_unique_conf_array\n");
ok(sum_unique_conf_ptr(NULL, 10) == 0, "RPC sum_unique_conf_array\n");

View File

@ -121,6 +121,7 @@ cpp_quote("#endif")
int test_list_length(test_list_t *ls);
int sum_fixed_int_3d(int m[2][3][4]);
int sum_conf_array([size_is(n)] int x[], int n);
int sum_conf_ptr_by_conf_ptr(int n1, [size_is(n1)] int *n2_then_x1, [size_is(*n2_then_x1)] int *x2);
int sum_unique_conf_array([size_is(n), unique] int x[], int n);
int sum_unique_conf_ptr([size_is(n), unique] int *x, int n);
int sum_var_array([length_is(n)] int x[20], int n);

View File

@ -470,6 +470,9 @@ static struct expression_type resolve_expression(const struct expr_loc *expr_loc
result = resolve_expression(expr_loc, cont_type, e->ref);
if (result.type && is_ptr(result.type))
result.type = type_pointer_get_ref(result.type);
else if(result.type && is_array(result.type)
&& !result.type->declarray)
result.type = type_array_get_element(result.type);
else
error_loc_info(&expr_loc->v->loc_info, "dereference operator applied to non-pointer type in expression%s%s\n",
expr_loc->attr ? " for attribute " : "",