| 1 |
// { dg-do compile } |
| 2 |
// { dg-options "-finline-small-functions -findirect-inlining -finline-functions -O" } |
| 3 |
typedef struct |
| 4 |
{} __mpf_struct; |
| 5 |
typedef __mpf_struct mpf_t[1]; |
| 6 |
typedef const __mpf_struct *mpf_srcptr; |
| 7 |
typedef __mpf_struct *mpf_ptr; |
| 8 |
extern "C" { |
| 9 |
void __gmpf_add (mpf_ptr, mpf_srcptr, mpf_srcptr); |
| 10 |
} |
| 11 |
class _knumber |
| 12 |
{ |
| 13 |
public: |
| 14 |
enum NumType {SpecialType, IntegerType, FractionType, FloatType}; |
| 15 |
virtual NumType type(void) const = 0; |
| 16 |
virtual _knumber * add(_knumber const & arg2) const = 0; |
| 17 |
virtual operator long int(void) const = 0; |
| 18 |
}; |
| 19 |
class _knumfloat : public _knumber |
| 20 |
{ |
| 21 |
_knumfloat(double num = 1.0) |
| 22 |
; |
| 23 |
virtual NumType type(void) const ; |
| 24 |
virtual _knumber * add(_knumber const & arg2) const; |
| 25 |
virtual operator long int (void) const; |
| 26 |
mpf_t _mpf; |
| 27 |
}; |
| 28 |
_knumber *_knumfloat::add(_knumber const & arg2) const |
| 29 |
{ |
| 30 |
if (arg2.type() == SpecialType) |
| 31 |
return arg2.add(*this); |
| 32 |
{ |
| 33 |
_knumfloat tmp_num(arg2); |
| 34 |
return tmp_num.add(*this); |
| 35 |
} |
| 36 |
_knumfloat * tmp_num = new _knumfloat(); |
| 37 |
__gmpf_add(tmp_num->_mpf, _mpf, |
| 38 |
dynamic_cast<_knumfloat const &>(arg2)._mpf); |
| 39 |
} |