From fbfae2f0897fe5e0e7ac86fa326e8e03b1a162e9 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Thu, 12 Nov 2015 17:08:42 +0000 Subject: [PATCH] Extend valid values of iostream bitmask types PR libstdc++/56158 * include/bits/ios_base.h (_Ios_Fmtflags, _Ios_Openmode, _Ios_Iostate): Define enumerators to ensure all values of type int are valid values of the enumeration type. * testsuite/27_io/ios_base/types/fmtflags/case_label.cc: Add new cases. * testsuite/27_io/ios_base/types/iostate/case_label.cc: Likewise. * testsuite/27_io/ios_base/types/openmode/case_label.cc: Likewise. From-SVN: r230267 --- libstdc++-v3/ChangeLog | 8 ++++++++ libstdc++-v3/include/bits/ios_base.h | 12 +++++++++--- .../27_io/ios_base/types/fmtflags/case_label.cc | 4 ++++ .../27_io/ios_base/types/iostate/case_label.cc | 4 ++++ .../27_io/ios_base/types/openmode/case_label.cc | 4 ++++ 5 files changed, 29 insertions(+), 3 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 2222b572d03..e1cc38ff1ef 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,13 @@ 2015-11-12 Jonathan Wakely + PR libstdc++/56158 + * include/bits/ios_base.h (_Ios_Fmtflags, _Ios_Openmode, _Ios_Iostate): + Define enumerators to ensure all values of type int are valid values + of the enumeration type. + * testsuite/27_io/ios_base/types/fmtflags/case_label.cc: Add new cases. + * testsuite/27_io/ios_base/types/iostate/case_label.cc: Likewise. + * testsuite/27_io/ios_base/types/openmode/case_label.cc: Likewise. + * include/std/thread: Include for EINTR. 2015-11-12 Ville Voutilainen diff --git a/libstdc++-v3/include/bits/ios_base.h b/libstdc++-v3/include/bits/ios_base.h index 44029ad2ce6..908ba7c7e4e 100644 --- a/libstdc++-v3/include/bits/ios_base.h +++ b/libstdc++-v3/include/bits/ios_base.h @@ -74,7 +74,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _S_adjustfield = _S_left | _S_right | _S_internal, _S_basefield = _S_dec | _S_oct | _S_hex, _S_floatfield = _S_scientific | _S_fixed, - _S_ios_fmtflags_end = 1L << 16 + _S_ios_fmtflags_end = 1L << 16, + _S_ios_fmtflags_max = __INT_MAX__, + _S_ios_fmtflags_min = ~__INT_MAX__ }; inline _GLIBCXX_CONSTEXPR _Ios_Fmtflags @@ -114,7 +116,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _S_in = 1L << 3, _S_out = 1L << 4, _S_trunc = 1L << 5, - _S_ios_openmode_end = 1L << 16 + _S_ios_openmode_end = 1L << 16, + _S_ios_openmode_max = __INT_MAX__, + _S_ios_openmode_min = ~__INT_MAX__ }; inline _GLIBCXX_CONSTEXPR _Ios_Openmode @@ -152,7 +156,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _S_badbit = 1L << 0, _S_eofbit = 1L << 1, _S_failbit = 1L << 2, - _S_ios_iostate_end = 1L << 16 + _S_ios_iostate_end = 1L << 16, + _S_ios_iostate_max = __INT_MAX__, + _S_ios_iostate_min = ~__INT_MAX__ }; inline _GLIBCXX_CONSTEXPR _Ios_Iostate diff --git a/libstdc++-v3/testsuite/27_io/ios_base/types/fmtflags/case_label.cc b/libstdc++-v3/testsuite/27_io/ios_base/types/fmtflags/case_label.cc index 591e3714366..e8820c5e84a 100644 --- a/libstdc++-v3/testsuite/27_io/ios_base/types/fmtflags/case_label.cc +++ b/libstdc++-v3/testsuite/27_io/ios_base/types/fmtflags/case_label.cc @@ -70,5 +70,9 @@ case_labels(bitmask_type b) break; case std::_S_ios_fmtflags_end: break; + case std::_S_ios_fmtflags_min: + break; + case std::_S_ios_fmtflags_max: + break; } } diff --git a/libstdc++-v3/testsuite/27_io/ios_base/types/iostate/case_label.cc b/libstdc++-v3/testsuite/27_io/ios_base/types/iostate/case_label.cc index 44fb44e7a8a..4e4e4f5e623 100644 --- a/libstdc++-v3/testsuite/27_io/ios_base/types/iostate/case_label.cc +++ b/libstdc++-v3/testsuite/27_io/ios_base/types/iostate/case_label.cc @@ -42,5 +42,9 @@ case_labels(bitmask_type b) break; case std::_S_ios_iostate_end: break; + case std::_S_ios_iostate_min: + break; + case std::_S_ios_iostate_max: + break; } } diff --git a/libstdc++-v3/testsuite/27_io/ios_base/types/openmode/case_label.cc b/libstdc++-v3/testsuite/27_io/ios_base/types/openmode/case_label.cc index 267f8a228b4..8c6672f65ce 100644 --- a/libstdc++-v3/testsuite/27_io/ios_base/types/openmode/case_label.cc +++ b/libstdc++-v3/testsuite/27_io/ios_base/types/openmode/case_label.cc @@ -46,5 +46,9 @@ case_labels(bitmask_type b) break; case std::_S_ios_openmode_end: break; + case std::_S_ios_openmode_min: + break; + case std::_S_ios_openmode_max: + break; } } -- 2.30.2