| 1 |
/* PR target/111822 */ |
| 2 |
/* { dg-do compile { target ia32 } } */ |
| 3 |
/* { dg-options "-O2 -flive-range-shrinkage -fno-dce -fnon-call-exceptions -march=x86-64" } */ |
| 4 |
|
| 5 |
typedef union { |
| 6 |
int *pNativeClosure; |
| 7 |
struct SQRefCounted *pRefCounted; |
| 8 |
} SQObjectValue; |
| 9 |
typedef struct { |
| 10 |
SQObjectValue _unVal; |
| 11 |
} SQObject; |
| 12 |
typedef long SQFUNCTION(struct SQVM *); |
| 13 |
struct SQVM { |
| 14 |
void CallNative(); |
| 15 |
}; |
| 16 |
struct SQRefCounted { |
| 17 |
long long _uiRef; |
| 18 |
}; |
| 19 |
void Null(); |
| 20 |
struct SQObjectPtr : SQObject { |
| 21 |
SQObjectPtr() {} |
| 22 |
SQObjectPtr(int *pNativeClosure) { |
| 23 |
_unVal.pNativeClosure = pNativeClosure; |
| 24 |
_unVal.pRefCounted->_uiRef++; |
| 25 |
} |
| 26 |
~SQObjectPtr() { --_unVal.pRefCounted->_uiRef; } |
| 27 |
}; |
| 28 |
struct CallInfo { |
| 29 |
SQObjectPtr _closure; |
| 30 |
}; |
| 31 |
long long _top; |
| 32 |
SQFUNCTION _function; |
| 33 |
int *CallNative_nclosure; |
| 34 |
void SQVM::CallNative() { |
| 35 |
long long oldtop = _top; |
| 36 |
CallInfo lci; |
| 37 |
lci._closure = CallNative_nclosure; |
| 38 |
try { |
| 39 |
_function(this); |
| 40 |
} catch (...) { |
| 41 |
_top = oldtop; |
| 42 |
} |
| 43 |
while (oldtop) |
| 44 |
Null(); |
| 45 |
} |