public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-6868] libstdc++: Avoid some more warnings [PR104019]
@ 2022-01-25 21:09 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2022-01-25 21:09 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:5c1f274e3e090ee03bedc22dd7169b28e759974e

commit r12-6868-g5c1f274e3e090ee03bedc22dd7169b28e759974e
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Jan 25 10:22:42 2022 +0000

    libstdc++: Avoid some more warnings [PR104019]
    
    With -fno-exceptions we get a -Wmisleading-indentation warning for:
    
      if (cond)
        __try {}
        __catch (...) {}
    
    This is because the __catch(...) expands to if (false), but is indented
    as though it is controlled by the preceding 'if'. Surround it in braces.
    
    The new make_shared<T[]> code triggers a bogus warning due to PR 61596,
    which can be disabled with a pragma.
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/104019
            * include/bits/istream.tcc (basic_istream::sentry): Add braces
            around try-block.
            * include/bits/shared_ptr_base.h (_Sp_counted_array_base::_M_init):
            Add pragmas to disable bogus warnings from PR 61596.

Diff:
---
 libstdc++-v3/include/bits/istream.tcc       | 62 +++++++++++++++--------------
 libstdc++-v3/include/bits/shared_ptr_base.h |  3 ++
 2 files changed, 35 insertions(+), 30 deletions(-)

diff --git a/libstdc++-v3/include/bits/istream.tcc b/libstdc++-v3/include/bits/istream.tcc
index cfab5b4f684..a1a7d89335e 100644
--- a/libstdc++-v3/include/bits/istream.tcc
+++ b/libstdc++-v3/include/bits/istream.tcc
@@ -48,36 +48,38 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     {
       ios_base::iostate __err = ios_base::goodbit;
       if (__in.good())
-	__try
-	  {
-	    if (__in.tie())
-	      __in.tie()->flush();
-	    if (!__noskip && bool(__in.flags() & ios_base::skipws))
-	      {
-		const __int_type __eof = traits_type::eof();
-		__streambuf_type* __sb = __in.rdbuf();
-		__int_type __c = __sb->sgetc();
-
-		const __ctype_type& __ct = __check_facet(__in._M_ctype);
-		while (!traits_type::eq_int_type(__c, __eof)
-		       && __ct.is(ctype_base::space,
-				  traits_type::to_char_type(__c)))
-		  __c = __sb->snextc();
-
-		// _GLIBCXX_RESOLVE_LIB_DEFECTS
-		// 195. Should basic_istream::sentry's constructor ever
-		// set eofbit?
-		if (traits_type::eq_int_type(__c, __eof))
-		  __err |= ios_base::eofbit;
-	      }
-	  }
-	__catch(__cxxabiv1::__forced_unwind&)
-	  {
-	    __in._M_setstate(ios_base::badbit);
-	    __throw_exception_again;
-	  }
-	__catch(...)
-	  { __in._M_setstate(ios_base::badbit); }
+	{
+	  __try
+	    {
+	      if (__in.tie())
+		__in.tie()->flush();
+	      if (!__noskip && bool(__in.flags() & ios_base::skipws))
+		{
+		  const __int_type __eof = traits_type::eof();
+		  __streambuf_type* __sb = __in.rdbuf();
+		  __int_type __c = __sb->sgetc();
+
+		  const __ctype_type& __ct = __check_facet(__in._M_ctype);
+		  while (!traits_type::eq_int_type(__c, __eof)
+			 && __ct.is(ctype_base::space,
+				    traits_type::to_char_type(__c)))
+		    __c = __sb->snextc();
+
+		  // _GLIBCXX_RESOLVE_LIB_DEFECTS
+		  // 195. Should basic_istream::sentry's constructor ever
+		  // set eofbit?
+		  if (traits_type::eq_int_type(__c, __eof))
+		    __err |= ios_base::eofbit;
+		}
+	    }
+	  __catch(__cxxabiv1::__forced_unwind&)
+	    {
+	      __in._M_setstate(ios_base::badbit);
+	      __throw_exception_again;
+	    }
+	  __catch(...)
+	    { __in._M_setstate(ios_base::badbit); }
+	}
 
       if (__in.good() && __err == ios_base::goodbit)
 	_M_ok = true;
diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h
index b2f955b41f7..d9230b72203 100644
--- a/libstdc++-v3/include/bits/shared_ptr_base.h
+++ b/libstdc++-v3/include/bits/shared_ptr_base.h
@@ -762,6 +762,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	    std::__uninitialized_fill_n_a(__p, _M_n, *__init, _M_alloc);
 	  else
 	    {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
 	      struct _Iter
 	      {
 		using value_type = _Up;
@@ -783,6 +785,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 		bool operator==(const _Iter& __i) const
 		{ return _M_pos == __i._M_pos; }
 	      };
+#pragma GCC diagnostic pop
 
 	      _Iter __first{_S_first_elem(__init), sizeof(_Tp) / sizeof(_Up)};
 	      _Iter __last = __first;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-01-25 21:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-25 21:09 [gcc r12-6868] libstdc++: Avoid some more warnings [PR104019] Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).