1
0
mirror of https://github.com/google/cpu_features.git synced 2025-04-27 15:12:30 +02:00

fix: Return default value from ‘GetCacheTypeString’ (#162)

The build fails with following message when -Werror
and -Werror=return-type are enabled.

In function ‘GetCacheTypeString’:
	error: control reaches end of non-void function [-Werror=return-type]

Simple fix is to return explicitly communicate to
the compiler that certain block is not reachable.
This commit is contained in:
Kris Kwiatkowski 2021-06-25 09:28:26 +01:00 committed by GitHub
parent 646b80fa3a
commit 001faefdc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -213,4 +213,17 @@
#endif // defined(__mips_msa)
#endif // defined(CPU_FEATURES_ARCH_MIPS)
////////////////////////////////////////////////////////////////////////////////
// Utils
////////////////////////////////////////////////////////////////////////////////
// Communicates to the compiler that the block is unreachable
#if defined(CPU_FEATURES_COMPILER_CLANG) || defined(CPU_FEATURES_COMPILER_GCC)
#define UNREACHABLE() __builtin_unreachable()
#elif defined(CPU_FEATURES_COMPILER_MSC)
#define UNREACHABLE() __assume(0)
#else
#define UNREACHABLE()
#endif
#endif // CPU_FEATURES_INCLUDE_CPU_FEATURES_MACROS_H_

View File

@ -340,6 +340,7 @@ static Node* GetCacheTypeString(CacheType cache_type) {
case CPU_FEATURE_CACHE_PREFETCH:
return CreateConstantString("prefetch");
}
UNREACHABLE();
}
static void AddCacheInfo(Node* root, const CacheInfo* cache_info) {