1 // { dg-options "-O1 -w -fpermissive" }
3 // Tests the fold bug described in PR 19650.
6 #define test(a) ((a) ? 1 : 0)
8 typedef int (*arg_cmp_func)();
13 enum Functype { UNKNOWN_FUNC, EQ_FUNC, EQUAL_FUNC };
14 virtual enum Functype functype() const { return UNKNOWN_FUNC; }
17 class Item_bool_func2 : public Item_func
20 virtual enum Functype functype() const { return EQUAL_FUNC; }
26 Item_bool_func2 *owner;
28 static arg_cmp_func comparator_matrix[4][2];
30 int Arg_comparator::set_compare_func(Item_bool_func2 *item, int type)
34 /****************** problematic line is here ************************/
36 func = comparator_matrix[type][test(owner->functype() == Item_func::EQUAL_FUNC)];
41 int compare_string() { return 0; }
42 int compare_e_string() { return 0; }
43 int compare_real() { return 0; }
44 int compare_e_real() { return 0; }
45 int compare_int_signed() { return 0; }
46 int compare_e_int() { return 0; }
47 int compare_row() { return 0; }
48 int compare_e_row() { return 0; }
50 arg_cmp_func Arg_comparator::comparator_matrix[4][2] =
51 {{&compare_string, &compare_e_string},
52 {&compare_real, &compare_e_real},
53 {&compare_int_signed, &compare_e_int},
54 {&compare_row, &compare_e_row}};
56 void myfunc (const char*p, arg_cmp_func f1, arg_cmp_func f2) __attribute__((noinline));
57 void myfunc (const char*p, arg_cmp_func f1, arg_cmp_func f2)
66 Item_bool_func2 equal_func;
68 cmp.set_compare_func(&equal_func, 0);
69 myfunc("cmp.func is %p (expected %p)\n", cmp.func, &compare_e_string);