]>
Commit | Line | Data |
---|---|---|
fcb6fced ML |
1 | // PR ipa/82352 |
2 | // { dg-do compile } | |
3 | // { dg-options "-O2" } | |
4 | ||
85e0b2c4 | 5 | typedef __SIZE_TYPE__ size_t; |
fcb6fced ML |
6 | |
7 | class A | |
8 | { | |
9 | public : | |
10 | typedef enum { Zero = 0, One = 1 } tA; | |
11 | A(tA a) { m_a = a; } | |
12 | ||
13 | private : | |
14 | tA m_a; | |
15 | }; | |
16 | ||
17 | class B | |
18 | { | |
19 | public : | |
50f3ac1b | 20 | void *operator new(size_t); |
fcb6fced ML |
21 | }; |
22 | ||
23 | class C | |
24 | { | |
25 | public: | |
26 | virtual void ffff () = 0; | |
27 | }; | |
28 | ||
29 | class D | |
30 | { | |
31 | public : | |
32 | virtual void g() = 0; | |
33 | virtual void h() = 0; | |
34 | }; | |
35 | ||
36 | template<class T> class IIII: public T, public D | |
37 | { | |
38 | public: | |
39 | void ffff() | |
40 | { | |
41 | if (!m_i2) throw A(A::One); | |
42 | }; | |
43 | ||
44 | void h() | |
45 | { | |
46 | if (m_i2) throw A(A::Zero); | |
47 | } | |
48 | ||
49 | protected: | |
50 | virtual void g() | |
51 | { | |
52 | if (m_i1 !=0) throw A(A::Zero); | |
53 | }; | |
54 | ||
55 | private : | |
56 | int m_i1; | |
57 | void *m_i2; | |
58 | }; | |
59 | ||
60 | class E | |
61 | { | |
62 | private: | |
63 | size_t m_e; | |
64 | static const size_t Max; | |
65 | ||
66 | public: | |
67 | E& i(size_t a, size_t b, size_t c) | |
68 | { | |
69 | if ((a > Max) || (c > Max)) throw A(A::Zero ); | |
70 | if (a + b > m_e) throw A(A::One ); | |
71 | return (*this); | |
72 | } | |
73 | ||
74 | inline E& j(const E &s) | |
75 | { | |
76 | return i(0,0,s.m_e); | |
77 | } | |
78 | }; | |
79 | ||
80 | class F : public C { }; | |
81 | class G : public C { }; | |
82 | class HHHH : public B, public F, public G { }; | |
83 | ||
84 | void k() | |
85 | { | |
86 | new IIII<HHHH>(); | |
87 | } | |
88 | ||
89 | void l() | |
90 | { | |
91 | E e1, e2; | |
92 | e1.j(e2); | |
93 | } |