On Thu, 5 Sept 2024 at 22:00, Jason Merrill <ja...@redhat.com> wrote:
>
> Tested x86_64-pc-linux-gnu, OK for trunk?

OK, thanks.

>
> -- 8< --
>
> In addition to marking it as flag_enum, we want to avoid warnings about
> not having a case for the implementation detail enumerators
> _S_ios_openmode_*.  And also for _S_noreplace in standard modes before it
> was added.
>
> libstdc++-v3/ChangeLog:
>
>         * include/bits/ios_base.h (_GLIBCXX_NOREPLACE_UNUSED): New.
>         (_Ios_Openmode): Add unused attributes.
>         * testsuite/27_io/ios_base/types/openmode/case_label.cc: Handle
>         noreplace.
> ---
>  libstdc++-v3/include/bits/ios_base.h          | 19 ++++++++++++++-----
>  .../ios_base/types/openmode/case_label.cc     |  4 ++++
>  2 files changed, 18 insertions(+), 5 deletions(-)
>
> diff --git a/libstdc++-v3/include/bits/ios_base.h 
> b/libstdc++-v3/include/bits/ios_base.h
> index b69151c49ad..6e343658096 100644
> --- a/libstdc++-v3/include/bits/ios_base.h
> +++ b/libstdc++-v3/include/bits/ios_base.h
> @@ -114,8 +114,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>    operator^=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b) _GLIBCXX_NOTHROW
>    { return __a = __a ^ __b; }
>
> +  // If std::ios_base::noreplace isn't available, -Wswitch should ignore
> +  // _S_noreplace.
> +#ifdef __glibcxx_ios_noreplace
> +#define _NOREPLACE_UNUSED
> +#else
> +#define _NOREPLACE_UNUSED __attribute__((__unused__))
> +#endif
>
> -  enum _Ios_Openmode
> +  enum __attribute__((__flag_enum__)) _Ios_Openmode
>      {
>        _S_app           = 1L << 0,
>        _S_ate           = 1L << 1,
> @@ -123,12 +130,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>        _S_in            = 1L << 3,
>        _S_out           = 1L << 4,
>        _S_trunc                 = 1L << 5,
> -      _S_noreplace     = 1L << 6,
> -      _S_ios_openmode_end = 1L << 16,
> -      _S_ios_openmode_max = __INT_MAX__,
> -      _S_ios_openmode_min = ~__INT_MAX__
> +      _S_noreplace _NOREPLACE_UNUSED = 1L << 6,
> +      _S_ios_openmode_end __attribute__((__unused__)) = 1L << 16,
> +      _S_ios_openmode_max __attribute__((__unused__)) = __INT_MAX__,
> +      _S_ios_openmode_min __attribute__((__unused__)) = ~__INT_MAX__
>      };
>
> +#undef _NOREPLACE_UNUSED
> +
>    _GLIBCXX_NODISCARD _GLIBCXX_CONSTEXPR
>    inline _Ios_Openmode
>    operator&(_Ios_Openmode __a, _Ios_Openmode __b) _GLIBCXX_NOTHROW
> 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 95c86588a54..9e388a51294 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
> @@ -44,6 +44,10 @@ case_labels(bitmask_type b)
>        break;
>      case std::ios_base::trunc:
>        break;
> +#ifdef __glibcxx_ios_noreplace
> +    case std::ios_base::noreplace:
> +      break;
> +#endif
>      case std::_S_ios_openmode_end:
>        break;
>      case __INT_MAX__:
>
> base-commit: b214ffeecb3f480dd7864bcbfc9ac30100c126f3
> --
> 2.46.0
>

Reply via email to