DisableStupidWarnings.h
Go to the documentation of this file.
1 #ifndef EIGEN_WARNINGS_DISABLED
2 #define EIGEN_WARNINGS_DISABLED
3 
4 #if defined(_MSC_VER)
5 // 4100 - unreferenced formal parameter (occurred e.g. in aligned_allocator::destroy(pointer p))
6 // 4101 - unreferenced local variable
7 // 4127 - conditional expression is constant
8 // 4181 - qualifier applied to reference type ignored
9 // 4211 - nonstandard extension used : redefined extern to static
10 // 4244 - 'argument' : conversion from 'type1' to 'type2', possible loss of data
11 // 4273 - QtAlignedMalloc, inconsistent DLL linkage
12 // 4324 - structure was padded due to declspec(align())
13 // 4503 - decorated name length exceeded, name was truncated
14 // 4512 - assignment operator could not be generated
15 // 4522 - 'class' : multiple assignment operators specified
16 // 4700 - uninitialized local variable 'xyz' used
17 // 4714 - function marked as __forceinline not inlined
18 // 4717 - 'function' : recursive on all control paths, function will cause runtime stack overflow
19 // 4800 - 'type' : forcing value to bool 'true' or 'false' (performance warning)
20 #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS
21 #pragma warning(push)
22 #endif
23 #pragma warning(disable : 4100 4101 4127 4181 4211 4244 4273 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 #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS
40 #pragma warning push
41 #endif
42 #pragma warning disable 2196 279 1684 2259
43 
44 #elif defined __clang__
45 #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS
46 #pragma clang diagnostic push
47 #endif
48 #if defined(__has_warning)
49 // -Wconstant-logical-operand - warning: use of logical && with constant operand; switch to bitwise & or remove constant
50 // this is really a stupid warning as it warns on compile-time expressions involving enums
51 #if __has_warning("-Wconstant-logical-operand")
52 #pragma clang diagnostic ignored "-Wconstant-logical-operand"
53 #endif
54 #if __has_warning("-Wimplicit-int-float-conversion")
55 #pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
56 #endif
57 #if (defined(__ALTIVEC__) || defined(__VSX__)) && (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 201112L))
58 // warning: generic selections are a C11-specific feature
59 // ignoring warnings thrown at vec_ctf in Altivec/PacketMath.h
60 #if __has_warning("-Wc11-extensions")
61 #pragma clang diagnostic ignored "-Wc11-extensions"
62 #endif
63 #endif
64 #endif
65 
66 #elif defined __GNUC__ && !defined(__FUJITSU)
67 
68 #if (!defined(EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS)) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
69 #pragma GCC diagnostic push
70 #endif
71 // g++ warns about local variables shadowing member functions, which is too strict
72 #pragma GCC diagnostic ignored "-Wshadow"
73 #if __GNUC__ == 4 && __GNUC_MINOR__ < 8
74 // Until g++-4.7 there are warnings when comparing unsigned int vs 0, even in templated functions:
75 #pragma GCC diagnostic ignored "-Wtype-limits"
76 #endif
77 #if __GNUC__ >= 6
78 #pragma GCC diagnostic ignored "-Wignored-attributes"
79 #endif
80 #if __GNUC__ == 7
81 // See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89325
82 #pragma GCC diagnostic ignored "-Wattributes"
83 #endif
84 #endif
85 
86 #if defined __NVCC__ && defined __CUDACC__
87 // MSVC 14.16 (required by CUDA 9.*) does not support the _Pragma keyword, so
88 // we instead use Microsoft's __pragma extension.
89 #if defined _MSC_VER
90 #define EIGEN_MAKE_PRAGMA(X) __pragma(#X)
91 #else
92 #define EIGEN_MAKE_PRAGMA(X) _Pragma(#X)
93 #endif
94 #if defined __NVCC_DIAG_PRAGMA_SUPPORT__
95 #define EIGEN_NV_DIAG_SUPPRESS(X) EIGEN_MAKE_PRAGMA(nv_diag_suppress X)
96 #else
97 #define EIGEN_NV_DIAG_SUPPRESS(X) EIGEN_MAKE_PRAGMA(diag_suppress X)
98 #endif
99 
100 EIGEN_NV_DIAG_SUPPRESS(boolean_controlling_expr_is_constant)
101 // Disable the "statement is unreachable" message
102 EIGEN_NV_DIAG_SUPPRESS(code_is_unreachable)
103 // Disable the "dynamic initialization in unreachable code" message
104 EIGEN_NV_DIAG_SUPPRESS(initialization_not_reachable)
105 // Disable the "invalid error number" message that we get with older versions of nvcc
106 EIGEN_NV_DIAG_SUPPRESS(1222)
107 // Disable the "calling a __host__ function from a __host__ __device__ function is not allowed" messages (yes, there are
108 // many of them and they seem to change with every version of the compiler)
109 EIGEN_NV_DIAG_SUPPRESS(2527)
110 EIGEN_NV_DIAG_SUPPRESS(2529)
111 EIGEN_NV_DIAG_SUPPRESS(2651)
112 EIGEN_NV_DIAG_SUPPRESS(2653)
113 EIGEN_NV_DIAG_SUPPRESS(2668)
114 EIGEN_NV_DIAG_SUPPRESS(2669)
115 EIGEN_NV_DIAG_SUPPRESS(2670)
116 EIGEN_NV_DIAG_SUPPRESS(2671)
117 EIGEN_NV_DIAG_SUPPRESS(2735)
118 EIGEN_NV_DIAG_SUPPRESS(2737)
119 EIGEN_NV_DIAG_SUPPRESS(2739)
120 EIGEN_NV_DIAG_SUPPRESS(2885)
121 EIGEN_NV_DIAG_SUPPRESS(2888)
122 EIGEN_NV_DIAG_SUPPRESS(2976)
123 EIGEN_NV_DIAG_SUPPRESS(2979)
124 EIGEN_NV_DIAG_SUPPRESS(20011)
125 EIGEN_NV_DIAG_SUPPRESS(20014)
126 // Disable the "// __device__ annotation is ignored on a function(...) that is
127 // explicitly defaulted on its first declaration" message.
128 // The __device__ annotation seems to actually be needed in some cases,
129 // otherwise resulting in kernel runtime errors.
130 EIGEN_NV_DIAG_SUPPRESS(2886)
131 EIGEN_NV_DIAG_SUPPRESS(2929)
132 EIGEN_NV_DIAG_SUPPRESS(2977)
133 EIGEN_NV_DIAG_SUPPRESS(20012)
134 #undef EIGEN_NV_DIAG_SUPPRESS
135 #undef EIGEN_MAKE_PRAGMA
136 #endif
137 
138 #else
139 // warnings already disabled:
140 #ifndef EIGEN_WARNINGS_DISABLED_2
141 #define EIGEN_WARNINGS_DISABLED_2
142 #elif defined(EIGEN_INTERNAL_DEBUGGING)
143 #error "Do not include \"DisableStupidWarnings.h\" recursively more than twice!"
144 #endif
145 
146 #endif // not EIGEN_WARNINGS_DISABLED