diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f0e5a793..20c735c4c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -138,7 +138,7 @@ IF (WIN32) ELSE() OPTION( ASSIMP_BUILD_ZLIB "Build your own zlib" - OFF + ON ) ENDIF() diff --git a/code/AssetLib/3DS/3DSLoader.h b/code/AssetLib/3DS/3DSLoader.h index f47fcfef9..6bd73f412 100644 --- a/code/AssetLib/3DS/3DSLoader.h +++ b/code/AssetLib/3DS/3DSLoader.h @@ -68,7 +68,7 @@ using namespace D3DS; class Discreet3DSImporter : public BaseImporter { public: Discreet3DSImporter(); - ~Discreet3DSImporter(); + ~Discreet3DSImporter() override; // ------------------------------------------------------------------- /** Returns whether the class can handle the format of the given file. diff --git a/code/AssetLib/3MF/3MFTypes.h b/code/AssetLib/3MF/3MFTypes.h index 02238ceab..8207b568b 100644 --- a/code/AssetLib/3MF/3MFTypes.h +++ b/code/AssetLib/3MF/3MFTypes.h @@ -93,7 +93,7 @@ public: // empty } - ~EmbeddedTexture() = default; + ~EmbeddedTexture() override = default; ResourceType getType() const override { return ResourceType::RT_EmbeddedTexture2D; @@ -110,7 +110,7 @@ public: // empty } - ~Texture2DGroup() = default; + ~Texture2DGroup() override = default; ResourceType getType() const override { return ResourceType::RT_Texture2DGroup; @@ -127,7 +127,7 @@ public: // empty } - ~BaseMaterials() = default; + ~BaseMaterials() override = default; ResourceType getType() const override { return ResourceType::RT_BaseMaterials; @@ -152,7 +152,7 @@ public: // empty } - ~Object() = default; + ~Object() override = default; ResourceType getType() const override { return ResourceType::RT_Object; diff --git a/code/AssetLib/AMF/AMFImporter.hpp b/code/AssetLib/AMF/AMFImporter.hpp index 601eae4e4..27f733043 100644 --- a/code/AssetLib/AMF/AMFImporter.hpp +++ b/code/AssetLib/AMF/AMFImporter.hpp @@ -282,11 +282,11 @@ public: bool Find_NodeElement(const std::string &pID, const AMFNodeElementBase::EType pType, AMFNodeElementBase **pNodeElement) const; bool Find_ConvertedNode(const std::string &pID, NodeArray &nodeArray, aiNode **pNode) const; bool Find_ConvertedMaterial(const std::string &pID, const SPP_Material **pConvertedMaterial) const; - void Throw_CloseNotFound(const std::string &nodeName); - void Throw_IncorrectAttr(const std::string &nodeName, const std::string &pAttrName); - void Throw_IncorrectAttrValue(const std::string &nodeName, const std::string &pAttrName); - void Throw_MoreThanOnceDefined(const std::string &nodeName, const std::string &pNodeType, const std::string &pDescription); - void Throw_ID_NotFound(const std::string &pID) const; + AI_WONT_RETURN void Throw_CloseNotFound(const std::string &nodeName) AI_WONT_RETURN_SUFFIX; + AI_WONT_RETURN void Throw_IncorrectAttr(const std::string &nodeName, const std::string &pAttrName) AI_WONT_RETURN_SUFFIX; + AI_WONT_RETURN void Throw_IncorrectAttrValue(const std::string &nodeName, const std::string &pAttrName) AI_WONT_RETURN_SUFFIX; + AI_WONT_RETURN void Throw_MoreThanOnceDefined(const std::string &nodeName, const std::string &pNodeType, const std::string &pDescription) AI_WONT_RETURN_SUFFIX; + AI_WONT_RETURN void Throw_ID_NotFound(const std::string &pID) const AI_WONT_RETURN_SUFFIX; void XML_CheckNode_MustHaveChildren(pugi::xml_node &node); bool XML_SearchNode(const std::string &nodeName); void ParseHelper_FixTruncatedFloatString(const char *pInStr, std::string &pOutString); diff --git a/code/AssetLib/Collada/ColladaParser.cpp b/code/AssetLib/Collada/ColladaParser.cpp index cce6a0db6..fcadd08a7 100644 --- a/code/AssetLib/Collada/ColladaParser.cpp +++ b/code/AssetLib/Collada/ColladaParser.cpp @@ -1855,7 +1855,6 @@ size_t ColladaParser::ReadPrimitives(XmlNode &node, Mesh &pMesh, std::vector end) { throw DeadlyImportError("LWOB: Invalid chunk length"); - break; } uint8_t* const next = mFileBuffer+head.length; switch (head.type) diff --git a/code/AssetLib/LWO/LWOLoader.cpp b/code/AssetLib/LWO/LWOLoader.cpp index 1bf39b2da..a7d4164bb 100644 --- a/code/AssetLib/LWO/LWOLoader.cpp +++ b/code/AssetLib/LWO/LWOLoader.cpp @@ -1486,7 +1486,6 @@ void LWOImporter::LoadLWO2File() { if (mFileBuffer + head.length > end) { throw DeadlyImportError("LWO2: Chunk length points behind the file"); - break; } uint8_t *const next = mFileBuffer + head.length; mFileBuffer += bufOffset; diff --git a/code/AssetLib/MD5/MD5Parser.h b/code/AssetLib/MD5/MD5Parser.h index bb4843cf9..ad7367e2a 100644 --- a/code/AssetLib/MD5/MD5Parser.h +++ b/code/AssetLib/MD5/MD5Parser.h @@ -365,9 +365,7 @@ public: static void ReportWarning (const char* warn, unsigned int line); - void ReportError (const char* error) { - return ReportError(error, lineNumber); - } + AI_WONT_RETURN void ReportError (const char* error) AI_WONT_RETURN_SUFFIX; void ReportWarning (const char* warn) { return ReportWarning(warn, lineNumber); @@ -404,6 +402,9 @@ private: unsigned int lineNumber; }; +inline void MD5Parser::ReportError(const char* error) { + ReportError(error, lineNumber); +} // ------------------------------------------------------------------- inline bool MD5Parser::SkipLine(const char* in, const char** out) { ++lineNumber; diff --git a/code/AssetLib/MDL/MDLLoader.h b/code/AssetLib/MDL/MDLLoader.h index b7d87e88d..433100938 100644 --- a/code/AssetLib/MDL/MDLLoader.h +++ b/code/AssetLib/MDL/MDLLoader.h @@ -139,7 +139,7 @@ protected: // ------------------------------------------------------------------- /** Import a CS:S/HL2 MDL file (not fully implemented) */ - void InternReadFile_HL2( ); + AI_WONT_RETURN void InternReadFile_HL2( ) AI_WONT_RETURN_SUFFIX; // ------------------------------------------------------------------- /** Check whether a given position is inside the valid range diff --git a/code/AssetLib/MMD/MMDPmxParser.h b/code/AssetLib/MMD/MMDPmxParser.h index f2e387975..424fc725a 100644 --- a/code/AssetLib/MMD/MMDPmxParser.h +++ b/code/AssetLib/MMD/MMDPmxParser.h @@ -46,6 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include #include "MMDCpp14.h" namespace pmx @@ -730,7 +731,7 @@ namespace pmx std::unique_ptr anchers; int pin_vertex_count; std::unique_ptr pin_vertices; - void Read(std::istream *stream, PmxSetting *setting); + AI_WONT_RETURN void Read(std::istream *stream, PmxSetting *setting) AI_WONT_RETURN_SUFFIX; }; class PmxModel diff --git a/code/AssetLib/Obj/ObjFileParser.cpp b/code/AssetLib/Obj/ObjFileParser.cpp index c7121083a..ed416dc93 100644 --- a/code/AssetLib/Obj/ObjFileParser.cpp +++ b/code/AssetLib/Obj/ObjFileParser.cpp @@ -236,7 +236,7 @@ void ObjFileParser::parseFile(IOStreamBuffer &streamBuffer) { getNameNoSpace(m_DataIt, m_DataItEnd, name); insideCstype = name == "cstype"; goto pf_skip_line; - } break; + } default: { pf_skip_line: diff --git a/code/AssetLib/Q3D/Q3DLoader.cpp b/code/AssetLib/Q3D/Q3DLoader.cpp index a91788c78..22d1065de 100644 --- a/code/AssetLib/Q3D/Q3DLoader.cpp +++ b/code/AssetLib/Q3D/Q3DLoader.cpp @@ -382,11 +382,10 @@ void Q3DImporter::InternReadFile(const std::string &pFile, // TODO goto outer; - } break; + } default: throw DeadlyImportError("Quick3D: Unknown chunk"); - break; }; } outer: diff --git a/code/AssetLib/Raw/RawLoader.h b/code/AssetLib/Raw/RawLoader.h index 6e4c4d110..54314f728 100644 --- a/code/AssetLib/Raw/RawLoader.h +++ b/code/AssetLib/Raw/RawLoader.h @@ -58,7 +58,7 @@ namespace Assimp { class RAWImporter : public BaseImporter { public: RAWImporter(); - ~RAWImporter(); + ~RAWImporter() override; // ------------------------------------------------------------------- /** Returns whether the class can handle the format of the given file. diff --git a/code/AssetLib/Unreal/UnrealLoader.h b/code/AssetLib/Unreal/UnrealLoader.h index a931a86dd..fda784cfb 100644 --- a/code/AssetLib/Unreal/UnrealLoader.h +++ b/code/AssetLib/Unreal/UnrealLoader.h @@ -56,7 +56,7 @@ namespace Assimp { class UnrealImporter : public BaseImporter { public: UnrealImporter(); - ~UnrealImporter(); + ~UnrealImporter() override; // ------------------------------------------------------------------- /** @brief Returns whether we can handle the format of the given file diff --git a/code/AssetLib/X/XFileParser.cpp b/code/AssetLib/X/XFileParser.cpp index 8786c3166..770c75a77 100644 --- a/code/AssetLib/X/XFileParser.cpp +++ b/code/AssetLib/X/XFileParser.cpp @@ -839,7 +839,6 @@ void XFileParser::ParseDataObjectAnimationKey(AnimBone *pAnimBone) { default: ThrowException("Unknown key type ", keyType, " in animation."); - break; } // end switch // key separator diff --git a/code/AssetLib/X3D/X3DImporter.hpp b/code/AssetLib/X3D/X3DImporter.hpp index 8852b71ec..705a2472e 100644 --- a/code/AssetLib/X3D/X3DImporter.hpp +++ b/code/AssetLib/X3D/X3DImporter.hpp @@ -55,6 +55,18 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include namespace Assimp { +AI_WONT_RETURN inline void Throw_ArgOutOfRange(const std::string &argument) AI_WONT_RETURN_SUFFIX; +AI_WONT_RETURN inline void Throw_CloseNotFound(const std::string &node) AI_WONT_RETURN_SUFFIX; +AI_WONT_RETURN inline void Throw_ConvertFail_Str2ArrF(const std::string &nodeName, const std::string &pAttrValue) AI_WONT_RETURN_SUFFIX; +AI_WONT_RETURN inline void Throw_ConvertFail_Str2ArrD(const std::string &nodeName, const std::string &pAttrValue) AI_WONT_RETURN_SUFFIX; +AI_WONT_RETURN inline void Throw_ConvertFail_Str2ArrB(const std::string &nodeName, const std::string &pAttrValue) AI_WONT_RETURN_SUFFIX; +AI_WONT_RETURN inline void Throw_ConvertFail_Str2ArrI(const std::string &nodeName, const std::string &pAttrValue) AI_WONT_RETURN_SUFFIX; +AI_WONT_RETURN inline void Throw_DEF_And_USE(const std::string &nodeName) AI_WONT_RETURN_SUFFIX; +AI_WONT_RETURN inline void Throw_IncorrectAttr(const std::string &nodeName, const std::string &pAttrName) AI_WONT_RETURN_SUFFIX; +AI_WONT_RETURN inline void Throw_IncorrectAttrValue(const std::string &nodeName, const std::string &pAttrName) AI_WONT_RETURN_SUFFIX; +AI_WONT_RETURN inline void Throw_MoreThanOnceDefined(const std::string &nodeName, const std::string &pNodeType, const std::string &pDescription) AI_WONT_RETURN_SUFFIX; +AI_WONT_RETURN inline void Throw_TagCountIncorrect(const std::string &pNode) AI_WONT_RETURN_SUFFIX; +AI_WONT_RETURN inline void Throw_USE_NotFound(const std::string &nodeName, const std::string &pAttrValue) AI_WONT_RETURN_SUFFIX; inline void Throw_ArgOutOfRange(const std::string &argument) { throw DeadlyImportError("Argument value is out of range for: \"" + argument + "\"."); diff --git a/code/AssetLib/glTF2/glTF2Asset.h b/code/AssetLib/glTF2/glTF2Asset.h index cf9c8f11c..048937502 100644 --- a/code/AssetLib/glTF2/glTF2Asset.h +++ b/code/AssetLib/glTF2/glTF2Asset.h @@ -483,7 +483,7 @@ private: public: Buffer(); - ~Buffer(); + ~Buffer() override; void Read(Value &obj, Asset &r); diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 6e0d0f143..d5500d986 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -1211,7 +1211,6 @@ IF (ASSIMP_WARNINGS_AS_ERRORS) -Wno-undef -Wno-suggest-destructor-override -Wno-suggest-override - -Wno-inconsistent-missing-destructor-override -Wno-zero-as-null-pointer-constant -Wno-global-constructors -Wno-exit-time-destructors @@ -1236,6 +1235,7 @@ IF (ASSIMP_WARNINGS_AS_ERRORS) -Wno-tautological-value-range-compare -Wno-tautological-type-limit-compare -Wno-missing-noreturn + -Wno-missing-variable-declarations -Wno-extra-semi -Wno-nonportable-system-include-path -Wno-undefined-reinterpret-cast @@ -1245,7 +1245,6 @@ IF (ASSIMP_WARNINGS_AS_ERRORS) -Wno-deprecated -Wno-format-nonliteral -Wno-comma - -Wno-unreachable-code-break -Wno-implicit-fallthrough -Wno-unused-template -Wno-undefined-func-template diff --git a/code/Common/ZipArchiveIOSystem.cpp b/code/Common/ZipArchiveIOSystem.cpp index d0c2f3204..51a250810 100644 --- a/code/Common/ZipArchiveIOSystem.cpp +++ b/code/Common/ZipArchiveIOSystem.cpp @@ -68,7 +68,7 @@ class ZipFile : public IOStream { public: std::string m_Filename; - virtual ~ZipFile(); + virtual ~ZipFile() override; // IOStream interface size_t Read(void *pvBuffer, size_t pSize, size_t pCount) override; diff --git a/code/PostProcessing/ValidateDataStructure.cpp b/code/PostProcessing/ValidateDataStructure.cpp index e31054972..bbb08a2e9 100644 --- a/code/PostProcessing/ValidateDataStructure.cpp +++ b/code/PostProcessing/ValidateDataStructure.cpp @@ -290,7 +290,6 @@ void ValidateDSProcess::Validate(const aiMesh *pMesh) { switch (face.mNumIndices) { case 0: ReportError("aiMesh::mFaces[%i].mNumIndices is 0", i); - break; case 1: if (0 == (pMesh->mPrimitiveTypes & aiPrimitiveType_POINT)) { ReportError("aiMesh::mFaces[%i] is a POINT but aiMesh::mPrimitiveTypes " diff --git a/contrib/Open3DGC/o3dgcArithmeticCodec.cpp b/contrib/Open3DGC/o3dgcArithmeticCodec.cpp index 2ae70fa2e..c1935822d 100644 --- a/contrib/Open3DGC/o3dgcArithmeticCodec.cpp +++ b/contrib/Open3DGC/o3dgcArithmeticCodec.cpp @@ -92,6 +92,7 @@ namespace o3dgc // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - Static functions - - - - - - - - - - - - - - - - - - - - - - - - - - - + AI_WONT_RETURN static void AC_Error(const char * msg) AI_WONT_RETURN_SUFFIX; static void AC_Error(const char * msg) { fprintf(stderr, "\n\n -> Arithmetic coding error: "); diff --git a/include/assimp/AssertHandler.h b/include/assimp/AssertHandler.h index 365a924b0..1247ff490 100644 --- a/include/assimp/AssertHandler.h +++ b/include/assimp/AssertHandler.h @@ -66,7 +66,7 @@ ASSIMP_API void setAiAssertHandler(AiAssertHandler handler); * * @brief This issues a message to stderr and calls abort. */ -ASSIMP_API void defaultAiAssertHandler(const char* failedExpression, const char* file, int line); +AI_WONT_RETURN ASSIMP_API void defaultAiAssertHandler(const char* failedExpression, const char* file, int line) AI_WONT_RETURN_SUFFIX; // --------------------------------------------------------------------------- /** diff --git a/include/assimp/DefaultIOStream.h b/include/assimp/DefaultIOStream.h index e8d9ed329..67cba3c5c 100644 --- a/include/assimp/DefaultIOStream.h +++ b/include/assimp/DefaultIOStream.h @@ -84,7 +84,7 @@ protected: public: /** Destructor public to allow simple deletion to close the file. */ - ~DefaultIOStream (); + ~DefaultIOStream () override; // ------------------------------------------------------------------- /// Read from stream diff --git a/include/assimp/MemoryIOWrapper.h b/include/assimp/MemoryIOWrapper.h index 1b986ff1b..4023f7529 100644 --- a/include/assimp/MemoryIOWrapper.h +++ b/include/assimp/MemoryIOWrapper.h @@ -65,8 +65,8 @@ namespace Assimp { // ---------------------------------------------------------------------------------- class MemoryIOStream : public IOStream { public: - MemoryIOStream (const uint8_t* buff, size_t len, bool own = false) : - buffer (buff), + MemoryIOStream (const uint8_t* buff, size_t len, bool own = false) : + buffer (buff), length(len), pos(static_cast(0)), own(own) { @@ -145,7 +145,7 @@ public: } /// @brief Destructor. - ~MemoryIOSystem() = default; + ~MemoryIOSystem() override = default; // ------------------------------------------------------------------- /// @brief Tests for the existence of a file at the given path. @@ -190,7 +190,7 @@ public: bool ComparePaths(const char* one, const char* second) const override { return existing_io ? existing_io->ComparePaths(one, second) : false; } - + /// @brief Will push the directory. bool PushDirectory( const std::string &path ) override { return existing_io ? existing_io->PushDirectory(path) : false; @@ -216,7 +216,7 @@ public: bool CreateDirectory( const std::string &path ) override { return existing_io ? existing_io->CreateDirectory(path) : false; } - + /// @brief Will change the directory. bool ChangeDirectory( const std::string &path ) override { return existing_io ? existing_io->ChangeDirectory(path) : false; diff --git a/include/assimp/ZipArchiveIOSystem.h b/include/assimp/ZipArchiveIOSystem.h index dac60b501..9f3a4783b 100644 --- a/include/assimp/ZipArchiveIOSystem.h +++ b/include/assimp/ZipArchiveIOSystem.h @@ -63,7 +63,7 @@ public: //! Open a Zip using the proffered IOSystem ZipArchiveIOSystem(IOSystem* pIOHandler, const char *pFilename, const char* pMode = "r"); ZipArchiveIOSystem(IOSystem* pIOHandler, const std::string& rFilename, const char* pMode = "r"); - virtual ~ZipArchiveIOSystem(); + virtual ~ZipArchiveIOSystem() override; bool Exists(const char* pFilename) const override; char getOsSeparator() const override; IOStream* Open(const char* pFilename, const char* pMode = "rb") override; diff --git a/include/assimp/defs.h b/include/assimp/defs.h index ddb209bec..34121e385 100644 --- a/include/assimp/defs.h +++ b/include/assimp/defs.h @@ -184,6 +184,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifdef __GNUC__ # define AI_WONT_RETURN_SUFFIX __attribute__((noreturn)) +#elif _MSC_VER +#if defined(__clang__) +# define AI_WONT_RETURN_SUFFIX __attribute__((noreturn)) +#else +# define AI_WONT_RETURN_SUFFIX +#endif #else # define AI_WONT_RETURN_SUFFIX #endif // (defined __clang__)