Skip to content

Commit a75c722

Browse files
committed
diagnostic: move diagnostic detction to new simde-diagnostic.h
It was taking up a bit too much of simde-common.h, and I want to increase the amount of documentation on these to clearly explain why each diagnostic is disabled.
1 parent c1e5d25 commit a75c722

File tree

4 files changed

+285
-217
lines changed

4 files changed

+285
-217
lines changed

simde/check.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# define SIMDE_NDEBUG 1
1818
#endif
1919

20+
#include "hedley.h"
2021
#include <stdint.h>
2122

2223
#if !defined(_WIN32)
@@ -58,23 +59,21 @@
5859

5960
# include "debug-trap.h"
6061

61-
# if HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic")
62-
# pragma clang diagnostic push
63-
# pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
64-
# endif
62+
HEDLEY_DIAGNOSTIC_PUSH
63+
SIMDE_DIAGNOSTIC_DISABLE_VARIADIC_MACROS_
6564
# if defined(EOF)
6665
# define simde_errorf(format, ...) (fprintf(stderr, format, __VA_ARGS__), abort())
6766
# else
6867
# define simde_errorf(format, ...) (simde_trap())
6968
# endif
70-
# if HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic")
71-
# pragma clang diagnostic pop
72-
# endif
69+
HEDLEY_DIAGNOSTIC_POP
7370
#endif
7471

7572
#define simde_error(msg) simde_errorf("%s", msg)
7673

77-
#if defined(SIMDE_NDEBUG)
74+
#if defined(SIMDE_NDEBUG) || \
75+
(defined(__cplusplus) && (__cplusplus < 201103L)) || \
76+
(defined(__STDC__) && (__STDC__ < 199901L))
7877
# if defined(SIMDE_CHECK_FAIL_DEFINED)
7978
# define simde_assert(expr)
8079
# else

simde/simde-common.h

Lines changed: 12 additions & 194 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
#include "simde-arch.h"
3838
#include "simde-features.h"
39+
#include "simde-diagnostic.h"
3940

4041
#include <stddef.h>
4142
#include <stdint.h>
@@ -204,21 +205,25 @@
204205
different. This macro is just an abstraction over them. Note that
205206
elem_size is in bits but vec_size is in bytes. */
206207
# if !defined(SIMDE_NO_SHUFFLE_VECTOR) && defined(SIMDE_VECTOR_SUBSCRIPT)
208+
HEDLEY_DIAGNOSTIC_PUSH
209+
/* We don't care about -Wvariadic-macros; all compilers that support
210+
* shufflevector/shuffle support them. */
211+
# if HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic")
212+
# pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
213+
# endif
214+
# if HEDLEY_HAS_WARNING("-Wvariadic-macros") || HEDLEY_GCC_VERSION_CHECK(4,0,0)
215+
# pragma GCC diagnostic ignored "-Wvariadic-macros"
216+
# endif
217+
207218
# if HEDLEY_HAS_BUILTIN(__builtin_shufflevector)
208-
# if HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic")
209-
# pragma clang diagnostic push
210-
# pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
211-
# endif
212219
# define SIMDE_SHUFFLE_VECTOR_(elem_size, vec_size, a, b, ...) __builtin_shufflevector(a, b, __VA_ARGS__)
213-
# if HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic")
214-
# pragma clang diagnostic pop
215-
# endif
216220
# elif HEDLEY_GCC_HAS_BUILTIN(__builtin_shuffle,4,7,0) && !defined(__INTEL_COMPILER)
217221
# define SIMDE_SHUFFLE_VECTOR_(elem_size, vec_size, a, b, ...) (__extension__ ({ \
218222
int##elem_size##_t SIMDE_VECTOR(vec_size) simde_shuffle_ = { __VA_ARGS__ }; \
219223
__builtin_shuffle(a, b, simde_shuffle_); \
220224
}))
221225
# endif
226+
HEDLEY_DIAGNOSTIC_POP
222227
# endif
223228

224229
/* TODO: this actually works on XL C/C++ without SIMDE_VECTOR_SUBSCRIPT
@@ -531,193 +536,6 @@ typedef SIMDE_FLOAT64_TYPE simde_float64;
531536
# define SIMDE_ACCURACY_PREFERENCE 1
532537
#endif
533538

534-
/**********************************************************************
535-
* Diagnostics to disable.
536-
*
537-
* It's usually better to resolve the warning by changing the code,
538-
* but sometimes that's not practical.
539-
*/
540-
541-
/* This is only to help us implement functions like _mm_undefined_ps. */
542-
#if defined(SIMDE_DIAGNOSTIC_DISABLE_UNINITIALIZED_)
543-
# undef SIMDE_DIAGNOSTIC_DISABLE_UNINITIALIZED_
544-
#endif
545-
#if HEDLEY_HAS_WARNING("-Wuninitialized")
546-
# define SIMDE_DIAGNOSTIC_DISABLE_UNINITIALIZED_ _Pragma("clang diagnostic ignored \"-Wuninitialized\"")
547-
#elif HEDLEY_GCC_VERSION_CHECK(4,2,0)
548-
# define SIMDE_DIAGNOSTIC_DISABLE_UNINITIALIZED_ _Pragma("GCC diagnostic ignored \"-Wuninitialized\"")
549-
#elif HEDLEY_PGI_VERSION_CHECK(19,10,0)
550-
# define SIMDE_DIAGNOSTIC_DISABLE_UNINITIALIZED_ _Pragma("diag_suppress 549")
551-
#elif HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)
552-
# define SIMDE_DIAGNOSTIC_DISABLE_UNINITIALIZED_ _Pragma("error_messages(off,SEC_UNINITIALIZED_MEM_READ,SEC_UNDEFINED_RETURN_VALUE,unassigned)")
553-
#elif HEDLEY_SUNPRO_VERSION_CHECK(5,14,0)
554-
# define SIMDE_DIAGNOSTIC_DISABLE_UNINITIALIZED_ _Pragma("error_messages(off,SEC_UNINITIALIZED_MEM_READ,SEC_UNDEFINED_RETURN_VALUE)")
555-
#elif HEDLEY_SUNPRO_VERSION_CHECK(5,12,0) && defined(__cplusplus)
556-
# define SIMDE_DIAGNOSTIC_DISABLE_UNINITIALIZED_ _Pragma("error_messages(off,unassigned)")
557-
#elif \
558-
HEDLEY_TI_VERSION_CHECK(16,9,9) || \
559-
HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \
560-
HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \
561-
HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,2)
562-
# define SIMDE_DIAGNOSTIC_DISABLE_UNINITIALIZED_ _Pragma("diag_suppress 551")
563-
#elif HEDLEY_INTEL_VERSION_CHECK(13,0,0)
564-
# define SIMDE_DIAGNOSTIC_DISABLE_UNINITIALIZED_ _Pragma("warning(disable:592)")
565-
#elif HEDLEY_MSVC_VERSION_CHECK(19,0,0) && !defined(__MSVC_RUNTIME_CHECKS)
566-
# define SIMDE_DIAGNOSTIC_DISABLE_UNINITIALIZED_ __pragma(warning(disable:4700))
567-
#endif
568-
569-
/* GCC emits a lot of "notes" about the ABI being different for things
570-
* in newer versions of GCC. We don't really care because all our
571-
* functions are inlined and don't generate ABI. */
572-
#if HEDLEY_GCC_VERSION_CHECK(7,0,0)
573-
# define SIMDE_DIAGNOSTIC_DISABLE_PSABI_ _Pragma("GCC diagnostic ignored \"-Wpsabi\"")
574-
#else
575-
# define SIMDE_DIAGNOSTIC_DISABLE_PSABI_
576-
#endif
577-
578-
/* Since MMX uses x87 FP registers, you're supposed to call _mm_empty()
579-
* after each MMX function before any floating point instructions.
580-
* Some compilers warn about functions which use MMX functions but
581-
* don't call _mm_empty(). However, since SIMDe is implementyng the
582-
* MMX API we shouldn't be calling _mm_empty(); we leave it to the
583-
* caller to invoke simde_mm_empty(). */
584-
#if HEDLEY_INTEL_VERSION_CHECK(19,0,0)
585-
# define SIMDE_DIAGNOSTIC_DISABLE_NO_EMMS_INSTRUCTION_ _Pragma("warning(disable:13200 13203)")
586-
#elif defined(HEDLEY_MSVC_VERSION)
587-
# define SIMDE_DIAGNOSTIC_DISABLE_NO_EMMS_INSTRUCTION_ __pragma(warning(disable:4799))
588-
#else
589-
# define SIMDE_DIAGNOSTIC_DISABLE_NO_EMMS_INSTRUCTION_
590-
#endif
591-
592-
/* Intel is pushing people to use OpenMP SIMD instead of Cilk+, so they
593-
* emit a diagnostic if you use #pragma simd instead of
594-
* #pragma omp simd. SIMDe supports OpenMP SIMD, you just need to
595-
* compile with -qopenmp or -qopenmp-simd and define
596-
* SIMDE_ENABLE_OPENMP. Cilk+ is just a fallback. */
597-
#if HEDLEY_INTEL_VERSION_CHECK(18,0,0)
598-
# define SIMDE_DIAGNOSTIC_DISABLE_SIMD_PRAGMA_DEPRECATED_ _Pragma("warning(disable:3948)")
599-
#else
600-
# define SIMDE_DIAGNOSTIC_DISABLE_SIMD_PRAGMA_DEPRECATED_
601-
#endif
602-
603-
#if \
604-
defined(HEDLEY_MSVC_VERSION)
605-
# define SIMDE_DIAGNOSTIC_DISABLE_NON_CONSTANT_AGGREGATE_INITIALIZER_ __pragma(warning(disable:4204))
606-
#else
607-
# define SIMDE_DIAGNOSTIC_DISABLE_NON_CONSTANT_AGGREGATE_INITIALIZER_
608-
#endif
609-
610-
/* This warning needs a lot of work. It is triggered if all you do is
611-
* pass the value to memcpy/__builtin_memcpy, or if you initialize a
612-
* member of the union, even if that member takes up the entire union.
613-
* Last tested with clang-10, hopefully things will improve in the
614-
* future; if clang fixes this I'd love to enable it. */
615-
#if \
616-
HEDLEY_HAS_WARNING("-Wconditional-uninitialized")
617-
# define SIMDE_DIAGNOSTIC_DISABLE_CONDITIONAL_UNINITIALIZED_ _Pragma("clang diagnostic ignored \"-Wconditional-uninitialized\"")
618-
#else
619-
# define SIMDE_DIAGNOSTIC_DISABLE_CONDITIONAL_UNINITIALIZED_
620-
#endif
621-
622-
/* This warning is meant to catch things like `0.3 + 0.4 == 0.7`, which
623-
* will is false. However, SIMDe uses these operations exclusively
624-
* for things like _mm_cmpeq_ps, for which we really do want to check
625-
* for equality (or inequality).
626-
*
627-
* If someone wants to put together a SIMDE_FLOAT_EQUAL(a, op, b) macro
628-
* which just wraps a check in some code do disable this diagnostic I'd
629-
* be happy to accept it. */
630-
#if \
631-
HEDLEY_HAS_WARNING("-Wfloat-equal") || \
632-
HEDLEY_GCC_VERSION_CHECK(3,0,0)
633-
# define SIMDE_DIAGNOSTIC_DISABLE_FLOAT_EQUAL_ _Pragma("GCC diagnostic ignored \"-Wfloat-equal\"")
634-
#else
635-
# define SIMDE_DIAGNOSTIC_DISABLE_FLOAT_EQUAL_
636-
#endif
637-
638-
#if HEDLEY_HAS_WARNING("-Wextra-semi")
639-
# define SIMDE_DIAGNOSTIC_DISABLE_EXTRA_SEMI_ _Pragma("clang diagnostic ignored \"-Wextra-semi\"")
640-
#elif HEDLEY_GCC_VERSION_CHECK(8,1,0) && defined(__cplusplus)
641-
# define SIMDE_DIAGNOSTIC_DISABLE_EXTRA_SEMI_ _Pragma("GCC diagnostic ignored \"-Wextra-semi\"")
642-
#else
643-
# define SIMDE_DIAGNOSTIC_DISABLE_EXTRA_SEMI_
644-
#endif
645-
646-
#if HEDLEY_HAS_WARNING("-Wdouble-promotion")
647-
# define SIMDE_DIAGNOSTIC_DISABLE_DOUBLE_PROMOTION_ _Pragma("clang diagnostic ignored \"-Wdouble-promotion\"")
648-
#else
649-
# define SIMDE_DIAGNOSTIC_DISABLE_DOUBLE_PROMOTION_
650-
#endif
651-
652-
/* Several compilers treat conformant array parameters as VLAs. */
653-
#if HEDLEY_HAS_WARNING("-Wvla")
654-
# define SIMDE_DIAGNOSTIC_DISABLE_VLA_ _Pragma("clang diagnostic ignored \"-Wvla\"")
655-
#elif HEDLEY_GCC_VERSION_CHECK(4,3,0)
656-
# define SIMDE_DIAGNOSTIC_DISABLE_VLA_ _Pragma("GCC diagnostic ignored \"-Wvla\"")
657-
#else
658-
# define SIMDE_DIAGNOSTIC_DISABLE_VLA_
659-
#endif
660-
661-
#if HEDLEY_HAS_WARNING("-Wvla")
662-
# define SIMDE_DIAGNOSTIC_DISABLE_VLA_ _Pragma("clang diagnostic ignored \"-Wvla\"")
663-
#elif HEDLEY_GCC_VERSION_CHECK(4,3,0)
664-
# define SIMDE_DIAGNOSTIC_DISABLE_VLA_ _Pragma("GCC diagnostic ignored \"-Wvla\"")
665-
#else
666-
# define SIMDE_DIAGNOSTIC_DISABLE_VLA_
667-
#endif
668-
669-
#if HEDLEY_HAS_WARNING("-Wused-but-marked-unused")
670-
# define SIMDE_DIAGNOSTIC_DISABLE_USED_BUT_MARKED_UNUSED_ _Pragma("clang diagnostic ignored \"-Wused-but-marked-unused\"")
671-
#else
672-
# define SIMDE_DIAGNOSTIC_DISABLE_USED_BUT_MARKED_UNUSED_
673-
#endif
674-
675-
#if HEDLEY_HAS_WARNING("-Wunused-function")
676-
# define SIMDE_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION_ _Pragma("clang diagnostic ignored \"-Wunused-function\"")
677-
#elif HEDLEY_GCC_VERSION_CHECK(3,4,0)
678-
# define SIMDE_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION_ _Pragma("GCC diagnostic ignored \"-Wunused-function\"")
679-
#else
680-
# define SIMDE_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION_
681-
#endif
682-
683-
#if HEDLEY_HAS_WARNING("-Wpass-failed")
684-
# define SIMDE_DIAGNOSTIC_DISABLE_PASS_FAILED_ _Pragma("clang diagnostic ignored \"-Wpass-failed\"")
685-
#else
686-
# define SIMDE_DIAGNOSTIC_DISABLE_PASS_FAILED_
687-
#endif
688-
689-
/* https://github.com/nemequ/simde/issues/277 */
690-
#if defined(HEDLEY_GCC_VERSION) && HEDLEY_GCC_VERSION_CHECK(4,6,0) && !HEDLEY_GCC_VERSION_CHECK(6,0,0) && defined(__cplusplus)
691-
#define SIMDE_DIAGNOSTIC_DISABLE_BUGGY_UNUSED_BUT_SET_VARIBALE _Pragma("GCC diagnostic ignored \"-Wunused-but-set-variable\"")
692-
#else
693-
#define SIMDE_DIAGNOSTIC_DISABLE_BUGGY_UNUSED_BUT_SET_VARIBALE
694-
#endif
695-
696-
/* Some compilers, such as clang, may use `long long` for 64-bit
697-
* integers, but `long long` triggers a diagnostic with
698-
* -Wc++98-compat-pedantic which says 'long long' is incompatible with
699-
* C++98. */
700-
#if HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic")
701-
#define SIMDE_DIAGNOSTIC_DISABLE_CPP98_COMPAT_PEDANTIC _Pragma("clang diagnostic ignored \"-Wc++98-compat-pedantic\"")
702-
#else
703-
#define SIMDE_DIAGNOSTIC_DISABLE_CPP98_COMPAT_PEDANTIC
704-
#endif
705-
706-
#define SIMDE_DISABLE_UNWANTED_DIAGNOSTICS \
707-
SIMDE_DIAGNOSTIC_DISABLE_PSABI_ \
708-
SIMDE_DIAGNOSTIC_DISABLE_NO_EMMS_INSTRUCTION_ \
709-
SIMDE_DIAGNOSTIC_DISABLE_SIMD_PRAGMA_DEPRECATED_ \
710-
SIMDE_DIAGNOSTIC_DISABLE_CONDITIONAL_UNINITIALIZED_ \
711-
SIMDE_DIAGNOSTIC_DISABLE_FLOAT_EQUAL_ \
712-
SIMDE_DIAGNOSTIC_DISABLE_NON_CONSTANT_AGGREGATE_INITIALIZER_ \
713-
SIMDE_DIAGNOSTIC_DISABLE_EXTRA_SEMI_ \
714-
SIMDE_DIAGNOSTIC_DISABLE_VLA_ \
715-
SIMDE_DIAGNOSTIC_DISABLE_USED_BUT_MARKED_UNUSED_ \
716-
SIMDE_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION_ \
717-
SIMDE_DIAGNOSTIC_DISABLE_PASS_FAILED_ \
718-
SIMDE_DIAGNOSTIC_DISABLE_CPP98_COMPAT_PEDANTIC \
719-
SIMDE_DIAGNOSTIC_DISABLE_BUGGY_UNUSED_BUT_SET_VARIBALE
720-
721539
#if defined(__STDC_HOSTED__)
722540
# define SIMDE_STDC_HOSTED __STDC_HOSTED__
723541
#else

0 commit comments

Comments
 (0)