1 /* Testing conditional warnings (without headers). */
2 /* Author: David Ayers */
4 /* { dg-do compile } */
13 @interface MyProtoObject <MyProtocol>
18 main (int argc, char *argv[])
21 id <MyProtocol> var_id_p = nil;
22 MyObject *var_obj = nil;
23 MyProtoObject *var_obj_p = nil;
25 var_id = (var_id == var_obj) ? var_id : var_obj;
26 var_id = (var_id == var_obj) ? var_id : var_obj_p;
28 /* Ayers: Currently, the following test case passes for
29 technically the wrong reason (see below).
31 var_obj_p = (var_id == var_obj) ? var_obj_p : var_obj; /* { dg-warning "distinct Objective-C types" } */
32 var_obj_p = (var_id == var_obj) ? var_obj_p : var_id_p;
34 /* Ayers: The first of the following test cases
35 should probably warn for var_obj_p = var_obj,
36 yet that would require extensive changes to
37 build_conditional_expr to create a tree with
38 multiple types that the assignment would have
39 to evaluate both versions for correct diagnostics.
41 var_obj_p = (var_id == var_obj) ? var_id : var_obj;
42 var_obj_p = (var_id == var_obj) ? var_id : var_obj_p;