Parenthesize SPV_BIT macro to avoid surprises.
This commit is contained in:
Родитель
17f1bae331
Коммит
f6184a8b37
|
@ -158,6 +158,7 @@ if (TARGET gtest)
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/test/FixWord.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test/BinaryHeaderGet.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test/BinaryToText.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test/LibspirvMacros.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test/NamedId.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test/OpcodeTableGet.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test/OpcodeIsVariable.cpp
|
||||
|
|
|
@ -90,7 +90,7 @@ extern "C" {
|
|||
|
||||
#define spvIsInBitfield(value, bitfield) (value == (value & bitfield))
|
||||
|
||||
#define SPV_BIT(shift) 1 << shift
|
||||
#define SPV_BIT(shift) (1 << (shift))
|
||||
|
||||
#define SPV_FORCE_16_BIT_ENUM(name) _##name = 0x7fff
|
||||
#define SPV_FORCE_32_BIT_ENUM(name) _##name = 0x7fffffff
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
// Copyright (c) 2015 The Khronos Group Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and/or associated documentation files (the
|
||||
// "Materials"), to deal in the Materials without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Materials, and to
|
||||
// permit persons to whom the Materials are furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Materials.
|
||||
//
|
||||
// MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS
|
||||
// KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS
|
||||
// SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT
|
||||
// https://www.khronos.org/registry/
|
||||
//
|
||||
// THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
// MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||
|
||||
#include "UnitSPIRV.h"
|
||||
|
||||
TEST(Macros, BitShiftInnerParens) {
|
||||
ASSERT_EQ(65536, SPV_BIT(2 << 3));
|
||||
}
|
||||
|
||||
TEST(Macros, BitShiftOuterParens) {
|
||||
ASSERT_EQ(15, SPV_BIT(4)-1);
|
||||
}
|
Загрузка…
Ссылка в новой задаче