Eigen  5.0.1-dev+master
 
Loading...
Searching...
No Matches
DisableStupidWarnings.h
1// SPDX-FileCopyrightText: The Eigen Authors
2// SPDX-License-Identifier: MPL-2.0
3
4#ifndef EIGEN_WARNINGS_DISABLED
5#define EIGEN_WARNINGS_DISABLED
6
7#if defined(_MSC_VER)
8// 4100 - unreferenced formal parameter (occurred e.g. in aligned_allocator::destroy(pointer p))
9// 4101 - unreferenced local variable
10// 4127 - conditional expression is constant
11// 4181 - qualifier applied to reference type ignored
12// 4211 - nonstandard extension used : redefined extern to static
13// 4244 - 'argument' : conversion from 'type1' to 'type2', possible loss of data
14// 4324 - structure was padded due to declspec(align())
15// 4503 - decorated name length exceeded, name was truncated
16// 4512 - assignment operator could not be generated
17// 4522 - 'class' : multiple assignment operators specified
18// 4700 - uninitialized local variable 'xyz' used
19// 4714 - function marked as __forceinline not inlined
20// 4717 - 'function' : recursive on all control paths, function will cause runtime stack overflow
21// 4800 - 'type' : forcing value to bool 'true' or 'false' (performance warning)
22#pragma warning(push)
23#pragma warning(disable : 4100 4101 4127 4181 4211 4244 4324 4503 4512 4522 4700 4714 4717 4800)
24// We currently rely on has_denorm in tests, and need it defined correctly for half/bfloat16.
25#ifndef _SILENCE_CXX23_DENORM_DEPRECATION_WARNING
26#define EIGEN_REENABLE_CXX23_DENORM_DEPRECATION_WARNING 1
27#define _SILENCE_CXX23_DENORM_DEPRECATION_WARNING
28#endif
29
30#elif defined __INTEL_COMPILER
31// 2196 - routine is both "inline" and "noinline" ("noinline" assumed)
32// ICC 12 generates this warning even without any inline keyword, when defining class methods 'inline' i.e.
33// inside of class body typedef that may be a reference type.
34// 279 - controlling expression is constant
35// ICC 12 generates this warning on assert(constant_expression_depending_on_template_params) and frankly this is
36// a legitimate use case.
37// 1684 - conversion from pointer to same-sized integral type (potential portability problem)
38// 2259 - non-pointer conversion from "Eigen::Index={ptrdiff_t={long}}" to "int" may lose significant bits
39#pragma warning push
40#pragma warning disable 2196 279 1684 2259
41
42#elif defined __clang__
43#pragma clang diagnostic push
44#if defined(__has_warning)
45// -Wconstant-logical-operand - warning: use of logical && with constant operand; switch to bitwise & or remove constant
46// this is really a stupid warning as it warns on compile-time expressions involving enums
47#if __has_warning("-Wconstant-logical-operand")
48#pragma clang diagnostic ignored "-Wconstant-logical-operand"
49#endif
50#if __has_warning("-Wimplicit-int-float-conversion")
51#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
52#endif
53#if (defined(__ALTIVEC__) || defined(__VSX__)) && (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 201112L))
54// warning: generic selections are a C11-specific feature
55// ignoring warnings thrown at vec_ctf in Altivec/PacketMath.h
56#if __has_warning("-Wc11-extensions")
57#pragma clang diagnostic ignored "-Wc11-extensions"
58#endif
59#endif
60#endif
61
62#elif defined __GNUC__ && !defined(__FUJITSU)
63
64#pragma GCC diagnostic push
65// g++ warns about local variables shadowing member functions, which is too strict
66#pragma GCC diagnostic ignored "-Wshadow"
67#if __GNUC__ >= 6
68#pragma GCC diagnostic ignored "-Wignored-attributes"
69#endif
70#if __GNUC__ == 7
71// See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89325
72#pragma GCC diagnostic ignored "-Wattributes"
73#endif
74#endif
75
76#if defined __NVCC__ && defined __CUDACC__
77// MSVC does not support the _Pragma keyword, so we use Microsoft's __pragma extension.
78#if defined _MSC_VER
79#define EIGEN_MAKE_PRAGMA(X) __pragma(#X)
80#else
81#define EIGEN_MAKE_PRAGMA(X) _Pragma(#X)
82#endif
83#if defined __NVCC_DIAG_PRAGMA_SUPPORT__
84#define EIGEN_NV_DIAG_SUPPRESS(X) EIGEN_MAKE_PRAGMA(nv_diag_suppress X)
85#else
86#define EIGEN_NV_DIAG_SUPPRESS(X) EIGEN_MAKE_PRAGMA(diag_suppress X)
87#endif
88
89EIGEN_NV_DIAG_SUPPRESS(boolean_controlling_expr_is_constant)
90// Disable the "statement is unreachable" message
91EIGEN_NV_DIAG_SUPPRESS(code_is_unreachable)
92// Disable the "dynamic initialization in unreachable code" message
93EIGEN_NV_DIAG_SUPPRESS(initialization_not_reachable)
94// Disable the "invalid error number" message that we get with older versions of nvcc
95EIGEN_NV_DIAG_SUPPRESS(1222)
96// Disable the "calling a __host__ function from a __host__ __device__ function is not allowed" messages (yes, there are
97// many of them and they seem to change with every version of the compiler)
98EIGEN_NV_DIAG_SUPPRESS(2527)
99EIGEN_NV_DIAG_SUPPRESS(2529)
100EIGEN_NV_DIAG_SUPPRESS(2651)
101EIGEN_NV_DIAG_SUPPRESS(2653)
102EIGEN_NV_DIAG_SUPPRESS(2668)
103EIGEN_NV_DIAG_SUPPRESS(2669)
104EIGEN_NV_DIAG_SUPPRESS(2670)
105EIGEN_NV_DIAG_SUPPRESS(2671)
106EIGEN_NV_DIAG_SUPPRESS(2735)
107EIGEN_NV_DIAG_SUPPRESS(2737)
108EIGEN_NV_DIAG_SUPPRESS(2739)
109EIGEN_NV_DIAG_SUPPRESS(2885)
110EIGEN_NV_DIAG_SUPPRESS(2888)
111EIGEN_NV_DIAG_SUPPRESS(2976)
112EIGEN_NV_DIAG_SUPPRESS(2979)
113EIGEN_NV_DIAG_SUPPRESS(20011)
114EIGEN_NV_DIAG_SUPPRESS(20014)
115// Disable the "// __device__ annotation is ignored on a function(...) that is
116// explicitly defaulted on its first declaration" message.
117// The __device__ annotation seems to actually be needed in some cases,
118// otherwise resulting in kernel runtime errors.
119EIGEN_NV_DIAG_SUPPRESS(2886)
120EIGEN_NV_DIAG_SUPPRESS(2929)
121EIGEN_NV_DIAG_SUPPRESS(2977)
122EIGEN_NV_DIAG_SUPPRESS(20012)
123#undef EIGEN_NV_DIAG_SUPPRESS
124#undef EIGEN_MAKE_PRAGMA
125#endif
126
127#else
128// warnings already disabled:
129#ifndef EIGEN_WARNINGS_DISABLED_2
130#define EIGEN_WARNINGS_DISABLED_2
131#elif defined(EIGEN_INTERNAL_DEBUGGING)
132#error "Do not include \"DisableStupidWarnings.h\" recursively more than twice!"
133#endif
134
135#endif // not EIGEN_WARNINGS_DISABLED