]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: add attributes to more ios_base types
authorJason Merrill <jason@redhat.com>
Mon, 3 Nov 2025 15:55:06 +0000 (18:55 +0300)
committerJason Merrill <jason@redhat.com>
Mon, 3 Nov 2025 15:55:06 +0000 (18:55 +0300)
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.

libstdc++-v3/include/bits/ios_base.h
libstdc++-v3/testsuite/27_io/ios_base/types/fmtflags/case_label.cc
libstdc++-v3/testsuite/27_io/ios_base/types/iostate/case_label.cc
libstdc++-v3/testsuite/27_io/ios_base/types/openmode/case_label.cc
libstdc++-v3/testsuite/27_io/ios_base/types/seekdir/case_label.cc

index b94b2cddcd98d31ed09e9cf67145335b29458886..adc2982059abad614c855a64773ab54c7f3f5438 100644 (file)
@@ -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
index c72e00f87b5cff0ecbd68c8f2abf923e6465bc2c..6f0390b6cffbcfc42ab1be290b22259fe5173766 100644 (file)
@@ -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<bitmask_type>::type;
   static_assert( sizeof(underlying_type) == sizeof(int),
index 6a1dd90f67baba3174dfe15b9da76e787a817c64..410f7464283842e1c5fd1b959d36dd6849e7ba88 100644 (file)
@@ -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<bitmask_type>::type;
   static_assert( sizeof(underlying_type) == sizeof(int),
index e132070bf48736dc32ff442e9fdb56504ad0ae40..44b84a9821f818fd2df90a89471a043aa3deae68 100644 (file)
@@ -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<bitmask_type>::type;
   static_assert( sizeof(underlying_type) == sizeof(int),
index c7b9817932d0a2f5b887e9b955c0b8e4574bc3c9..2dd1560339db13127951c3f2332390d5779a79e7 100644 (file)
@@ -38,7 +38,5 @@ case_labels(test_type b)
       break;
     case std::ios_base::end:
       break;
-    case std::_S_ios_fmtflags_end:
-      break;
     }
 }