simde-diagnostic.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. /* SPDX-License-Identifier: MIT
  2. *
  3. * Permission is hereby granted, free of charge, to any person
  4. * obtaining a copy of this software and associated documentation
  5. * files (the "Software"), to deal in the Software without
  6. * restriction, including without limitation the rights to use, copy,
  7. * modify, merge, publish, distribute, sublicense, and/or sell copies
  8. * of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be
  12. * included in all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  15. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  16. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  17. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  18. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  19. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  20. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21. * SOFTWARE.
  22. *
  23. * Copyright:
  24. * 2017-2020 Evan Nemerson <evan@nemerson.com>
  25. */
  26. /* SIMDe targets a very wide range of standards and compilers, and our
  27. * goal is to compile cleanly even with extremely aggressive warnings
  28. * (i.e., -Weverything in clang, -Wextra in GCC, /W4 for MSVC, etc.)
  29. * treated as errors.
  30. *
  31. * While our preference is to resolve the underlying issue a given
  32. * diagnostic is warning us about, sometimes that's not possible.
  33. * Fixing a warning in one compiler may cause problems in another.
  34. * Sometimes a warning doesn't really apply to us (false positives),
  35. * and sometimes adhering to a warning would mean dropping a feature
  36. * we *know* the compiler supports since we have tested specifically
  37. * for the compiler or feature.
  38. *
  39. * When practical, warnings are only disabled for specific code. For
  40. * a list of warnings which are enabled by default in all SIMDe code,
  41. * see SIMDE_DISABLE_UNWANTED_DIAGNOSTICS. Note that we restore the
  42. * warning stack when SIMDe is done parsing, so code which includes
  43. * SIMDe is not deprived of these warnings.
  44. */
  45. #if !defined(SIMDE_DIAGNOSTIC_H)
  46. #define SIMDE_DIAGNOSTIC_H
  47. #include "hedley.h"
  48. #include "simde-detect-clang.h"
  49. #include "simde-arch.h"
  50. /* This is only to help us implement functions like _mm_undefined_ps. */
  51. #if defined(SIMDE_DIAGNOSTIC_DISABLE_UNINITIALIZED_)
  52. #undef SIMDE_DIAGNOSTIC_DISABLE_UNINITIALIZED_
  53. #endif
  54. #if HEDLEY_HAS_WARNING("-Wuninitialized")
  55. #define SIMDE_DIAGNOSTIC_DISABLE_UNINITIALIZED_ _Pragma("clang diagnostic ignored \"-Wuninitialized\"")
  56. #elif HEDLEY_GCC_VERSION_CHECK(4,2,0)
  57. #define SIMDE_DIAGNOSTIC_DISABLE_UNINITIALIZED_ _Pragma("GCC diagnostic ignored \"-Wuninitialized\"")
  58. #elif HEDLEY_PGI_VERSION_CHECK(19,10,0)
  59. #define SIMDE_DIAGNOSTIC_DISABLE_UNINITIALIZED_ _Pragma("diag_suppress 549")
  60. #elif HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)
  61. #define SIMDE_DIAGNOSTIC_DISABLE_UNINITIALIZED_ _Pragma("error_messages(off,SEC_UNINITIALIZED_MEM_READ,SEC_UNDEFINED_RETURN_VALUE,unassigned)")
  62. #elif HEDLEY_SUNPRO_VERSION_CHECK(5,14,0)
  63. #define SIMDE_DIAGNOSTIC_DISABLE_UNINITIALIZED_ _Pragma("error_messages(off,SEC_UNINITIALIZED_MEM_READ,SEC_UNDEFINED_RETURN_VALUE)")
  64. #elif HEDLEY_SUNPRO_VERSION_CHECK(5,12,0) && defined(__cplusplus)
  65. #define SIMDE_DIAGNOSTIC_DISABLE_UNINITIALIZED_ _Pragma("error_messages(off,unassigned)")
  66. #elif \
  67. HEDLEY_TI_VERSION_CHECK(16,9,9) || \
  68. HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
  69. HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
  70. HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,2)
  71. #define SIMDE_DIAGNOSTIC_DISABLE_UNINITIALIZED_ _Pragma("diag_suppress 551")
  72. #elif HEDLEY_INTEL_VERSION_CHECK(13,0,0)
  73. #define SIMDE_DIAGNOSTIC_DISABLE_UNINITIALIZED_ _Pragma("warning(disable:592)")
  74. #elif HEDLEY_MSVC_VERSION_CHECK(19,0,0) && !defined(__MSVC_RUNTIME_CHECKS)
  75. #define SIMDE_DIAGNOSTIC_DISABLE_UNINITIALIZED_ __pragma(warning(disable:4700))
  76. #endif
  77. /* GCC emits a lot of "notes" about the ABI being different for things
  78. * in newer versions of GCC. We don't really care because all our
  79. * functions are inlined and don't generate ABI. */
  80. #if HEDLEY_GCC_VERSION_CHECK(7,0,0)
  81. #define SIMDE_DIAGNOSTIC_DISABLE_PSABI_ _Pragma("GCC diagnostic ignored \"-Wpsabi\"")
  82. #else
  83. #define SIMDE_DIAGNOSTIC_DISABLE_PSABI_
  84. #endif
  85. /* Since MMX uses x87 FP registers, you're supposed to call _mm_empty()
  86. * after each MMX function before any floating point instructions.
  87. * Some compilers warn about functions which use MMX functions but
  88. * don't call _mm_empty(). However, since SIMDe is implementyng the
  89. * MMX API we shouldn't be calling _mm_empty(); we leave it to the
  90. * caller to invoke simde_mm_empty(). */
  91. #if HEDLEY_INTEL_VERSION_CHECK(19,0,0)
  92. #define SIMDE_DIAGNOSTIC_DISABLE_NO_EMMS_INSTRUCTION_ _Pragma("warning(disable:13200 13203)")
  93. #elif defined(HEDLEY_MSVC_VERSION)
  94. #define SIMDE_DIAGNOSTIC_DISABLE_NO_EMMS_INSTRUCTION_ __pragma(warning(disable:4799))
  95. #else
  96. #define SIMDE_DIAGNOSTIC_DISABLE_NO_EMMS_INSTRUCTION_
  97. #endif
  98. /* Intel is pushing people to use OpenMP SIMD instead of Cilk+, so they
  99. * emit a diagnostic if you use #pragma simd instead of
  100. * #pragma omp simd. SIMDe supports OpenMP SIMD, you just need to
  101. * compile with -qopenmp or -qopenmp-simd and define
  102. * SIMDE_ENABLE_OPENMP. Cilk+ is just a fallback. */
  103. #if HEDLEY_INTEL_VERSION_CHECK(18,0,0)
  104. #define SIMDE_DIAGNOSTIC_DISABLE_SIMD_PRAGMA_DEPRECATED_ _Pragma("warning(disable:3948)")
  105. #else
  106. #define SIMDE_DIAGNOSTIC_DISABLE_SIMD_PRAGMA_DEPRECATED_
  107. #endif
  108. /* MSVC emits a diagnostic when we call a function (like
  109. * simde_mm_set_epi32) while initializing a struct. We currently do
  110. * this a *lot* in the tests. */
  111. #if \
  112. defined(HEDLEY_MSVC_VERSION)
  113. #define SIMDE_DIAGNOSTIC_DISABLE_NON_CONSTANT_AGGREGATE_INITIALIZER_ __pragma(warning(disable:4204))
  114. #else
  115. #define SIMDE_DIAGNOSTIC_DISABLE_NON_CONSTANT_AGGREGATE_INITIALIZER_
  116. #endif
  117. /* This warning needs a lot of work. It is triggered if all you do is
  118. * pass the value to memcpy/__builtin_memcpy, or if you initialize a
  119. * member of the union, even if that member takes up the entire union.
  120. * Last tested with clang-10, hopefully things will improve in the
  121. * future; if clang fixes this I'd love to enable it. */
  122. #if \
  123. HEDLEY_HAS_WARNING("-Wconditional-uninitialized")
  124. #define SIMDE_DIAGNOSTIC_DISABLE_CONDITIONAL_UNINITIALIZED_ _Pragma("clang diagnostic ignored \"-Wconditional-uninitialized\"")
  125. #else
  126. #define SIMDE_DIAGNOSTIC_DISABLE_CONDITIONAL_UNINITIALIZED_
  127. #endif
  128. /* This warning is meant to catch things like `0.3 + 0.4 == 0.7`, which
  129. * will is false. However, SIMDe uses these operations exclusively
  130. * for things like _mm_cmpeq_ps, for which we really do want to check
  131. * for equality (or inequality).
  132. *
  133. * If someone wants to put together a SIMDE_FLOAT_EQUAL(a, op, b) macro
  134. * which just wraps a check in some code do disable this diagnostic I'd
  135. * be happy to accept it. */
  136. #if \
  137. HEDLEY_HAS_WARNING("-Wfloat-equal") || \
  138. HEDLEY_GCC_VERSION_CHECK(3,0,0)
  139. #define SIMDE_DIAGNOSTIC_DISABLE_FLOAT_EQUAL_ _Pragma("GCC diagnostic ignored \"-Wfloat-equal\"")
  140. #else
  141. #define SIMDE_DIAGNOSTIC_DISABLE_FLOAT_EQUAL_
  142. #endif
  143. /* This is because we use HEDLEY_STATIC_ASSERT for static assertions.
  144. * If Hedley can't find an implementation it will preprocess to
  145. * nothing, which means there will be a trailing semi-colon. */
  146. #if HEDLEY_HAS_WARNING("-Wextra-semi")
  147. #define SIMDE_DIAGNOSTIC_DISABLE_EXTRA_SEMI_ _Pragma("clang diagnostic ignored \"-Wextra-semi\"")
  148. #elif HEDLEY_GCC_VERSION_CHECK(8,1,0) && defined(__cplusplus)
  149. #define SIMDE_DIAGNOSTIC_DISABLE_EXTRA_SEMI_ _Pragma("GCC diagnostic ignored \"-Wextra-semi\"")
  150. #else
  151. #define SIMDE_DIAGNOSTIC_DISABLE_EXTRA_SEMI_
  152. #endif
  153. /* We do use a few variadic macros, which technically aren't available
  154. * until C99 and C++11, but every compiler I'm aware of has supported
  155. * them for much longer. That said, usage is isolated to the test
  156. * suite and compilers known to support them. */
  157. #if HEDLEY_HAS_WARNING("-Wvariadic-macros") || HEDLEY_GCC_VERSION_CHECK(4,0,0)
  158. #if HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic")
  159. #define SIMDE_DIAGNOSTIC_DISABLE_VARIADIC_MACROS_ \
  160. _Pragma("clang diagnostic ignored \"-Wvariadic-macros\"") \
  161. _Pragma("clang diagnostic ignored \"-Wc++98-compat-pedantic\"")
  162. #else
  163. #define SIMDE_DIAGNOSTIC_DISABLE_VARIADIC_MACROS_ _Pragma("GCC diagnostic ignored \"-Wvariadic-macros\"")
  164. #endif
  165. #else
  166. #define SIMDE_DIAGNOSTIC_DISABLE_VARIADIC_MACROS_
  167. #endif
  168. /* emscripten requires us to use a __wasm_unimplemented_simd128__ macro
  169. * before we can access certain SIMD intrinsics, but this diagnostic
  170. * warns about it being a reserved name. It is a reserved name, but
  171. * it's reserved for the compiler and we are using it to convey
  172. * information to the compiler.
  173. *
  174. * This is also used when enabling native aliases since we don't get to
  175. * choose the macro names. */
  176. #if HEDLEY_HAS_WARNING("-Wreserved-id-macro")
  177. #define SIMDE_DIAGNOSTIC_DISABLE_RESERVED_ID_MACRO_ _Pragma("clang diagnostic ignored \"-Wreserved-id-macro\"")
  178. #else
  179. #define SIMDE_DIAGNOSTIC_DISABLE_RESERVED_ID_MACRO_
  180. #endif
  181. /* Similar to above; types like simde__m128i are reserved due to the
  182. * double underscore, but we didn't choose them, Intel did. */
  183. #if HEDLEY_HAS_WARNING("-Wreserved-identifier")
  184. #define SIMDE_DIAGNOSTIC_DISABLE_RESERVED_ID_ _Pragma("clang diagnostic ignored \"-Wreserved-identifier\"")
  185. #else
  186. #define SIMDE_DIAGNOSTIC_DISABLE_RESERVED_ID_
  187. #endif
  188. /* clang 3.8 warns about the packed attribute being unnecessary when
  189. * used in the _mm_loadu_* functions. That *may* be true for version
  190. * 3.8, but for later versions it is crucial in order to make unaligned
  191. * access safe. */
  192. #if HEDLEY_HAS_WARNING("-Wpacked")
  193. #define SIMDE_DIAGNOSTIC_DISABLE_PACKED_ _Pragma("clang diagnostic ignored \"-Wpacked\"")
  194. #else
  195. #define SIMDE_DIAGNOSTIC_DISABLE_PACKED_
  196. #endif
  197. /* Triggered when assigning a float to a double implicitly. We use
  198. * explicit casts in SIMDe, this is only used in the test suite. */
  199. #if HEDLEY_HAS_WARNING("-Wdouble-promotion")
  200. #define SIMDE_DIAGNOSTIC_DISABLE_DOUBLE_PROMOTION_ _Pragma("clang diagnostic ignored \"-Wdouble-promotion\"")
  201. #else
  202. #define SIMDE_DIAGNOSTIC_DISABLE_DOUBLE_PROMOTION_
  203. #endif
  204. /* Several compilers treat conformant array parameters as VLAs. We
  205. * test to make sure we're in C mode (C++ doesn't support CAPs), and
  206. * that the version of the standard supports CAPs. We also reject
  207. * some buggy compilers like MSVC (the logic is in Hedley if you want
  208. * to take a look), but with certain warnings enabled some compilers
  209. * still like to emit a diagnostic. */
  210. #if HEDLEY_HAS_WARNING("-Wvla")
  211. #define SIMDE_DIAGNOSTIC_DISABLE_VLA_ _Pragma("clang diagnostic ignored \"-Wvla\"")
  212. #elif HEDLEY_GCC_VERSION_CHECK(4,3,0)
  213. #define SIMDE_DIAGNOSTIC_DISABLE_VLA_ _Pragma("GCC diagnostic ignored \"-Wvla\"")
  214. #else
  215. #define SIMDE_DIAGNOSTIC_DISABLE_VLA_
  216. #endif
  217. /* If you add an unused attribute to a function and don't use it, clang
  218. * may emit this. */
  219. #if HEDLEY_HAS_WARNING("-Wused-but-marked-unused")
  220. #define SIMDE_DIAGNOSTIC_DISABLE_USED_BUT_MARKED_UNUSED_ _Pragma("clang diagnostic ignored \"-Wused-but-marked-unused\"")
  221. #else
  222. #define SIMDE_DIAGNOSTIC_DISABLE_USED_BUT_MARKED_UNUSED_
  223. #endif
  224. #if HEDLEY_HAS_WARNING("-Wpass-failed")
  225. #define SIMDE_DIAGNOSTIC_DISABLE_PASS_FAILED_ _Pragma("clang diagnostic ignored \"-Wpass-failed\"")
  226. #else
  227. #define SIMDE_DIAGNOSTIC_DISABLE_PASS_FAILED_
  228. #endif
  229. #if HEDLEY_HAS_WARNING("-Wpadded")
  230. #define SIMDE_DIAGNOSTIC_DISABLE_PADDED_ _Pragma("clang diagnostic ignored \"-Wpadded\"")
  231. #elif HEDLEY_MSVC_VERSION_CHECK(19,0,0) /* Likely goes back further */
  232. #define SIMDE_DIAGNOSTIC_DISABLE_PADDED_ __pragma(warning(disable:4324))
  233. #else
  234. #define SIMDE_DIAGNOSTIC_DISABLE_PADDED_
  235. #endif
  236. #if HEDLEY_HAS_WARNING("-Wzero-as-null-pointer-constant")
  237. #define SIMDE_DIAGNOSTIC_DISABLE_ZERO_AS_NULL_POINTER_CONSTANT_ _Pragma("clang diagnostic ignored \"-Wzero-as-null-pointer-constant\"")
  238. #else
  239. #define SIMDE_DIAGNOSTIC_DISABLE_ZERO_AS_NULL_POINTER_CONSTANT_
  240. #endif
  241. #if HEDLEY_HAS_WARNING("-Wold-style-cast")
  242. #define SIMDE_DIAGNOSTIC_DISABLE_OLD_STYLE_CAST_ _Pragma("clang diagnostic ignored \"-Wold-style-cast\"")
  243. #else
  244. #define SIMDE_DIAGNOSTIC_DISABLE_OLD_STYLE_CAST_
  245. #endif
  246. #if HEDLEY_HAS_WARNING("-Wcast-function-type") || HEDLEY_GCC_VERSION_CHECK(8,0,0)
  247. #define SIMDE_DIAGNOSTIC_DISABLE_CAST_FUNCTION_TYPE_ _Pragma("GCC diagnostic ignored \"-Wcast-function-type\"")
  248. #else
  249. #define SIMDE_DIAGNOSTIC_DISABLE_CAST_FUNCTION_TYPE_
  250. #endif
  251. /* clang will emit this warning when we use C99 extensions when not in
  252. * C99 mode, even though it does support this. In such cases we check
  253. * the compiler and version first, so we know it's not a problem. */
  254. #if HEDLEY_HAS_WARNING("-Wc99-extensions")
  255. #define SIMDE_DIAGNOSTIC_DISABLE_C99_EXTENSIONS_ _Pragma("clang diagnostic ignored \"-Wc99-extensions\"")
  256. #else
  257. #define SIMDE_DIAGNOSTIC_DISABLE_C99_EXTENSIONS_
  258. #endif
  259. /* Similar problm as above; we rely on some basic C99 support, but clang
  260. * has started warning obut this even in C17 mode with -Weverything. */
  261. #if HEDLEY_HAS_WARNING("-Wdeclaration-after-statement")
  262. #define SIMDE_DIAGNOSTIC_DISABLE_DECLARATION_AFTER_STATEMENT_ _Pragma("clang diagnostic ignored \"-Wdeclaration-after-statement\"")
  263. #else
  264. #define SIMDE_DIAGNOSTIC_DISABLE_DECLARATION_AFTER_STATEMENT_
  265. #endif
  266. /* https://github.com/simd-everywhere/simde/issues/277 */
  267. #if defined(HEDLEY_GCC_VERSION) && HEDLEY_GCC_VERSION_CHECK(4,6,0) && !HEDLEY_GCC_VERSION_CHECK(6,4,0) && defined(__cplusplus)
  268. #define SIMDE_DIAGNOSTIC_DISABLE_BUGGY_UNUSED_BUT_SET_VARIBALE_ _Pragma("GCC diagnostic ignored \"-Wunused-but-set-variable\"")
  269. #else
  270. #define SIMDE_DIAGNOSTIC_DISABLE_BUGGY_UNUSED_BUT_SET_VARIBALE_
  271. #endif
  272. /* This is the warning that you normally define _CRT_SECURE_NO_WARNINGS
  273. * to silence, but you have to do that before including anything and
  274. * that would require reordering includes. */
  275. #if defined(_MSC_VER)
  276. #define SIMDE_DIAGNOSTIC_DISABLE_ANNEX_K_ __pragma(warning(disable:4996))
  277. #else
  278. #define SIMDE_DIAGNOSTIC_DISABLE_ANNEX_K_
  279. #endif
  280. /* Some compilers, such as clang, may use `long long` for 64-bit
  281. * integers, but `long long` triggers a diagnostic with
  282. * -Wc++98-compat-pedantic which says 'long long' is incompatible with
  283. * C++98. */
  284. #if HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic")
  285. #if HEDLEY_HAS_WARNING("-Wc++11-long-long")
  286. #define SIMDE_DIAGNOSTIC_DISABLE_CPP98_COMPAT_PEDANTIC_ \
  287. _Pragma("clang diagnostic ignored \"-Wc++98-compat-pedantic\"") \
  288. _Pragma("clang diagnostic ignored \"-Wc++11-long-long\"")
  289. #else
  290. #define SIMDE_DIAGNOSTIC_DISABLE_CPP98_COMPAT_PEDANTIC_ _Pragma("clang diagnostic ignored \"-Wc++98-compat-pedantic\"")
  291. #endif
  292. #else
  293. #define SIMDE_DIAGNOSTIC_DISABLE_CPP98_COMPAT_PEDANTIC_
  294. #endif
  295. /* Some problem as above */
  296. #if HEDLEY_HAS_WARNING("-Wc++11-long-long")
  297. #define SIMDE_DIAGNOSTIC_DISABLE_CPP11_LONG_LONG_ _Pragma("clang diagnostic ignored \"-Wc++11-long-long\"")
  298. #else
  299. #define SIMDE_DIAGNOSTIC_DISABLE_CPP11_LONG_LONG_
  300. #endif
  301. /* emscripten emits this whenever stdin/stdout/stderr is used in a
  302. * macro. */
  303. #if HEDLEY_HAS_WARNING("-Wdisabled-macro-expansion")
  304. #define SIMDE_DIAGNOSTIC_DISABLE_DISABLED_MACRO_EXPANSION_ _Pragma("clang diagnostic ignored \"-Wdisabled-macro-expansion\"")
  305. #else
  306. #define SIMDE_DIAGNOSTIC_DISABLE_DISABLED_MACRO_EXPANSION_
  307. #endif
  308. /* Clang uses C11 generic selections to implement some AltiVec
  309. * functions, which triggers this diagnostic when not compiling
  310. * in C11 mode */
  311. #if HEDLEY_HAS_WARNING("-Wc11-extensions")
  312. #define SIMDE_DIAGNOSTIC_DISABLE_C11_EXTENSIONS_ _Pragma("clang diagnostic ignored \"-Wc11-extensions\"")
  313. #else
  314. #define SIMDE_DIAGNOSTIC_DISABLE_C11_EXTENSIONS_
  315. #endif
  316. /* Clang sometimes triggers this warning in macros in the AltiVec and
  317. * NEON headers, or due to missing functions. */
  318. #if HEDLEY_HAS_WARNING("-Wvector-conversion")
  319. #define SIMDE_DIAGNOSTIC_DISABLE_VECTOR_CONVERSION_ _Pragma("clang diagnostic ignored \"-Wvector-conversion\"")
  320. /* For NEON, the situation with -Wvector-conversion in clang < 10 is
  321. * bad enough that we just disable the warning altogether. On x86,
  322. * clang has similar issues on several sse4.2+ intrinsics before 3.8. */
  323. #if \
  324. (defined(SIMDE_ARCH_ARM) && SIMDE_DETECT_CLANG_VERSION_NOT(10,0,0)) || \
  325. SIMDE_DETECT_CLANG_VERSION_NOT(3,8,0)
  326. #define SIMDE_DIAGNOSTIC_DISABLE_BUGGY_VECTOR_CONVERSION_ SIMDE_DIAGNOSTIC_DISABLE_VECTOR_CONVERSION_
  327. #endif
  328. #else
  329. #define SIMDE_DIAGNOSTIC_DISABLE_VECTOR_CONVERSION_
  330. #endif
  331. #if !defined(SIMDE_DIAGNOSTIC_DISABLE_BUGGY_VECTOR_CONVERSION_)
  332. #define SIMDE_DIAGNOSTIC_DISABLE_BUGGY_VECTOR_CONVERSION_
  333. #endif
  334. /* Prior to 5.0, clang didn't support disabling diagnostics in
  335. * statement exprs. As a result, some macros we use don't
  336. * properly silence warnings. */
  337. #if SIMDE_DETECT_CLANG_VERSION_NOT(5,0,0) && HEDLEY_HAS_WARNING("-Wcast-qual") && HEDLEY_HAS_WARNING("-Wcast-align")
  338. #define SIMDE_DIAGNOSTIC_DISABLE_BUGGY_CASTS_ _Pragma("clang diagnostic ignored \"-Wcast-qual\"") _Pragma("clang diagnostic ignored \"-Wcast-align\"")
  339. #elif SIMDE_DETECT_CLANG_VERSION_NOT(5,0,0) && HEDLEY_HAS_WARNING("-Wcast-qual")
  340. #define SIMDE_DIAGNOSTIC_DISABLE_BUGGY_CASTS_ _Pragma("clang diagnostic ignored \"-Wcast-qual\"")
  341. #elif SIMDE_DETECT_CLANG_VERSION_NOT(5,0,0) && HEDLEY_HAS_WARNING("-Wcast-align")
  342. #define SIMDE_DIAGNOSTIC_DISABLE_BUGGY_CASTS_ _Pragma("clang diagnostic ignored \"-Wcast-align\"")
  343. #else
  344. #define SIMDE_DIAGNOSTIC_DISABLE_BUGGY_CASTS_
  345. #endif
  346. /* SLEEF triggers this a *lot* in their headers */
  347. #if HEDLEY_HAS_WARNING("-Wignored-qualifiers")
  348. #define SIMDE_DIAGNOSTIC_DISABLE_IGNORED_QUALIFIERS_ _Pragma("clang diagnostic ignored \"-Wignored-qualifiers\"")
  349. #elif HEDLEY_GCC_VERSION_CHECK(4,3,0)
  350. #define SIMDE_DIAGNOSTIC_DISABLE_IGNORED_QUALIFIERS_ _Pragma("GCC diagnostic ignored \"-Wignored-qualifiers\"")
  351. #else
  352. #define SIMDE_DIAGNOSTIC_DISABLE_IGNORED_QUALIFIERS_
  353. #endif
  354. /* GCC emits this under some circumstances when using __int128 */
  355. #if HEDLEY_GCC_VERSION_CHECK(4,8,0)
  356. #define SIMDE_DIAGNOSTIC_DISABLE_PEDANTIC_ _Pragma("GCC diagnostic ignored \"-Wpedantic\"")
  357. #else
  358. #define SIMDE_DIAGNOSTIC_DISABLE_PEDANTIC_
  359. #endif
  360. /* MSVC doesn't like (__assume(0), code) and will warn about code being
  361. * unreachable, but we want it there because not all compilers
  362. * understand the unreachable macro and will complain if it is missing.
  363. * I'm planning on adding a new macro to Hedley to handle this a bit
  364. * more elegantly, but until then... */
  365. #if defined(HEDLEY_MSVC_VERSION)
  366. #define SIMDE_DIAGNOSTIC_DISABLE_UNREACHABLE_ __pragma(warning(disable:4702))
  367. #elif defined(__clang__)
  368. #define SIMDE_DIAGNOSTIC_DISABLE_UNREACHABLE_ HEDLEY_PRAGMA(clang diagnostic ignored "-Wunreachable-code")
  369. #else
  370. #define SIMDE_DIAGNOSTIC_DISABLE_UNREACHABLE_
  371. #endif
  372. /* This is a false positive from GCC in a few places. */
  373. #if HEDLEY_GCC_VERSION_CHECK(4,7,0)
  374. #define SIMDE_DIAGNOSTIC_DISABLE_MAYBE_UNINITIAZILED_ _Pragma("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
  375. #else
  376. #define SIMDE_DIAGNOSTIC_DISABLE_MAYBE_UNINITIAZILED_
  377. #endif
  378. #if defined(SIMDE_ENABLE_NATIVE_ALIASES)
  379. #define SIMDE_DISABLE_UNWANTED_DIAGNOSTICS_NATIVE_ALIASES_ \
  380. SIMDE_DIAGNOSTIC_DISABLE_RESERVED_ID_MACRO_
  381. #else
  382. #define SIMDE_DISABLE_UNWANTED_DIAGNOSTICS_NATIVE_ALIASES_
  383. #endif
  384. /* Some native functions on E2K with instruction set < v6 are declared
  385. * as deprecated due to inefficiency. Still they are more efficient
  386. * than SIMDe implementation. So we're using them, and switching off
  387. * these deprecation warnings. */
  388. #if defined(HEDLEY_MCST_LCC_VERSION)
  389. # define SIMDE_LCC_DISABLE_DEPRECATED_WARNINGS _Pragma("diag_suppress 1215,1444")
  390. # define SIMDE_LCC_REVERT_DEPRECATED_WARNINGS _Pragma("diag_default 1215,1444")
  391. #else
  392. # define SIMDE_LCC_DISABLE_DEPRECATED_WARNINGS
  393. # define SIMDE_LCC_REVERT_DEPRECATED_WARNINGS
  394. #endif
  395. #define SIMDE_DISABLE_UNWANTED_DIAGNOSTICS \
  396. HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION \
  397. SIMDE_DISABLE_UNWANTED_DIAGNOSTICS_NATIVE_ALIASES_ \
  398. SIMDE_DIAGNOSTIC_DISABLE_PSABI_ \
  399. SIMDE_DIAGNOSTIC_DISABLE_NO_EMMS_INSTRUCTION_ \
  400. SIMDE_DIAGNOSTIC_DISABLE_SIMD_PRAGMA_DEPRECATED_ \
  401. SIMDE_DIAGNOSTIC_DISABLE_CONDITIONAL_UNINITIALIZED_ \
  402. SIMDE_DIAGNOSTIC_DISABLE_DECLARATION_AFTER_STATEMENT_ \
  403. SIMDE_DIAGNOSTIC_DISABLE_FLOAT_EQUAL_ \
  404. SIMDE_DIAGNOSTIC_DISABLE_NON_CONSTANT_AGGREGATE_INITIALIZER_ \
  405. SIMDE_DIAGNOSTIC_DISABLE_EXTRA_SEMI_ \
  406. SIMDE_DIAGNOSTIC_DISABLE_VLA_ \
  407. SIMDE_DIAGNOSTIC_DISABLE_USED_BUT_MARKED_UNUSED_ \
  408. SIMDE_DIAGNOSTIC_DISABLE_PASS_FAILED_ \
  409. SIMDE_DIAGNOSTIC_DISABLE_CPP98_COMPAT_PEDANTIC_ \
  410. SIMDE_DIAGNOSTIC_DISABLE_CPP11_LONG_LONG_ \
  411. SIMDE_DIAGNOSTIC_DISABLE_BUGGY_UNUSED_BUT_SET_VARIBALE_ \
  412. SIMDE_DIAGNOSTIC_DISABLE_BUGGY_CASTS_ \
  413. SIMDE_DIAGNOSTIC_DISABLE_BUGGY_VECTOR_CONVERSION_ \
  414. SIMDE_DIAGNOSTIC_DISABLE_RESERVED_ID_
  415. #endif /* !defined(SIMDE_DIAGNOSTIC_H) */