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