msvcp90: Introduce throw_failure helper.

Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Piotr Caban 2021-08-27 13:48:33 +02:00 committed by Alexandre Julliard
parent 93455491fc
commit d7e9190032
6 changed files with 20 additions and 14 deletions

View File

@ -4849,13 +4849,13 @@ void __thiscall ios_base_clear_reraise(ios_base *this, IOSB_iostate state, bool
if(reraise)
_CxxThrowException(NULL, NULL);
else if(this->state & this->except & IOSTATE_eofbit)
throw_exception(EXCEPTION_FAILURE, "eofbit is set");
throw_failure("eofbit is set");
else if(this->state & this->except & IOSTATE_failbit)
throw_exception(EXCEPTION_FAILURE, "failbit is set");
throw_failure("failbit is set");
else if(this->state & this->except & IOSTATE_badbit)
throw_exception(EXCEPTION_FAILURE, "badbit is set");
throw_failure("badbit is set");
else if(this->state & this->except & IOSTATE__Hardfail)
throw_exception(EXCEPTION_FAILURE, "_Hardfail is set");
throw_failure("_Hardfail is set");
}
/* ?clear@ios_base@std@@QAEXH@Z */

View File

@ -488,3 +488,4 @@ void WINAPI DECLSPEC_NORETURN _CxxThrowException(void*,const cxx_exception_type*
void __cdecl DECLSPEC_NORETURN _Xlength_error(const char*);
void __cdecl DECLSPEC_NORETURN _Xmem(void);
void __cdecl DECLSPEC_NORETURN _Xout_of_range(const char*);
void DECLSPEC_NORETURN throw_failure(const char*);

View File

@ -319,7 +319,6 @@ typedef enum __exception_type {
EXCEPTION,
EXCEPTION_BAD_CAST,
EXCEPTION_LOGIC_ERROR,
EXCEPTION_FAILURE,
} exception_type;
void throw_exception(exception_type, const char *);

View File

@ -1086,11 +1086,6 @@ void throw_exception(exception_type et, const char *str)
MSVCP_logic_error_ctor(&e, name);
_CxxThrowException(&e, &logic_error_cxx_type);
}
case EXCEPTION_FAILURE: {
failure e;
MSVCP_failure_ctor(&e, name);
_CxxThrowException(&e, &failure_cxx_type);
}
}
}
@ -1104,6 +1099,16 @@ void DECLSPEC_NORETURN throw_range_error(const char *str)
_CxxThrowException(&e, &range_error_cxx_type);
}
/* Internal: throws failure exception */
void DECLSPEC_NORETURN throw_failure(const char *str)
{
exception_name name = EXCEPTION_NAME(str);
failure e;
MSVCP_failure_ctor(&e, name);
_CxxThrowException(&e, &failure_cxx_type);
}
void init_exception(void *base)
{
#ifdef __x86_64__

View File

@ -5266,13 +5266,13 @@ void __thiscall ios_base_clear_reraise(ios_base *this, IOSB_iostate state, bool
if(reraise)
_CxxThrowException(NULL, NULL);
else if(this->state & this->except & IOSTATE_eofbit)
throw_exception(EXCEPTION_FAILURE, "eofbit is set");
throw_failure("eofbit is set");
else if(this->state & this->except & IOSTATE_failbit)
throw_exception(EXCEPTION_FAILURE, "failbit is set");
throw_failure("failbit is set");
else if(this->state & this->except & IOSTATE_badbit)
throw_exception(EXCEPTION_FAILURE, "badbit is set");
throw_failure("badbit is set");
else if(this->state & this->except & IOSTATE__Hardfail)
throw_exception(EXCEPTION_FAILURE, "_Hardfail is set");
throw_failure("_Hardfail is set");
}
/* ?clear@ios_base@std@@QAEXH@Z */

View File

@ -669,4 +669,5 @@ void __cdecl DECLSPEC_NORETURN _Xlength_error(const char*);
void __cdecl DECLSPEC_NORETURN _Xmem(void);
void __cdecl DECLSPEC_NORETURN _Xout_of_range(const char*);
void __cdecl DECLSPEC_NORETURN _Xruntime_error(const char*);
void DECLSPEC_NORETURN throw_failure(const char*);
void DECLSPEC_NORETURN throw_range_error(const char*);