From 199577821118e1348a4ebe96ea8e77a135d41d61 Mon Sep 17 00:00:00 2001 From: Glen Fernandes Date: Mon, 29 May 2017 09:34:41 -0400 Subject: [PATCH] Add BOOST_NO_CXX17_INLINE_VARIABLES detection --- checks/Jamfile.v2 | 3 +- checks/test_case.cpp | 7 +++- include/boost/config/compiler/clang.hpp | 9 +++++ include/boost/config/compiler/common_edg.hpp | 3 ++ include/boost/config/compiler/digitalmars.hpp | 3 ++ include/boost/config/compiler/gcc.hpp | 3 ++ include/boost/config/compiler/gcc_xml.hpp | 3 ++ include/boost/config/compiler/metrowerks.hpp | 3 ++ include/boost/config/compiler/mpw.hpp | 3 ++ include/boost/config/compiler/pathscale.hpp | 3 ++ include/boost/config/compiler/pgi.hpp | 3 ++ include/boost/config/compiler/sunpro_cc.hpp | 3 ++ include/boost/config/compiler/vacpp.hpp | 3 ++ include/boost/config/compiler/visualc.hpp | 1 + include/boost/config/compiler/xlcpp.hpp | 9 +++++ include/boost/config/compiler/xlcpp_zos.hpp | 1 + test/all/Jamfile.v2 | 5 ++- test/boost_no_cxx17_inline_variables.ipp | 27 ++++++++++++++ test/config_info.cpp | 2 + test/config_test.cpp | 12 +++++- test/no_cxx17_inline_variables_fail.cpp | 37 +++++++++++++++++++ test/no_cxx17_inline_variables_pass.cpp | 37 +++++++++++++++++++ 22 files changed, 176 insertions(+), 4 deletions(-) create mode 100644 test/boost_no_cxx17_inline_variables.ipp create mode 100644 test/no_cxx17_inline_variables_fail.cpp create mode 100644 test/no_cxx17_inline_variables_pass.cpp diff --git a/checks/Jamfile.v2 b/checks/Jamfile.v2 index 73ece5f5..fe46f896 100644 --- a/checks/Jamfile.v2 +++ b/checks/Jamfile.v2 @@ -1,6 +1,6 @@ # # *** DO NOT EDIT THIS FILE BY HAND *** -# This file was automatically generated on Mon May 29 09:56:04 2017 +# This file was automatically generated on Mon May 29 10:00:26 2017 # by libs/config/tools/generate.cpp # Copyright John Maddock. # Use, modification and distribution are subject to the @@ -109,6 +109,7 @@ obj cxx14_aggregate_nsdmi : test_case.cpp : TEST_BOOST_NO_CXX14_AGGREGAT obj cxx14_return_type_deduction : test_case.cpp : TEST_BOOST_NO_CXX14_RETURN_TYPE_DEDUCTION ; obj cxx14_std_exchange : test_case.cpp : TEST_BOOST_NO_CXX14_STD_EXCHANGE ; obj cxx14_variable_templates : test_case.cpp : TEST_BOOST_NO_CXX14_VARIABLE_TEMPLATES ; +obj cxx17_inline_variables : test_case.cpp : TEST_BOOST_NO_CXX17_INLINE_VARIABLES ; obj cxx17_std_apply : test_case.cpp : TEST_BOOST_NO_CXX17_STD_APPLY ; obj cxx17_std_invoke : test_case.cpp : TEST_BOOST_NO_CXX17_STD_INVOKE ; obj cxx17_structured_bindings : test_case.cpp : TEST_BOOST_NO_CXX17_STRUCTURED_BINDINGS ; diff --git a/checks/test_case.cpp b/checks/test_case.cpp index f27fb2bd..3de59c60 100644 --- a/checks/test_case.cpp +++ b/checks/test_case.cpp @@ -1,4 +1,4 @@ -// This file was automatically generated on Mon May 29 09:56:04 2017 +// This file was automatically generated on Mon May 29 10:00:26 2017 // by libs/config/tools/generate.cpp // Copyright John Maddock 2002-4. // Use, modification and distribution are subject to the @@ -501,6 +501,11 @@ # error "Defect macro BOOST_NO_CXX14_VARIABLE_TEMPLATES is defined." # endif #endif +#ifdef TEST_BOOST_NO_CXX17_INLINE_VARIABLES +# ifdef BOOST_NO_CXX17_INLINE_VARIABLES +# error "Defect macro BOOST_NO_CXX17_INLINE_VARIABLES is defined." +# endif +#endif #ifdef TEST_BOOST_NO_CXX17_STD_APPLY # ifdef BOOST_NO_CXX17_STD_APPLY # error "Defect macro BOOST_NO_CXX17_STD_APPLY is defined." diff --git a/include/boost/config/compiler/clang.hpp b/include/boost/config/compiler/clang.hpp index d7f7ecc1..dc020173 100644 --- a/include/boost/config/compiler/clang.hpp +++ b/include/boost/config/compiler/clang.hpp @@ -27,6 +27,10 @@ #define __has_attribute(x) 0 #endif +#ifndef __has_cpp_attribute +#define __has_cpp_attribute(x) 0 +#endif + #if !__has_feature(cxx_exceptions) && !defined(BOOST_NO_EXCEPTIONS) # define BOOST_NO_EXCEPTIONS #endif @@ -286,6 +290,11 @@ # define BOOST_NO_CXX17_STRUCTURED_BINDINGS #endif +// Clang 3.9+ in c++1z +#if !__has_cpp_attribute(fallthrough) || __cplusplus < 201406L +# define BOOST_NO_CXX17_INLINE_VARIABLES +#endif + #if __cplusplus < 201103L #define BOOST_NO_CXX11_SFINAE_EXPR #endif diff --git a/include/boost/config/compiler/common_edg.hpp b/include/boost/config/compiler/common_edg.hpp index b1eea14d..a34f3f37 100644 --- a/include/boost/config/compiler/common_edg.hpp +++ b/include/boost/config/compiler/common_edg.hpp @@ -142,6 +142,9 @@ #if !defined(__cpp_structured_bindings) || (__cpp_structured_bindings < 201606) # define BOOST_NO_CXX17_STRUCTURED_BINDINGS #endif +#if !defined(__cpp_inline_variables) || (__cpp_inline_variables < 201606) +# define BOOST_NO_CXX17_INLINE_VARIABLES +#endif #ifdef c_plusplus // EDG has "long long" in non-strict mode diff --git a/include/boost/config/compiler/digitalmars.hpp b/include/boost/config/compiler/digitalmars.hpp index 5c680248..2e48c55b 100644 --- a/include/boost/config/compiler/digitalmars.hpp +++ b/include/boost/config/compiler/digitalmars.hpp @@ -118,6 +118,9 @@ #if !defined(__cpp_structured_bindings) || (__cpp_structured_bindings < 201606) # define BOOST_NO_CXX17_STRUCTURED_BINDINGS #endif +#if !defined(__cpp_inline_variables) || (__cpp_inline_variables < 201606) +# define BOOST_NO_CXX17_INLINE_VARIABLES +#endif #if (__DMC__ <= 0x840) #error "Compiler not supported or configured - please reconfigure" diff --git a/include/boost/config/compiler/gcc.hpp b/include/boost/config/compiler/gcc.hpp index 0272333a..e66c23b8 100644 --- a/include/boost/config/compiler/gcc.hpp +++ b/include/boost/config/compiler/gcc.hpp @@ -292,6 +292,9 @@ #if !defined(__cpp_structured_bindings) || (__cpp_structured_bindings < 201606) # define BOOST_NO_CXX17_STRUCTURED_BINDINGS #endif +#if !defined(__cpp_inline_variables) || (__cpp_inline_variables < 201606) +# define BOOST_NO_CXX17_INLINE_VARIABLES +#endif // // Unused attribute: diff --git a/include/boost/config/compiler/gcc_xml.hpp b/include/boost/config/compiler/gcc_xml.hpp index a71c1682..9bcda105 100644 --- a/include/boost/config/compiler/gcc_xml.hpp +++ b/include/boost/config/compiler/gcc_xml.hpp @@ -96,6 +96,9 @@ #if !defined(__cpp_structured_bindings) || (__cpp_structured_bindings < 201606) # define BOOST_NO_CXX17_STRUCTURED_BINDINGS #endif +#if !defined(__cpp_inline_variables) || (__cpp_inline_variables < 201606) +# define BOOST_NO_CXX17_INLINE_VARIABLES +#endif #define BOOST_COMPILER "GCC-XML C++ version " __GCCXML__ diff --git a/include/boost/config/compiler/metrowerks.hpp b/include/boost/config/compiler/metrowerks.hpp index 24b26437..852fa3ae 100644 --- a/include/boost/config/compiler/metrowerks.hpp +++ b/include/boost/config/compiler/metrowerks.hpp @@ -161,6 +161,9 @@ #if !defined(__cpp_structured_bindings) || (__cpp_structured_bindings < 201606) # define BOOST_NO_CXX17_STRUCTURED_BINDINGS #endif +#if !defined(__cpp_inline_variables) || (__cpp_inline_variables < 201606) +# define BOOST_NO_CXX17_INLINE_VARIABLES +#endif #define BOOST_COMPILER "Metrowerks CodeWarrior C++ version " BOOST_STRINGIZE(BOOST_COMPILER_VERSION) diff --git a/include/boost/config/compiler/mpw.hpp b/include/boost/config/compiler/mpw.hpp index 687a3595..7160e52e 100644 --- a/include/boost/config/compiler/mpw.hpp +++ b/include/boost/config/compiler/mpw.hpp @@ -110,6 +110,9 @@ #if !defined(__cpp_structured_bindings) || (__cpp_structured_bindings < 201606) # define BOOST_NO_CXX17_STRUCTURED_BINDINGS #endif +#if !defined(__cpp_inline_variables) || (__cpp_inline_variables < 201606) +# define BOOST_NO_CXX17_INLINE_VARIABLES +#endif // // versions check: diff --git a/include/boost/config/compiler/pathscale.hpp b/include/boost/config/compiler/pathscale.hpp index aa5cc8c1..47d7b9e6 100644 --- a/include/boost/config/compiler/pathscale.hpp +++ b/include/boost/config/compiler/pathscale.hpp @@ -123,4 +123,7 @@ #if !defined(__cpp_structured_bindings) || (__cpp_structured_bindings < 201606) # define BOOST_NO_CXX17_STRUCTURED_BINDINGS #endif +#if !defined(__cpp_inline_variables) || (__cpp_inline_variables < 201606) +# define BOOST_NO_CXX17_INLINE_VARIABLES +#endif #endif diff --git a/include/boost/config/compiler/pgi.hpp b/include/boost/config/compiler/pgi.hpp index 4f851b9a..8999ad03 100644 --- a/include/boost/config/compiler/pgi.hpp +++ b/include/boost/config/compiler/pgi.hpp @@ -156,6 +156,9 @@ #if !defined(__cpp_structured_bindings) || (__cpp_structured_bindings < 201606) # define BOOST_NO_CXX17_STRUCTURED_BINDINGS #endif +#if !defined(__cpp_inline_variables) || (__cpp_inline_variables < 201606) +# define BOOST_NO_CXX17_INLINE_VARIABLES +#endif // // version check: // probably nothing to do here? diff --git a/include/boost/config/compiler/sunpro_cc.hpp b/include/boost/config/compiler/sunpro_cc.hpp index 8efd0bfb..628d237f 100644 --- a/include/boost/config/compiler/sunpro_cc.hpp +++ b/include/boost/config/compiler/sunpro_cc.hpp @@ -176,6 +176,9 @@ #if !defined(__cpp_structured_bindings) || (__cpp_structured_bindings < 201606) # define BOOST_NO_CXX17_STRUCTURED_BINDINGS #endif +#if !defined(__cpp_inline_variables) || (__cpp_inline_variables < 201606) +# define BOOST_NO_CXX17_INLINE_VARIABLES +#endif // Turn on threading support for Solaris 12. // Ticket #11972 diff --git a/include/boost/config/compiler/vacpp.hpp b/include/boost/config/compiler/vacpp.hpp index a31fd12f..9838008a 100644 --- a/include/boost/config/compiler/vacpp.hpp +++ b/include/boost/config/compiler/vacpp.hpp @@ -167,3 +167,6 @@ #if !defined(__cpp_structured_bindings) || (__cpp_structured_bindings < 201606) # define BOOST_NO_CXX17_STRUCTURED_BINDINGS #endif +#if !defined(__cpp_inline_variables) || (__cpp_inline_variables < 201606) +# define BOOST_NO_CXX17_INLINE_VARIABLES +#endif diff --git a/include/boost/config/compiler/visualc.hpp b/include/boost/config/compiler/visualc.hpp index 4786616d..726fcf8e 100644 --- a/include/boost/config/compiler/visualc.hpp +++ b/include/boost/config/compiler/visualc.hpp @@ -220,6 +220,7 @@ #define BOOST_NO_CXX11_SFINAE_EXPR // C++ 17: #define BOOST_NO_CXX17_STRUCTURED_BINDINGS +#define BOOST_NO_CXX17_INLINE_VARIABLES // // Things that don't work in clr mode: diff --git a/include/boost/config/compiler/xlcpp.hpp b/include/boost/config/compiler/xlcpp.hpp index 2bce08ac..f8161110 100644 --- a/include/boost/config/compiler/xlcpp.hpp +++ b/include/boost/config/compiler/xlcpp.hpp @@ -23,6 +23,10 @@ #define __has_extension __has_feature #endif +#ifndef __has_cpp_attribute +#define __has_cpp_attribute(x) 0 +#endif + #if !__has_feature(cxx_exceptions) && !defined(BOOST_NO_EXCEPTIONS) # define BOOST_NO_EXCEPTIONS #endif @@ -242,6 +246,11 @@ # define BOOST_NO_CXX17_STRUCTURED_BINDINGS #endif +// Clang 3.9+ in c++1z +#if !__has_cpp_attribute(fallthrough) || __cplusplus < 201406L +# define BOOST_NO_CXX17_INLINE_VARIABLES +#endif + #if !__has_feature(cxx_thread_local) # define BOOST_NO_CXX11_THREAD_LOCAL #endif diff --git a/include/boost/config/compiler/xlcpp_zos.hpp b/include/boost/config/compiler/xlcpp_zos.hpp index cc5e2363..846c837a 100644 --- a/include/boost/config/compiler/xlcpp_zos.hpp +++ b/include/boost/config/compiler/xlcpp_zos.hpp @@ -151,6 +151,7 @@ #define BOOST_NO_CXX14_CONSTEXPR #define BOOST_NO_CXX14_BINARY_LITERALS #define BOOST_NO_CXX17_STRUCTURED_BINDINGS +#define BOOST_NO_CXX17_INLINE_VARIABLES // ------------------------------------- diff --git a/test/all/Jamfile.v2 b/test/all/Jamfile.v2 index c47fd69c..b8270835 100644 --- a/test/all/Jamfile.v2 +++ b/test/all/Jamfile.v2 @@ -1,7 +1,7 @@ # # Regression test Jamfile for boost configuration setup. # *** DO NOT EDIT THIS FILE BY HAND *** -# This file was automatically generated on Mon May 29 09:56:04 2017 +# This file was automatically generated on Mon May 29 10:00:26 2017 # by libs/config/tools/generate.cpp # Copyright John Maddock. # Use, modification and distribution are subject to the @@ -316,6 +316,9 @@ test-suite "BOOST_NO_CXX14_STD_EXCHANGE" : test-suite "BOOST_NO_CXX14_VARIABLE_TEMPLATES" : [ run ../no_cxx14_var_templ_pass.cpp ] [ compile-fail ../no_cxx14_var_templ_fail.cpp ] ; +test-suite "BOOST_NO_CXX17_INLINE_VARIABLES" : +[ run ../no_cxx17_inline_variables_pass.cpp ] +[ compile-fail ../no_cxx17_inline_variables_fail.cpp ] ; test-suite "BOOST_NO_CXX17_STD_APPLY" : [ run ../no_cxx17_std_apply_pass.cpp ] [ compile-fail ../no_cxx17_std_apply_fail.cpp ] ; diff --git a/test/boost_no_cxx17_inline_variables.ipp b/test/boost_no_cxx17_inline_variables.ipp new file mode 100644 index 00000000..d144ed9a --- /dev/null +++ b/test/boost_no_cxx17_inline_variables.ipp @@ -0,0 +1,27 @@ +/* +Copyright 2017 Glen Joseph Fernandes +(glenjofe@gmail.com) + +Distributed under Boost Software License, Version 1.0. +(See accompanying file LICENSE_1_0.txt or copy at +http://www.boost.org/LICENSE_1_0.txt) +*/ + +// MACRO: BOOST_NO_CXX17_INLINE_VARIABLES +// TITLE: C++17 inline variables +// DESCRIPTION: C++17 inline variables are not supported. + +namespace boost_no_cxx17_inline_variables { + +inline const int Value = 1; + +struct Type { + static inline const int value = 1; +}; + +int test() +{ + return Type::value - Value; +} + +} /* boost_no_cxx17_inline_variables */ diff --git a/test/config_info.cpp b/test/config_info.cpp index dee413c7..9beeb65f 100644 --- a/test/config_info.cpp +++ b/test/config_info.cpp @@ -1067,6 +1067,7 @@ void print_boost_macros() PRINT_MACRO(BOOST_NO_CXX14_RETURN_TYPE_DEDUCTION); PRINT_MACRO(BOOST_NO_CXX14_STD_EXCHANGE); PRINT_MACRO(BOOST_NO_CXX14_VARIABLE_TEMPLATES); + PRINT_MACRO(BOOST_NO_CXX17_INLINE_VARIABLES); PRINT_MACRO(BOOST_NO_CXX17_STD_APPLY); PRINT_MACRO(BOOST_NO_CXX17_STD_INVOKE); PRINT_MACRO(BOOST_NO_CXX17_STRUCTURED_BINDINGS); @@ -1158,6 +1159,7 @@ void print_boost_macros() + // END GENERATED BLOCK diff --git a/test/config_test.cpp b/test/config_test.cpp index 6860b00b..4bc52a0e 100644 --- a/test/config_test.cpp +++ b/test/config_test.cpp @@ -1,4 +1,4 @@ -// This file was automatically generated on Mon May 29 09:56:04 2017 +// This file was automatically generated on Mon May 29 10:00:26 2017 // by libs/config/tools/generate.cpp // Copyright John Maddock 2002-4. // Use, modification and distribution are subject to the @@ -332,6 +332,11 @@ namespace boost_no_cxx14_std_exchange = empty_boost; #else namespace boost_no_cxx14_variable_templates = empty_boost; #endif +#ifndef BOOST_NO_CXX17_INLINE_VARIABLES +#include "boost_no_cxx17_inline_variables.ipp" +#else +namespace boost_no_cxx17_inline_variables = empty_boost; +#endif #ifndef BOOST_NO_CXX17_STD_APPLY #include "boost_no_cxx17_std_apply.ipp" #else @@ -1456,6 +1461,11 @@ int main( int, char *[] ) std::cerr << "Failed test for BOOST_NO_CXX14_VARIABLE_TEMPLATES at: " << __FILE__ << ":" << __LINE__ << std::endl; ++error_count; } + if(0 != boost_no_cxx17_inline_variables::test()) + { + std::cerr << "Failed test for BOOST_NO_CXX17_INLINE_VARIABLES at: " << __FILE__ << ":" << __LINE__ << std::endl; + ++error_count; + } if(0 != boost_no_cxx17_std_apply::test()) { std::cerr << "Failed test for BOOST_NO_CXX17_STD_APPLY at: " << __FILE__ << ":" << __LINE__ << std::endl; diff --git a/test/no_cxx17_inline_variables_fail.cpp b/test/no_cxx17_inline_variables_fail.cpp new file mode 100644 index 00000000..58e688b3 --- /dev/null +++ b/test/no_cxx17_inline_variables_fail.cpp @@ -0,0 +1,37 @@ +// This file was automatically generated on Mon May 29 10:00:26 2017 +// by libs/config/tools/generate.cpp +// Copyright John Maddock 2002-4. +// 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) + +// See http://www.boost.org/libs/config for the most recent version.// +// Revision $Id$ +// + + +// Test file for macro BOOST_NO_CXX17_INLINE_VARIABLES +// This file should not compile, if it does then +// BOOST_NO_CXX17_INLINE_VARIABLES should not be defined. +// See file boost_no_cxx17_inline_variables.ipp for details + +// Must not have BOOST_ASSERT_CONFIG set; it defeats +// the objective of this file: +#ifdef BOOST_ASSERT_CONFIG +# undef BOOST_ASSERT_CONFIG +#endif + +#include +#include "test.hpp" + +#ifdef BOOST_NO_CXX17_INLINE_VARIABLES +#include "boost_no_cxx17_inline_variables.ipp" +#else +#error "this file should not compile" +#endif + +int main( int, char *[] ) +{ + return boost_no_cxx17_inline_variables::test(); +} + diff --git a/test/no_cxx17_inline_variables_pass.cpp b/test/no_cxx17_inline_variables_pass.cpp new file mode 100644 index 00000000..ec5f69e2 --- /dev/null +++ b/test/no_cxx17_inline_variables_pass.cpp @@ -0,0 +1,37 @@ +// This file was automatically generated on Mon May 29 10:00:26 2017 +// by libs/config/tools/generate.cpp +// Copyright John Maddock 2002-4. +// 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) + +// See http://www.boost.org/libs/config for the most recent version.// +// Revision $Id$ +// + + +// Test file for macro BOOST_NO_CXX17_INLINE_VARIABLES +// This file should compile, if it does not then +// BOOST_NO_CXX17_INLINE_VARIABLES should be defined. +// See file boost_no_cxx17_inline_variables.ipp for details + +// Must not have BOOST_ASSERT_CONFIG set; it defeats +// the objective of this file: +#ifdef BOOST_ASSERT_CONFIG +# undef BOOST_ASSERT_CONFIG +#endif + +#include +#include "test.hpp" + +#ifndef BOOST_NO_CXX17_INLINE_VARIABLES +#include "boost_no_cxx17_inline_variables.ipp" +#else +namespace boost_no_cxx17_inline_variables = empty_boost; +#endif + +int main( int, char *[] ) +{ + return boost_no_cxx17_inline_variables::test(); +} +