[Bf-blender-cvs] [81e584ed179] master: CMake: Use GCC7's -Wimplicit-fallthrough=5
Campbell Barton
noreply at git.blender.org
Sat May 20 06:00:45 CEST 2017
Commit: 81e584ed17902878579131776b4e5a9f7b54cdab
Author: Campbell Barton
Date: Sat May 20 14:01:03 2017 +1000
Branches: master
https://developer.blender.org/rB81e584ed17902878579131776b4e5a9f7b54cdab
CMake: Use GCC7's -Wimplicit-fallthrough=5
Use to avoid accidental missing break statements,
use ATTR_FALLTHROUGH to suppress.
===================================================================
M CMakeLists.txt
M intern/string/STR_HashedString.h
M source/blender/alembic/intern/abc_curves.cc
M source/blender/blenkernel/intern/image.c
M source/blender/blenkernel/intern/mball_tessellate.c
M source/blender/blenkernel/intern/packedFile.c
M source/blender/blenkernel/intern/particle.c
M source/blender/blenkernel/intern/rigidbody.c
M source/blender/blenlib/BLI_compiler_attrs.h
M source/blender/blenlib/intern/hash_mm2a.c
M source/blender/blenlib/intern/string.c
M source/blender/blenlib/intern/string_utf8.c
M source/blender/blenloader/intern/readfile.c
M source/blender/editors/animation/anim_draw.c
M source/blender/editors/animation/anim_markers.c
M source/blender/editors/interface/interface_handlers.c
M source/blender/editors/mask/mask_ops.c
M source/blender/editors/render/render_opengl.c
M source/blender/editors/space_clip/space_clip.c
M source/blender/editors/space_clip/tracking_ops.c
M source/blender/editors/space_clip/tracking_ops_plane.c
M source/blender/editors/space_image/image_buttons.c
M source/blender/editors/space_nla/nla_draw.c
M source/blender/editors/space_sequencer/sequencer_edit.c
M source/blender/editors/space_text/space_text.c
M source/blender/editors/space_text/text_autocomplete.c
M source/blender/editors/space_view3d/drawobject.c
M source/blender/editors/transform/transform.c
M source/blender/editors/transform/transform_manipulator.c
M source/blender/editors/transform/transform_orientations.c
M source/blender/editors/util/numinput.c
M source/blender/editors/uvedit/uvedit_smart_stitch.c
M source/blender/gpu/intern/gpu_debug.c
M source/blender/python/intern/bpy_rna.c
M source/blender/python/mathutils/mathutils_Color.c
M source/blender/python/mathutils/mathutils_Euler.c
M source/blender/python/mathutils/mathutils_Matrix.c
M source/blender/python/mathutils/mathutils_Quaternion.c
M source/blender/render/intern/source/render_texture.c
M source/blender/render/intern/source/volumetric.c
M source/gameengine/Expressions/intern/PyObjectPlus.cpp
M source/gameengine/GameLogic/SCA_PropertySensor.cpp
M source/gameengine/Ketsji/KX_ObstacleSimulation.cpp
M source/gameengine/Ketsji/KX_SoundActuator.cpp
===================================================================
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1dac082459f..2284146b3ab 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1380,9 +1380,16 @@ if(CMAKE_COMPILER_IS_GNUCC)
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_MISSING_DECLARATIONS -Wmissing-declarations)
endif()
+ # Use 'ATTR_FALLTHROUGH' macro to suppress.
+ if(CMAKE_COMPILER_IS_GNUCC AND (NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "7.0"))
+ ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_IMPLICIT_FALLTHROUGH -Wimplicit-fallthrough=5)
+ ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_IMPLICIT_FALLTHROUGH -Wimplicit-fallthrough=5)
+ endif()
+
# flags to undo strict flags
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_DEPRECATED_DECLARATIONS -Wno-deprecated-declarations)
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter)
+ ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_IMPLICIT_FALLTHROUGH -Wno-implicit-fallthrough)
if(NOT APPLE)
ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable)
diff --git a/intern/string/STR_HashedString.h b/intern/string/STR_HashedString.h
index 8bfbde65895..ce790f398a0 100644
--- a/intern/string/STR_HashedString.h
+++ b/intern/string/STR_HashedString.h
@@ -38,6 +38,14 @@
#include "STR_String.h"
+/* copied from 'BLI_compiler_attrs.h' */
+/* Use to suppress '-Wimplicit-fallthrough' (in place of 'break'). */
+#if defined(__GNUC__) && (__GNUC__ >= 7) /* gcc7.0+ only */
+#define ATTR_FALLTHROUGH __attribute__((fallthrough))
+#else
+#define ATTR_FALLTHROUGH ((void)0)
+#endif
+
// Hash Mix utility function, by Bob Jenkins - Mix 3 32-bit values reversibly
//
@@ -102,16 +110,16 @@ static dword STR_gHash(const void *in, int len, dword init_val)
// Handle the last 11 bytes
c += len;
switch (length) {
- case 11: c += ((dword)p_in[10] << 24);
- case 10: c += ((dword)p_in[9] << 16);
- case 9: c += ((dword)p_in[8] << 8); /* the first byte of c is reserved for the length */
- case 8: b += ((dword)p_in[7] << 24);
- case 7: b += ((dword)p_in[6] << 16);
- case 6: b += ((dword)p_in[5] << 8);
- case 5: b += p_in[4];
- case 4: a += ((dword)p_in[3] << 24);
- case 3: a += ((dword)p_in[2] << 16);
- case 2: a += ((dword)p_in[1] << 8);
+ case 11: c += ((dword)p_in[10] << 24); ATTR_FALLTHROUGH;
+ case 10: c += ((dword)p_in[9] << 16); ATTR_FALLTHROUGH;
+ case 9: c += ((dword)p_in[8] << 8); ATTR_FALLTHROUGH; /* the first byte of c is reserved for the length */
+ case 8: b += ((dword)p_in[7] << 24); ATTR_FALLTHROUGH;
+ case 7: b += ((dword)p_in[6] << 16); ATTR_FALLTHROUGH;
+ case 6: b += ((dword)p_in[5] << 8); ATTR_FALLTHROUGH;
+ case 5: b += p_in[4]; ATTR_FALLTHROUGH;
+ case 4: a += ((dword)p_in[3] << 24); ATTR_FALLTHROUGH;
+ case 3: a += ((dword)p_in[2] << 16); ATTR_FALLTHROUGH;
+ case 2: a += ((dword)p_in[1] << 8); ATTR_FALLTHROUGH;
case 1: a += p_in[0];
}
STR_gHashMix(a, b, c);
diff --git a/source/blender/alembic/intern/abc_curves.cc b/source/blender/alembic/intern/abc_curves.cc
index 67b2cb8ae8c..f54abd6563e 100644
--- a/source/blender/alembic/intern/abc_curves.cc
+++ b/source/blender/alembic/intern/abc_curves.cc
@@ -297,6 +297,7 @@ void read_curve_sample(Curve *cu, const ICurvesSchema &schema, const ISampleSele
nu->orderu = static_cast<short>((*orders)[i]);
break;
}
+ ATTR_FALLTHROUGH;
case Alembic::AbcGeom::kLinear:
default:
nu->orderu = 2;
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 2db13f9c778..026e8aea74f 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -1238,7 +1238,7 @@ char BKE_imtype_valid_channels(const char imtype, bool write_file)
switch (imtype) {
case R_IMF_IMTYPE_BMP:
if (write_file) break;
- /* fall-through */
+ ATTR_FALLTHROUGH;
case R_IMF_IMTYPE_TARGA:
case R_IMF_IMTYPE_RAWTGA:
case R_IMF_IMTYPE_IRIS:
diff --git a/source/blender/blenkernel/intern/mball_tessellate.c b/source/blender/blenkernel/intern/mball_tessellate.c
index c8b75f3e457..76965176be8 100644
--- a/source/blender/blenkernel/intern/mball_tessellate.c
+++ b/source/blender/blenkernel/intern/mball_tessellate.c
@@ -316,12 +316,12 @@ static float densfunc(const MetaElem *ball, float x, float y, float z)
if (dvec[2] > ball->expz) dvec[2] -= ball->expz;
else if (dvec[2] < -ball->expz) dvec[2] += ball->expz;
else dvec[2] = 0.0;
- /* fall through */
+ ATTR_FALLTHROUGH;
case MB_PLANE:
if (dvec[1] > ball->expy) dvec[1] -= ball->expy;
else if (dvec[1] < -ball->expy) dvec[1] += ball->expy;
else dvec[1] = 0.0;
- /* fall through */
+ ATTR_FALLTHROUGH;
case MB_TUBE:
if (dvec[0] > ball->expx) dvec[0] -= ball->expx;
else if (dvec[0] < -ball->expx) dvec[0] += ball->expx;
@@ -1194,10 +1194,10 @@ static void init_meta(EvaluationContext *eval_ctx, PROCESS *process, Scene *scen
break;
case MB_CUBE: /* cube is "expanded" by expz, expy and expx */
expz += ml->expz;
- /* fall through */
+ ATTR_FALLTHROUGH;
case MB_PLANE: /* plane is "expanded" by expy and expx */
expy += ml->expy;
- /* fall through */
+ ATTR_FALLTHROUGH;
case MB_TUBE: /* tube is "expanded" by expx */
expx += ml->expx;
break;
diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c
index 489fc2f3710..64f90ef5c52 100644
--- a/source/blender/blenkernel/intern/packedFile.c
+++ b/source/blender/blenkernel/intern/packedFile.c
@@ -450,7 +450,7 @@ char *unpackFile(ReportList *reports, const char *abs_name, const char *local_na
break;
}
/* else create it */
- /* fall-through */
+ ATTR_FALLTHROUGH;
}
case PF_WRITE_LOCAL:
if (writePackedFile(reports, local_name, pf, 1) == RET_OK) {
@@ -471,7 +471,7 @@ char *unpackFile(ReportList *reports, const char *abs_name, const char *local_na
break;
}
/* else create it */
- /* fall-through */
+ ATTR_FALLTHROUGH;
}
case PF_WRITE_ORIGINAL:
if (writePackedFile(reports, abs_name, pf, 1) == RET_OK) {
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 228ae6afaba..bb5cea9dcc7 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -3466,7 +3466,8 @@ static void get_cpa_texture(DerivedMesh *dm, ParticleSystem *psys, ParticleSetti
case TEXCO_UV:
if (fw && get_particle_uv(dm, NULL, face_index, fw, mtex->uvname, texvec))
break;
- /* no break, failed to get uv's, so let's try orco's */
+ /* no break, failed to get uv's, so let's try orco's */
+ ATTR_FALLTHROUGH;
case TEXCO_ORCO:
copy_v3_v3(texvec, orco);
break;
@@ -3538,7 +3539,8 @@ void psys_get_texture(ParticleSimulationData *sim, ParticleData *pa, ParticleTex
case TEXCO_UV:
if (get_particle_uv(sim->psmd->dm_final, pa, 0, pa->fuv, mtex->uvname, texvec))
break;
- /* no break, failed to get uv's, so let's try orco's */
+ /* no break, failed to get uv's, so let's try orco's */
+ ATTR_FALLTHROUGH;
case TEXCO_ORCO:
psys_particle_on_emitter(sim->psmd, sim->psys->part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, co, 0, 0, 0, texvec, 0);
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c
index 5353cc26295..b3a36bfb089 100644
--- a/source/blender/blenkernel/intern/rigidbody.c
+++ b/source/blender/blenkernel/intern/rigidbody.c
@@ -822,7 +822,7 @@ static void rigidbody_validate_sim_constraint(RigidBodyWorld *rbw, Object *ob, b
RB_constraint_set_damping_6dof_spring(rbc->physics_constraint, RB_LIMIT_ANG_Z, rbc->spring_damping_ang_z);
RB_constraint_set_equilibrium_6dof_spring(rbc->physics_constraint);
- /* fall-through */
+ ATTR_FALLTHROUGH;
case RBC_TYPE_6DOF:
if (rbc->type == RBC_TYPE_6DOF) /* a litte awkward but avoids duplicate code for limits */
rbc->physics_constraint = RB_constraint_new_6dof(loc, rot, rb1, rb2);
diff --git a/source/blender/blenlib/BLI_compiler_attrs.h b/source/blender/blenlib/BLI_compiler_attrs.h
index f0d32670229..4c548654e33 100644
--- a/source/blender/blenlib/BLI_compiler_attrs.h
+++ b/source/blender/blenlib/BLI_compiler_attrs.h
@@ -92,4 +92,12 @@
# define ATTR_PRINTF_FORMAT(format_param, dots_param)
#endif
+/* Use to suppress '-Wimplicit-fallthrough' (in place of 'break'). */
+#if defined(__GNUC__) && (__GNUC__ >= 7) /* gcc7.0+ only */
+#define ATTR_FALLTHROUGH __attribute__((fallthrough))
+#else
+#define ATTR_FALLTHROUGH ((void)0)
+#endif
+
+
#endif /* __BLI_COMPILER_ATTRS_H__ */
diff --git a/source/blender/blenlib/intern/hash_mm2a.c b/source/blender/blenlib/intern/hash_mm2a.c
index af6ef4f355f..e8ca9244f25 100644
--- a/source/blender/blenlib/intern/hash_mm2a.c
+++ b/source/blender/blenlib/intern/hash_mm2a.c
@@ -36,6 +36,8 @@
* for temporary data.
*/
+#include "BLI_compiler_attrs.h"
+
#include "BLI_hash_mm2a.h" /* own include */
/* Helpers. */
@@ -128,10 +130,10 @@ uint32_t BLI_hash_mm2(const unsigned char *data, size_t len, uint32_t seed)
switch (len) {
case 3:
h ^= data[2] << 16;
- /* fall through */
+ ATTR_FALLTHROUGH;
case 2:
h ^= data[1] << 8;
- /* fall through */
+ ATTR_FALLTHROUGH;
case 1:
h ^= data[0];
h *= MM2A_M;
diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c
index f62ffe9e985..6022732025b 100644
--- a/source/blender/blenlib/intern/string.c
+++ b/source/blender/blenlib/intern/string.c
@@ -332,7 +332,7 @@ size_t BLI_strescape(char *__restrict dst, const char *__restrict src, const siz
goto escape_finish;
case '\\':
case '"':
- /* fall-through */
+ ATTR_FALLTHROUGH;
/* less common but should also be support */
case '\t':
@@ -346,7 +346,7 @@ size_t BLI_strescape(char *__
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list