Welcome to mirror list, hosted at ThFree Co, Russian Federation.

BLI_strict_flags.h « blenlib « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ab7aacc4d2d32015a57707ea748f850a06928ce0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#pragma once

/** \file
 * \ingroup bli
 * \brief Strict compiler flags for areas of code we want
 * to ensure don't do conversions without us knowing about it.
 */

#ifdef __GNUC__
#  if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 /* gcc4.6+ only */
#    pragma GCC diagnostic error "-Wsign-compare"
#  endif
#  if __GNUC__ >= 6 /* gcc6+ only */
#    pragma GCC diagnostic error "-Wconversion"
#  endif
#  if (__GNUC__ * 100 + __GNUC_MINOR__) >= 408
/* gcc4.8+ only (behavior changed to ignore globals). */
#    pragma GCC diagnostic error "-Wshadow"
/* older gcc changed behavior with ternary */
#    pragma GCC diagnostic error "-Wsign-conversion"
#  endif
/* pedantic gives too many issues, developers can define this for own use */
#  ifdef WARN_PEDANTIC
#    pragma GCC diagnostic error "-Wpedantic"
#    ifdef __clang__ /* pedantic causes clang error */
#      pragma GCC diagnostic ignored "-Wlanguage-extension-token"
#    endif
#  endif
#endif

#ifdef _MSC_VER
/* While regular clang defines __GNUC__ and is handled by the code above, clang-cl does not and
 * needs to be handled separately. */
#  ifdef __clang__
#    pragma clang diagnostic error "-Wsign-conversion"
#    pragma clang diagnostic error "-Wsign-compare"
#    pragma clang diagnostic error "-Wimplicit-float-conversion"
#    pragma clang diagnostic error "-Wimplicit-int-conversion"
#    pragma clang diagnostic error "-Wimplicit-int"
#    pragma clang diagnostic error "-Wshadow"
/* Normal MSVC */
#  else
#    pragma warning(error : 4018) /* signed/unsigned mismatch */
#    pragma warning(error : 4244) /* conversion from 'type1' to 'type2', possible loss of data */
#    pragma warning(error : 4245) /* conversion from 'int' to 'unsigned int' */
#    pragma warning(error : 4267) /* conversion from 'size_t' to 'type', possible loss of data */
#    pragma warning(error : 4305) /* truncation from 'type1' to 'type2' */
#    pragma warning(error : 4389) /* signed/unsigned mismatch */
#  endif
#endif