mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
Convert FALLTHROUGH comments to C++17 [[fallthrough]] attribute
Use conditionals and a macro to avoid provoking compilers that do
not support this attribute.
Adds a macro named CPP_ATTRIBUTE_FALLTHROUGH which is invoked right
before a following case statement to declare that the intent is to
fall through. Example:
...
case xxx:
...
CPP_ATTRIBUTE_FALLTHROUGH;
case yyy:
...
The gcc/clang alternative of adding comments that contain "FALLTHROUGH"
suffers from the problem that *by default* ccache strips the comments
so that they are not present for the real compilation.
Change-Id: I77ddeb7dae46db8398b014a93f6a71bedc64ada9
Signed-off-by: Dale Stimson <dale.b.stimson@intel.com>
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "common/compiler_support.h"
|
||||
#include "runtime/helpers/aligned_memory.h"
|
||||
#include <cstdint>
|
||||
|
||||
@@ -51,11 +52,11 @@ class Hash {
|
||||
case 3:
|
||||
value = static_cast<uint32_t>(*reinterpret_cast<const unsigned char *>(data++));
|
||||
value <<= 8;
|
||||
// FALLTHROUGH
|
||||
CPP_ATTRIBUTE_FALLTHROUGH;
|
||||
case 2:
|
||||
value |= static_cast<uint32_t>(*reinterpret_cast<const unsigned char *>(data++));
|
||||
value <<= 8;
|
||||
// FALLTHROUGH
|
||||
CPP_ATTRIBUTE_FALLTHROUGH;
|
||||
case 1:
|
||||
value |= static_cast<uint32_t>(*reinterpret_cast<const unsigned char *>(data++));
|
||||
value <<= 8;
|
||||
|
||||
Reference in New Issue
Block a user