[Bf-blender-cvs] [55c15ad9ded] master: Cycles: Use falltrhough attribute to help catching missing break statements

Sergey Sharybin noreply at git.blender.org
Wed May 24 18:09:08 CEST 2017


Commit: 55c15ad9ded2707d16cb88eea2dc2a62e4ec2359
Author: Sergey Sharybin
Date:   Wed May 24 17:23:54 2017 +0200
Branches: master
https://developer.blender.org/rB55c15ad9ded2707d16cb88eea2dc2a62e4ec2359

Cycles: Use falltrhough attribute to help catching missing break statements

===================================================================

M	intern/cycles/kernel/kernel_compat_cpu.h
M	intern/cycles/kernel/kernel_compat_cuda.h
M	intern/cycles/kernel/kernel_compat_opencl.h
M	intern/cycles/kernel/svm/svm_closure.h
M	intern/cycles/util/util_types.h

===================================================================

diff --git a/intern/cycles/kernel/kernel_compat_cpu.h b/intern/cycles/kernel/kernel_compat_cpu.h
index 21da180bb8e..93934ee6b38 100644
--- a/intern/cycles/kernel/kernel_compat_cpu.h
+++ b/intern/cycles/kernel/kernel_compat_cpu.h
@@ -195,7 +195,7 @@ template<typename T> struct texture_image  {
 					if(x < 0.0f || y < 0.0f || x > 1.0f || y > 1.0f) {
 						return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
 					}
-					/* Fall through. */
+					ATTR_FALLTHROUGH;
 				case EXTENSION_EXTEND:
 					ix = wrap_clamp(ix, width);
 					iy = wrap_clamp(iy, height);
@@ -222,7 +222,7 @@ template<typename T> struct texture_image  {
 					if(x < 0.0f || y < 0.0f || x > 1.0f || y > 1.0f) {
 						return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
 					}
-					/* Fall through. */
+					ATTR_FALLTHROUGH;
 				case EXTENSION_EXTEND:
 					nix = wrap_clamp(ix+1, width);
 					niy = wrap_clamp(iy+1, height);
@@ -265,7 +265,7 @@ template<typename T> struct texture_image  {
 					if(x < 0.0f || y < 0.0f || x > 1.0f || y > 1.0f) {
 						return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
 					}
-					/* Fall through. */
+					ATTR_FALLTHROUGH;
 				case EXTENSION_EXTEND:
 					pix = wrap_clamp(ix-1, width);
 					piy = wrap_clamp(iy-1, height);
@@ -335,7 +335,7 @@ template<typename T> struct texture_image  {
 				{
 					return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
 				}
-				/* Fall through. */
+				ATTR_FALLTHROUGH;
 			case EXTENSION_EXTEND:
 				ix = wrap_clamp(ix, width);
 				iy = wrap_clamp(iy, height);
@@ -374,7 +374,7 @@ template<typename T> struct texture_image  {
 				{
 					return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
 				}
-				/* Fall through. */
+				ATTR_FALLTHROUGH;
 			case EXTENSION_EXTEND:
 				nix = wrap_clamp(ix+1, width);
 				niy = wrap_clamp(iy+1, height);
@@ -449,7 +449,7 @@ template<typename T> struct texture_image  {
 				{
 					return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
 				}
-				/* Fall through. */
+				ATTR_FALLTHROUGH;
 			case EXTENSION_EXTEND:
 				pix = wrap_clamp(ix-1, width);
 				piy = wrap_clamp(iy-1, height);
diff --git a/intern/cycles/kernel/kernel_compat_cuda.h b/intern/cycles/kernel/kernel_compat_cuda.h
index 988126f90e1..38708f7ff0b 100644
--- a/intern/cycles/kernel/kernel_compat_cuda.h
+++ b/intern/cycles/kernel/kernel_compat_cuda.h
@@ -55,6 +55,8 @@
 #define ccl_restrict __restrict__
 #define ccl_align(n) __align__(n)
 
+#define ATTR_FALLTHROUGH
+
 #define CCL_MAX_LOCAL_SIZE (CUDA_THREADS_BLOCK_WIDTH*CUDA_THREADS_BLOCK_WIDTH)
 
 
diff --git a/intern/cycles/kernel/kernel_compat_opencl.h b/intern/cycles/kernel/kernel_compat_opencl.h
index c2263ac0d49..4836c290312 100644
--- a/intern/cycles/kernel/kernel_compat_opencl.h
+++ b/intern/cycles/kernel/kernel_compat_opencl.h
@@ -50,6 +50,8 @@
 #  define ccl_addr_space
 #endif
 
+#define ATTR_FALLTHROUGH
+
 #define ccl_local_id(d) get_local_id(d)
 #define ccl_global_id(d) get_global_id(d)
 
diff --git a/intern/cycles/kernel/svm/svm_closure.h b/intern/cycles/kernel/svm/svm_closure.h
index 4a0bbb25c1d..f04f765686e 100644
--- a/intern/cycles/kernel/svm/svm_closure.h
+++ b/intern/cycles/kernel/svm/svm_closure.h
@@ -684,6 +684,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
 #ifdef __CAUSTICS_TRICKS__
 			if(!kernel_data.integrator.caustics_reflective && (path_flag & PATH_RAY_DIFFUSE))
 				break;
+			ATTR_FALLTHROUGH;
 #endif
 		case CLOSURE_BSDF_DIFFUSE_TOON_ID: {
 			float3 weight = sd->svm_closure_weight * mix_weight;
diff --git a/intern/cycles/util/util_types.h b/intern/cycles/util/util_types.h
index 0039c59ec48..a5d1d7152d5 100644
--- a/intern/cycles/util/util_types.h
+++ b/intern/cycles/util/util_types.h
@@ -68,6 +68,13 @@
 #    define ccl_never_inline __attribute__((noinline))
 #    define ccl_maybe_unused __attribute__((used))
 #  endif  /* _WIN32 && !FREE_WINDOWS */
+
+/* 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  /* __KERNEL_GPU__ */
 
 /* Standard Integer Types */




More information about the Bf-blender-cvs mailing list