From 664e0da8dff1d04860cc46ce8139cbd47e15c552 Mon Sep 17 00:00:00 2001 From: Yong He Date: Sat, 4 Nov 2017 15:37:40 -0400 Subject: fix all unreachable code warnings --- source/core/common.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source/core') diff --git a/source/core/common.h b/source/core/common.h index dbb837821..3a4543085 100644 --- a/source/core/common.h +++ b/source/core/common.h @@ -41,6 +41,14 @@ namespace Slang #define SLANG_RETURN_NEVER __declspec(noreturn) #else #define SLANG_RETURN_NEVER /* empty */ +#endif + +#ifdef _MSC_VER +#define UNREACHABLE_RETURN(x) +#define UNREACHABLE(x) +#else +#define UNREACHABLE_RETURN(x) return x; +#define UNREACHABLE(x) x; #endif SLANG_RETURN_NEVER void signalUnexpectedError(char const* message); -- cgit v1.2.3 From 98d2f27ec7c1039679da5c86e4d1dfb308d0fc6f Mon Sep 17 00:00:00 2001 From: Yong He Date: Sat, 4 Nov 2017 16:27:50 -0400 Subject: gcc warning fix --- source/core/slang-string.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/core') diff --git a/source/core/slang-string.h b/source/core/slang-string.h index 3f2b85d28..0808d9715 100644 --- a/source/core/slang-string.h +++ b/source/core/slang-string.h @@ -523,7 +523,7 @@ namespace Slang UInt IndexOf(const char * str, UInt id) const // String str { - if (id < 0 || id >= getLength()) + if (id >= getLength()) return UInt(-1); auto findRs = strstr(begin() + id, str); UInt res = findRs ? findRs - begin() : -1; @@ -612,7 +612,7 @@ namespace Slang { if (!buffer) return false; - return (IndexOf(str) >= 0) ? true : false; + return (IndexOf(str) != UInt(-1)) ? true : false; } bool Contains(const String & str) const -- cgit v1.2.3