From: Jason Merrill Date: Mon, 3 Nov 2025 15:55:06 +0000 (+0300) Subject: libstdc++: add attributes to more ios_base types X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=725ce34b6c27a1d840a03911644f4d248858c83d;p=thirdparty%2Fgcc.git libstdc++: add attributes to more ios_base types In r15-3499 I added attributes to _Ios_Openmode to avoid -Wswitch false positives; let's do the same for the other enums in ios_base. It also seems to me that with these attributes, the tests don't need to include the end/max/min cases. libstdc++-v3/ChangeLog: * include/bits/ios_base.h: Add attribs to _Ios_Fmtflags, _Ios_Iostate, _ios_seekdir. * testsuite/27_io/ios_base/types/fmtflags/case_label.cc: Remove unneeded cases. * testsuite/27_io/ios_base/types/iostate/case_label.cc: Likewise. * testsuite/27_io/ios_base/types/openmode/case_label.cc: Likewise. * testsuite/27_io/ios_base/types/seekdir/case_label.cc: Likewise. --- diff --git a/libstdc++-v3/include/bits/ios_base.h b/libstdc++-v3/include/bits/ios_base.h index b94b2cddcd98..adc2982059ab 100644 --- a/libstdc++-v3/include/bits/ios_base.h +++ b/libstdc++-v3/include/bits/ios_base.h @@ -56,7 +56,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // as permitted (but not required) in the standard, in order to provide // better type safety in iostream calls. A side effect is that in C++98 // expressions involving them are not compile-time constants. - enum _Ios_Fmtflags + enum __attribute__((__flag_enum__)) _Ios_Fmtflags { _S_boolalpha = 1L << 0, _S_dec = 1L << 1, @@ -76,9 +76,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_max = __INT_MAX__, - _S_ios_fmtflags_min = ~__INT_MAX__ + _S_ios_fmtflags_end __attribute__((__unused__)) = 1L << 16, + _S_ios_fmtflags_max __attribute__((__unused__)) = __INT_MAX__, + _S_ios_fmtflags_min __attribute__((__unused__)) = ~__INT_MAX__ }; _GLIBCXX_NODISCARD _GLIBCXX_CONSTEXPR @@ -176,15 +176,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __a = __a ^ __b; } - enum _Ios_Iostate + enum __attribute__((__flag_enum__)) _Ios_Iostate { _S_goodbit = 0, _S_badbit = 1L << 0, _S_eofbit = 1L << 1, _S_failbit = 1L << 2, - _S_ios_iostate_end = 1L << 16, - _S_ios_iostate_max = __INT_MAX__, - _S_ios_iostate_min = ~__INT_MAX__ + _S_ios_iostate_end __attribute__((__unused__)) = 1L << 16, + _S_ios_iostate_max __attribute__((__unused__)) = __INT_MAX__, + _S_ios_iostate_min __attribute__((__unused__)) = ~__INT_MAX__ }; _GLIBCXX_NODISCARD _GLIBCXX_CONSTEXPR @@ -228,7 +228,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _S_beg = 0, _S_cur = _GLIBCXX_STDIO_SEEK_CUR, _S_end = _GLIBCXX_STDIO_SEEK_END, - _S_ios_seekdir_end = 1L << 16 + _S_ios_seekdir_end __attribute__((__unused__)) = 1L << 16 }; #if __cplusplus >= 201103L 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 c72e00f87b5c..6f0390b6cffb 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 @@ -68,12 +68,6 @@ case_labels(bitmask_type b) break; case std::ios_base::floatfield: break; - case std::_S_ios_fmtflags_end: - break; - case __INT_MAX__: - break; - case ~__INT_MAX__: - break; } using underlying_type = std::underlying_type::type; static_assert( sizeof(underlying_type) == sizeof(int), 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 6a1dd90f67ba..410f74642838 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 @@ -40,12 +40,6 @@ case_labels(bitmask_type b) break; case std::ios_base::failbit: break; - case std::_S_ios_iostate_end: - break; - case __INT_MAX__: - break; - case ~__INT_MAX__: - break; } using underlying_type = std::underlying_type::type; static_assert( sizeof(underlying_type) == sizeof(int), 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 e132070bf487..44b84a9821f8 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 @@ -48,12 +48,6 @@ case_labels(bitmask_type b) case std::ios_base::noreplace: break; #endif - case std::_S_ios_openmode_end: - break; - case __INT_MAX__: - break; - case ~__INT_MAX__: - break; } using underlying_type = std::underlying_type::type; static_assert( sizeof(underlying_type) == sizeof(int), diff --git a/libstdc++-v3/testsuite/27_io/ios_base/types/seekdir/case_label.cc b/libstdc++-v3/testsuite/27_io/ios_base/types/seekdir/case_label.cc index c7b9817932d0..2dd1560339db 100644 --- a/libstdc++-v3/testsuite/27_io/ios_base/types/seekdir/case_label.cc +++ b/libstdc++-v3/testsuite/27_io/ios_base/types/seekdir/case_label.cc @@ -38,7 +38,5 @@ case_labels(test_type b) break; case std::ios_base::end: break; - case std::_S_ios_fmtflags_end: - break; } }