OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [opt/] [pr19650.C] - Blame information for rev 774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 693 jeremybenn
// { dg-options "-O1 -w -fpermissive" }
2
// { dg-do run }
3
// Tests the fold bug described in PR 19650.
4
#include 
5
#include 
6
#define test(a) ((a) ? 1 : 0)
7
 
8
typedef int (*arg_cmp_func)();
9
 
10
class Item_func
11
{
12
public:
13
    enum Functype { UNKNOWN_FUNC, EQ_FUNC, EQUAL_FUNC };
14
    virtual enum Functype functype() const { return UNKNOWN_FUNC; }
15
};
16
 
17
class Item_bool_func2 : public Item_func
18
{
19
public:
20
    virtual enum Functype functype() const { return EQUAL_FUNC; }
21
};
22
 
23
class Arg_comparator
24
{
25
public:
26
    Item_bool_func2 *owner;
27
    arg_cmp_func func;
28
    static arg_cmp_func comparator_matrix[4][2];
29
 
30
    int Arg_comparator::set_compare_func(Item_bool_func2 *item, int type)
31
    {
32
        owner = item;
33
 
34
        /****************** problematic line is here ************************/
35
 
36
        func = comparator_matrix[type][test(owner->functype() == Item_func::EQUAL_FUNC)];
37
        return 0;
38
    }
39
};
40
 
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; }
49
 
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}};
55
 
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)
58
{
59
    if (f1!=f2)
60
      abort ();
61
}
62
 
63
int main()
64
{
65
    Arg_comparator cmp;
66
    Item_bool_func2 equal_func;
67
 
68
    cmp.set_compare_func(&equal_func, 0);
69
    myfunc("cmp.func is %p (expected %p)\n", cmp.func, &compare_e_string);
70
}
71
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.