- added [[noreturn]] to several functions that always throw exceptions.

This commit is contained in:
Christoph Oelckers 2022-11-05 09:09:00 +01:00
parent 7d81417829
commit 9c75a38ec3
7 changed files with 14 additions and 14 deletions

View file

@ -138,7 +138,7 @@ IMPLEMENT_CLASS(DShape2D, false, false)
static void Shape2D_SetTransform(DShape2D* self, DShape2DTransform *transform) static void Shape2D_SetTransform(DShape2D* self, DShape2DTransform *transform)
{ {
self->transform = transform->transform; self->transform = PARAM_NULLCHECK(transform, transform)->transform;
} }
DEFINE_ACTION_FUNCTION_NATIVE(DShape2D, SetTransform, Shape2D_SetTransform) DEFINE_ACTION_FUNCTION_NATIVE(DShape2D, SetTransform, Shape2D_SetTransform)

View file

@ -75,8 +75,8 @@ enum
}; };
void I_Error(const char *fmt, ...) ATTRIBUTE((format(printf,1,2))); [[noreturn]] void I_Error(const char *fmt, ...) ATTRIBUTE((format(printf,1,2)));
void I_FatalError(const char* fmt, ...) ATTRIBUTE((format(printf, 1, 2))); [[noreturn]] void I_FatalError(const char* fmt, ...) ATTRIBUTE((format(printf, 1, 2)));
// This really could need some cleanup - the main problem is that it'd create // This really could need some cleanup - the main problem is that it'd create
// lots of potential for merge conflicts. // lots of potential for merge conflicts.

View file

@ -593,7 +593,7 @@ const TArray<VSMatrix> IQMModel::CalculateBones(int frame1, int frame2, double i
actor->boneComponentData->trsmatrix[index] = bones; actor->boneComponentData->trsmatrix[index] = bones;
for (uint32_t j = 0; j < numbones; j++) for (int j = 0; j < numbones; j++)
{ {
VSMatrix m; VSMatrix m;
m.loadMatrix(swapYZ); m.loadMatrix(swapYZ);

View file

@ -110,8 +110,8 @@ public:
}; };
// This must be a separate function because the VC compiler would otherwise allocate memory on the stack for every separate instance of the exception object that may get thrown. // This must be a separate function because the VC compiler would otherwise allocate memory on the stack for every separate instance of the exception object that may get thrown.
void ThrowAbortException(EVMAbortException reason, const char *moreinfo, ...); [[noreturn]] void ThrowAbortException(EVMAbortException reason, const char *moreinfo, ...);
void ThrowAbortException(VMScriptFunction *sfunc, VMOP *line, EVMAbortException reason, const char *moreinfo, ...); [[noreturn]] void ThrowAbortException(VMScriptFunction *sfunc, VMOP *line, EVMAbortException reason, const char *moreinfo, ...);
void ClearGlobalVMStack(); void ClearGlobalVMStack();
@ -496,6 +496,7 @@ inline int VMCallAction(VMFunction *func, VMValue *params, int numparams, VMRetu
// Use these to collect the parameters in a native function. // Use these to collect the parameters in a native function.
// variable name <x> at position <p> // variable name <x> at position <p>
[[noreturn]]
void NullParam(const char *varname); void NullParam(const char *varname);
#ifndef NDEBUG #ifndef NDEBUG

View file

@ -688,14 +688,14 @@ void CVMAbortException::MaybePrintMessage()
} }
void ThrowAbortException(EVMAbortException reason, const char *moreinfo, ...) [[noreturn]] void ThrowAbortException(EVMAbortException reason, const char *moreinfo, ...)
{ {
va_list ap; va_list ap;
va_start(ap, moreinfo); va_start(ap, moreinfo);
throw CVMAbortException(reason, moreinfo, ap); throw CVMAbortException(reason, moreinfo, ap);
} }
void ThrowAbortException(VMScriptFunction *sfunc, VMOP *line, EVMAbortException reason, const char *moreinfo, ...) [[noreturn]] void ThrowAbortException(VMScriptFunction *sfunc, VMOP *line, EVMAbortException reason, const char *moreinfo, ...)
{ {
va_list ap; va_list ap;
va_start(ap, moreinfo); va_start(ap, moreinfo);
@ -711,10 +711,9 @@ DEFINE_ACTION_FUNCTION(DObject, ThrowAbortException)
PARAM_PROLOGUE; PARAM_PROLOGUE;
FString s = FStringFormat(VM_ARGS_NAMES); FString s = FStringFormat(VM_ARGS_NAMES);
ThrowAbortException(X_OTHER, s.GetChars()); ThrowAbortException(X_OTHER, s.GetChars());
return 0;
} }
void NullParam(const char *varname) [[noreturn]] void NullParam(const char *varname)
{ {
ThrowAbortException(X_READ_NIL, "In function parameter %s", varname); ThrowAbortException(X_READ_NIL, "In function parameter %s", varname);
} }

View file

@ -63,7 +63,7 @@ void I_DebugPrint(const char *cp)
// //
//========================================================================== //==========================================================================
void I_Error(const char *error, ...) [[noreturn]] void I_Error(const char *error, ...)
{ {
va_list argptr; va_list argptr;
char errortext[MAX_ERRORTEXT]; char errortext[MAX_ERRORTEXT];
@ -85,7 +85,7 @@ void I_Error(const char *error, ...)
//========================================================================== //==========================================================================
extern FILE *Logfile; extern FILE *Logfile;
void I_FatalError(const char *error, ...) [[noreturn]] void I_FatalError(const char *error, ...)
{ {
static bool alreadyThrown = false; static bool alreadyThrown = false;
gameisdead = true; gameisdead = true;

View file

@ -110,7 +110,7 @@ public:
}; };
void I_ShowFatalError(const char *message); void I_ShowFatalError(const char *message);
void I_Error (const char *error, ...) GCCPRINTF(1,2); [[noreturn]] void I_Error (const char *error, ...) GCCPRINTF(1,2);
void I_FatalError (const char *error, ...) GCCPRINTF(1,2); [[noreturn]] void I_FatalError (const char *error, ...) GCCPRINTF(1,2);
#endif //__ERRORS_H__ #endif //__ERRORS_H__