From 7b2ccc00959a619919855692c79868e0e8b11244 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Sun, 22 Jul 2018 17:16:21 +0100 Subject: [PATCH 1/3] Tentative fix for msvc warnings. See https://github.com/boostorg/regex/issues/61. Adds warning test case. --- include/boost/regex/config.hpp | 5 ++++- include/boost/regex/v4/basic_regex.hpp | 8 +++++++- include/boost/regex/v4/basic_regex_creator.hpp | 4 +++- include/boost/regex/v4/basic_regex_parser.hpp | 5 ++++- include/boost/regex/v4/instances.hpp | 5 ++++- include/boost/regex/v4/match_results.hpp | 5 ++++- include/boost/regex/v4/perl_matcher.hpp | 9 +++++++-- include/boost/regex/v4/perl_matcher_common.hpp | 4 +++- .../boost/regex/v4/perl_matcher_non_recursive.hpp | 5 ++++- include/boost/regex/v4/regex_raw_buffer.hpp | 6 +++--- include/boost/regex/v4/regex_split.hpp | 4 +++- include/boost/regex/v4/regex_traits_defaults.hpp | 2 +- include/boost/regex/v4/w32_regex_traits.hpp | 2 ++ test/Jamfile.v2 | 5 +++++ test/test_warnings.cpp | 12 ++++++++++++ 15 files changed, 66 insertions(+), 15 deletions(-) create mode 100644 test/test_warnings.cpp diff --git a/include/boost/regex/config.hpp b/include/boost/regex/config.hpp index eb998110..1df0097d 100644 --- a/include/boost/regex/config.hpp +++ b/include/boost/regex/config.hpp @@ -201,7 +201,10 @@ # define BOOST_REGEX_HAS_OTHER_WCHAR_T # ifdef BOOST_MSVC # pragma warning(push) -# pragma warning(disable : 4251 4231) +# pragma warning(disable : 4251) +#if BOOST_MSVC < 1700 +# pragma warning(disable : 4231) +#endif # if BOOST_MSVC < 1600 # pragma warning(disable : 4660) # endif diff --git a/include/boost/regex/v4/basic_regex.hpp b/include/boost/regex/v4/basic_regex.hpp index ac91af29..19623720 100644 --- a/include/boost/regex/v4/basic_regex.hpp +++ b/include/boost/regex/v4/basic_regex.hpp @@ -36,10 +36,16 @@ namespace boost{ #ifdef BOOST_MSVC #pragma warning(push) -#pragma warning(disable : 4251 4231 4800) +#pragma warning(disable : 4251) +#if BOOST_MSVC < 1700 +# pragma warning(disable : 4231) +#endif #if BOOST_MSVC < 1600 #pragma warning(disable : 4660) #endif +#if BOOST_MSVC < 1910 +#pragma warning(disable:4800) +#endif #endif namespace BOOST_REGEX_DETAIL_NS{ diff --git a/include/boost/regex/v4/basic_regex_creator.hpp b/include/boost/regex/v4/basic_regex_creator.hpp index 623e06f1..7c006527 100644 --- a/include/boost/regex/v4/basic_regex_creator.hpp +++ b/include/boost/regex/v4/basic_regex_creator.hpp @@ -33,7 +33,9 @@ #ifdef BOOST_MSVC # pragma warning(push) -# pragma warning(disable: 4800) +#if BOOST_MSVC < 1910 +#pragma warning(disable:4800) +#endif #endif namespace boost{ diff --git a/include/boost/regex/v4/basic_regex_parser.hpp b/include/boost/regex/v4/basic_regex_parser.hpp index dc528a39..6c7065f0 100644 --- a/include/boost/regex/v4/basic_regex_parser.hpp +++ b/include/boost/regex/v4/basic_regex_parser.hpp @@ -35,7 +35,10 @@ namespace BOOST_REGEX_DETAIL_NS{ #ifdef BOOST_MSVC #pragma warning(push) -#pragma warning(disable:4244 4800) +#pragma warning(disable:4244) +#if BOOST_MSVC < 1910 +#pragma warning(disable:4800) +#endif #endif inline boost::intmax_t umax(mpl::false_ const&) diff --git a/include/boost/regex/v4/instances.hpp b/include/boost/regex/v4/instances.hpp index 05ac71a6..b70437e7 100644 --- a/include/boost/regex/v4/instances.hpp +++ b/include/boost/regex/v4/instances.hpp @@ -84,7 +84,10 @@ template class BOOST_REGEX_DECL ::boost::BOOST_REGEX_DETAIL_NS::perl_matcher(ptr) - static_cast(data()); + return size_type(static_cast(ptr) - static_cast(data())); } void BOOST_REGEX_CALL clear() diff --git a/include/boost/regex/v4/regex_split.hpp b/include/boost/regex/v4/regex_split.hpp index 65b2c64a..afa56598 100644 --- a/include/boost/regex/v4/regex_split.hpp +++ b/include/boost/regex/v4/regex_split.hpp @@ -36,7 +36,9 @@ namespace boost{ #ifdef BOOST_MSVC # pragma warning(push) -# pragma warning(disable: 4800) +#if BOOST_MSVC < 1910 +#pragma warning(disable:4800) +#endif #endif namespace BOOST_REGEX_DETAIL_NS{ diff --git a/include/boost/regex/v4/regex_traits_defaults.hpp b/include/boost/regex/v4/regex_traits_defaults.hpp index 87030a83..e58d6bae 100644 --- a/include/boost/regex/v4/regex_traits_defaults.hpp +++ b/include/boost/regex/v4/regex_traits_defaults.hpp @@ -241,7 +241,7 @@ inline std::ptrdiff_t global_length(const char* p) template<> inline std::ptrdiff_t global_length(const wchar_t* p) { - return (std::wcslen)(p); + return (std::ptrdiff_t)(std::wcslen)(p); } #endif template diff --git a/include/boost/regex/v4/w32_regex_traits.hpp b/include/boost/regex/v4/w32_regex_traits.hpp index bf996d61..378ee856 100644 --- a/include/boost/regex/v4/w32_regex_traits.hpp +++ b/include/boost/regex/v4/w32_regex_traits.hpp @@ -51,8 +51,10 @@ #ifdef BOOST_MSVC #pragma warning(push) #pragma warning(disable:4786) +#if BOOST_MSVC < 1910 #pragma warning(disable:4800) #endif +#endif namespace boost{ diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index f485058c..17f6b842 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -196,3 +196,8 @@ build-project ../example ; # `quick` target (for CI) run quick.cpp ../build//boost_regex ; + +compile test_warnings.cpp + : msvc:all msvc:on + gcc:all gcc:on + clang:all clang:on ; diff --git a/test/test_warnings.cpp b/test/test_warnings.cpp new file mode 100644 index 00000000..1c2a41d3 --- /dev/null +++ b/test/test_warnings.cpp @@ -0,0 +1,12 @@ +#ifdef _MSC_VER +#pragma warning(disable:4820 4668) +#endif + +#include + +void test_proc() +{ + std::string text, re; + boost::regex exp(re); + regex_match(text, exp); +} \ No newline at end of file From 5177518fe3ed1f93c1432f4b96d8cb5d673d1be1 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Sun, 22 Jul 2018 18:25:35 +0100 Subject: [PATCH 2/3] Fix missing \n at end of file, Fix some clang warnings. Add gcc 7&8 to CI tests. --- .travis.yml | 36 ++++++++++++++++++++++++++++ include/boost/regex/v4/instances.hpp | 2 ++ test/test_warnings.cpp | 19 ++++++++++++++- 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ae6c5e50..4b1ab15e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -102,6 +102,42 @@ matrix: sources: - ubuntu-toolchain-r-test + - os: linux + env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11 CXXSTD_DIALECT=cxxstd-dialect=gnu + addons: + apt: + packages: + - g++-7 + sources: + - ubuntu-toolchain-r-test + + - os: linux + env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=14,1z CXXSTD_DIALECT=cxxstd-dialect=gnu + addons: + apt: + packages: + - g++-7 + sources: + - ubuntu-toolchain-r-test + + - os: linux + env: TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11 CXXSTD_DIALECT=cxxstd-dialect=gnu + addons: + apt: + packages: + - g++-8 + sources: + - ubuntu-toolchain-r-test + + - os: linux + env: TOOLSET=gcc COMPILER=g++-8 CXXSTD=14,1z CXXSTD_DIALECT=cxxstd-dialect=gnu + addons: + apt: + packages: + - g++-8 + sources: + - ubuntu-toolchain-r-test + - os: linux env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11 diff --git a/include/boost/regex/v4/instances.hpp b/include/boost/regex/v4/instances.hpp index b70437e7..f695f01a 100644 --- a/include/boost/regex/v4/instances.hpp +++ b/include/boost/regex/v4/instances.hpp @@ -124,8 +124,10 @@ template class BOOST_REGEX_TEMPLATE_DECL ::boost::BOOST_REGEX_DETAIL_NS::perl_ma #ifdef __clang__ #pragma clang diagnostic push +#if (__clang_major__ > 3) || ((__clang_major__ == 3) && (__clang_minor__ > 5)) #pragma clang diagnostic ignored "-Wkeyword-macro" #endif +#endif # ifndef BOOST_REGEX_INSTANTIATE # ifdef __GNUC__ diff --git a/test/test_warnings.cpp b/test/test_warnings.cpp index 1c2a41d3..f85d437d 100644 --- a/test/test_warnings.cpp +++ b/test/test_warnings.cpp @@ -1,7 +1,23 @@ +/* +* +* Copyright (c) 2018 +* John Maddock +* +* Use, modification and distribution are subject to the +* Boost Software License, Version 1.0. (See accompanying file +* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +* +*/ + + #ifdef _MSC_VER #pragma warning(disable:4820 4668) #endif +#ifdef __APPLE_CC__ +#pragma clang diagnostic ignored "-Wc++11-long-long" +#endif + #include void test_proc() @@ -9,4 +25,5 @@ void test_proc() std::string text, re; boost::regex exp(re); regex_match(text, exp); -} \ No newline at end of file +} + From f5b7d3a4f9e927fc632a1c1ea694b14baefe3a7a Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Mon, 23 Jul 2018 19:10:47 +0100 Subject: [PATCH 3/3] Correct apple clang version check. --- include/boost/regex/v4/instances.hpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/include/boost/regex/v4/instances.hpp b/include/boost/regex/v4/instances.hpp index f695f01a..0e423437 100644 --- a/include/boost/regex/v4/instances.hpp +++ b/include/boost/regex/v4/instances.hpp @@ -122,11 +122,17 @@ template class BOOST_REGEX_TEMPLATE_DECL ::boost::BOOST_REGEX_DETAIL_NS::perl_ma #elif (defined(__GNUC__) && (__GNUC__ >= 3)) || !defined(BOOST_NO_CXX11_EXTERN_TEMPLATE) -#ifdef __clang__ -#pragma clang diagnostic push -#if (__clang_major__ > 3) || ((__clang_major__ == 3) && (__clang_minor__ > 5)) -#pragma clang diagnostic ignored "-Wkeyword-macro" -#endif +#if defined(__clang__) +# pragma clang diagnostic push +# if defined(__APPLE_CC__) +# if (__clang_major__ > 6) +# pragma clang diagnostic ignored "-Wkeyword-macro" +# endif +# else +# if (__clang_major__ > 3) || ((__clang_major__ == 3) && (__clang_minor__ > 5)) +# pragma clang diagnostic ignored "-Wkeyword-macro" +# endif +# endif #endif # ifndef BOOST_REGEX_INSTANTIATE