diff --git a/include/etl/crc1.h b/include/etl/crc1.h index 305f894ec..47986991e 100644 --- a/include/etl/crc1.h +++ b/include/etl/crc1.h @@ -52,19 +52,19 @@ namespace etl }; //********************************* - value_type initial() const + ETL_CONSTEXPR14 value_type initial() const { return even_parity; } //********************************* - uint8_t add(int parity, uint8_t value) const + ETL_CONSTEXPR14 uint8_t add(int parity, uint8_t value) const { return parity ^ etl::parity(value); } //********************************* - uint8_t final(uint8_t parity) const + ETL_CONSTEXPR14 uint8_t final(uint8_t parity) const { return parity; } @@ -83,7 +83,7 @@ namespace etl //************************************************************************* /// Default constructor. //************************************************************************* - crc1() + ETL_CONSTEXPR14 crc1() { this->reset(); } @@ -94,7 +94,7 @@ namespace etl /// \param end End of the range. //************************************************************************* template - crc1(TIterator begin, const TIterator end) + ETL_CONSTEXPR14 crc1(TIterator begin, const TIterator end) { this->reset(); this->add(begin, end); diff --git a/include/etl/frame_check_sequence.h b/include/etl/frame_check_sequence.h index 71bc31d43..6a21e93de 100644 --- a/include/etl/frame_check_sequence.h +++ b/include/etl/frame_check_sequence.h @@ -107,7 +107,8 @@ namespace etl //************************************************************************* /// Default constructor. //************************************************************************* - ETL_CONSTEXPR14 frame_check_sequence() : frame_check() + ETL_CONSTEXPR14 frame_check_sequence() + : frame_check() { reset(); } diff --git a/test/test_crc1.cpp b/test/test_crc1.cpp index fe62b17e1..ed988da6a 100644 --- a/test/test_crc1.cpp +++ b/test/test_crc1.cpp @@ -66,6 +66,17 @@ namespace CHECK_EQUAL(calculate_parity(data.begin(), data.end()), int(crc)); } +#if ETL_USING_CPP14 + //************************************************************************* + TEST(test_crc1_constructor_constexpr) + { + constexpr char data[] = "123456789"; + constexpr uint8_t crc = etl::crc1(data, data + 9); + + CHECK_EQUAL(calculate_parity(data, data + 9), int(crc)); + } +#endif + //************************************************************************* TEST(test_crc1_add_values) {