From 36c6f79dd67d9dae18c425ad77b731f8dacbca41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Mon, 28 Jun 2021 14:26:59 +0200 Subject: [PATCH 1/3] Add static_assert for EVMC_LATEST_STABLE_REVISION --- include/evmc/evmc.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/evmc/evmc.hpp b/include/evmc/evmc.hpp index a55ee35c5..b7ef0a025 100644 --- a/include/evmc/evmc.hpp +++ b/include/evmc/evmc.hpp @@ -12,6 +12,9 @@ #include #include +static_assert(EVMC_LATEST_STABLE_REVISION <= EVMC_MAX_REVISION, + "latest stable revision ill-defined"); + /// EVMC C++ API - wrappers and bindings for C++ /// @ingroup cpp namespace evmc From 6ba97b1643663792152aedf91bd0333415437f17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Mon, 28 Jun 2021 14:28:43 +0200 Subject: [PATCH 2/3] cmake: Explicitly require C99 for evmc.h --- lib/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index b09cba05a..731ce4280 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -4,6 +4,7 @@ add_library(evmc INTERFACE) add_library(evmc::evmc ALIAS evmc) +target_compile_features(evmc INTERFACE c_std_99) target_include_directories(evmc INTERFACE $$) add_library(evmc_cpp INTERFACE) From 7180f39dd6bae5cdfeedd8669a70aa478d02f8ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Mon, 28 Jun 2021 16:10:23 +0200 Subject: [PATCH 3/3] test: Use C++17 static_assert without message --- test/unittests/cpp_test.cpp | 34 +++++++++++++++++----------------- test/unittests/loader_test.cpp | 8 ++++---- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/test/unittests/cpp_test.cpp b/test/unittests/cpp_test.cpp index ec292e8c9..e676c3817 100644 --- a/test/unittests/cpp_test.cpp +++ b/test/unittests/cpp_test.cpp @@ -124,8 +124,8 @@ TEST(cpp, std_hash) using namespace evmc::literals; - static_assert(std::hash{}({}) == static_cast(0xd94d12186c0f2fb7), ""); - static_assert(std::hash{}({}) == static_cast(0x4d25767f9dce13f5), ""); + static_assert(std::hash{}({}) == static_cast(0xd94d12186c0f2fb7)); + static_assert(std::hash{}({}) == static_cast(0x4d25767f9dce13f5)); EXPECT_EQ(std::hash{}({}), static_cast(0xd94d12186c0f2fb7)); EXPECT_EQ(std::hash{}({}), static_cast(0x4d25767f9dce13f5)); @@ -341,15 +341,15 @@ TEST(cpp, literals) constexpr auto zero_address = 0_address; constexpr auto zero_hash = 0_bytes32; - static_assert(address1.bytes[0] == 0xa0, ""); - static_assert(address1.bytes[9] == 0xa9, ""); - static_assert(address1.bytes[10] == 0xd0, ""); - static_assert(address1.bytes[19] == 0xd9, ""); - static_assert(hash1.bytes[0] == 0x01, ""); - static_assert(hash1.bytes[10] == 0xa1, ""); - static_assert(hash1.bytes[31] == 0xd2, ""); - static_assert(zero_address == evmc::address{}, ""); - static_assert(zero_hash == evmc::bytes32{}, ""); + static_assert(address1.bytes[0] == 0xa0); + static_assert(address1.bytes[9] == 0xa9); + static_assert(address1.bytes[10] == 0xd0); + static_assert(address1.bytes[19] == 0xd9); + static_assert(hash1.bytes[0] == 0x01); + static_assert(hash1.bytes[10] == 0xa1); + static_assert(hash1.bytes[31] == 0xd2); + static_assert(zero_address == evmc::address{}); + static_assert(zero_hash == evmc::bytes32{}); EXPECT_EQ(0_address, evmc::address{}); EXPECT_EQ(0_bytes32, evmc::bytes32{}); @@ -371,9 +371,9 @@ TEST(cpp, bytes32_from_uint) using evmc::bytes32; using evmc::operator""_bytes32; - static_assert(bytes32{0} == bytes32{}, ""); - static_assert(bytes32{3}.bytes[31] == 3, ""); - static_assert(bytes32{0xfe00000000000000}.bytes[24] == 0xfe, ""); + static_assert(bytes32{0} == bytes32{}); + static_assert(bytes32{3}.bytes[31] == 3); + static_assert(bytes32{0xfe00000000000000}.bytes[24] == 0xfe); EXPECT_EQ(bytes32{0}, bytes32{}); EXPECT_EQ(bytes32{0x01}, @@ -393,9 +393,9 @@ TEST(cpp, address_from_uint) using evmc::address; using evmc::operator""_address; - static_assert(address{0} == address{}, ""); - static_assert(address{3}.bytes[19] == 3, ""); - static_assert(address{0xfe00000000000000}.bytes[12] == 0xfe, ""); + static_assert(address{0} == address{}); + static_assert(address{3}.bytes[19] == 3); + static_assert(address{0xfe00000000000000}.bytes[12] == 0xfe); EXPECT_EQ(address{0}, address{}); EXPECT_EQ(address{0x01}, 0x0000000000000000000000000000000000000001_address); diff --git a/test/unittests/loader_test.cpp b/test/unittests/loader_test.cpp index ae55d2e81..654c577fa 100644 --- a/test/unittests/loader_test.cpp +++ b/test/unittests/loader_test.cpp @@ -91,7 +91,7 @@ class loader : public ::testing::Test static evmc_vm* create_vm_with_wrong_abi() { constexpr auto wrong_abi_version = 1985; - static_assert(wrong_abi_version != EVMC_ABI_VERSION, ""); + static_assert(wrong_abi_version != EVMC_ABI_VERSION); static auto instance = evmc_vm{wrong_abi_version, "", "", destroy, nullptr, nullptr, nullptr}; ++create_count; @@ -137,9 +137,9 @@ TEST_F(loader, strcpy_sx) const char input_that_fits[] = "x"; const char input_too_big[] = "12"; char buf[2] = {0x0f, 0x0f}; - static_assert(sizeof(input_empty) <= sizeof(buf), ""); - static_assert(sizeof(input_that_fits) <= sizeof(buf), ""); - static_assert(sizeof(input_too_big) > sizeof(buf), ""); + static_assert(sizeof(input_empty) <= sizeof(buf)); + static_assert(sizeof(input_that_fits) <= sizeof(buf)); + static_assert(sizeof(input_too_big) > sizeof(buf)); EXPECT_EQ(strcpy_sx(buf, sizeof(buf), input_empty), 0); EXPECT_EQ(buf[0], 0);