Ensure functions always have a return even in release builds.

This commit is contained in:
Bob Nystrom
2014-12-01 21:36:06 -08:00
parent c001042276
commit e3cf80127b
3 changed files with 7 additions and 3 deletions

View File

@ -2258,6 +2258,7 @@ static int getNumArguments(const uint8_t* bytecode, const Value* constants,
default:
UNREACHABLE();
return 0;
}
}

View File

@ -668,7 +668,8 @@ ObjClass* wrenGetClass(WrenVM* vm, Value value)
}
#endif
return NULL; // Unreachable.
UNREACHABLE();
return NULL;
}
bool wrenValuesEqual(Value a, Value b)

View File

@ -1007,10 +1007,12 @@ static bool runInterpreter(WrenVM* vm)
// A CODE_END should always be preceded by a CODE_RETURN. If we get here,
// the compiler generated wrong code.
UNREACHABLE();
DISPATCH();
}
ASSERT(0, "Should not reach end of interpret.");
// We should only exit this function from an explicit return from CODE_RETURN
// or a runtime error.
UNREACHABLE();
return false;
}
WrenInterpretResult wrenInterpret(WrenVM* vm, const char* sourcePath,