This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix -Wsystem-header warnings in libstdc++


On 01/12/17 16:10 +0000, Jonathan Wakely wrote:
On 01/12/17 15:11 +0000, Jonathan Wakely wrote:
This fixes a number of warnings that show up with -Wsystem-headers

This fixes some more.

And some more, this time for -Wunused, -Wcomment, and
-Wvariadic-macros.

Tested powerpc64le-linux, committed to trunk.

The purpose of these is not only to reduce noise if users use
-Wsystem-headers, but to get us to a place where PR 50871 can be fixed
(i.e. build and test libstdc++ without having useful warnings
suppressed by the #pragma GCC system_header lines).

commit e04e77ee6202b69652d033d419283bc35d67897a
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Dec 4 20:49:42 2017 +0000

    Fix warnings in <bits/regex_compiler.tcc>
    
            * include/bits/regex_compiler.tcc: Use C-style comment to work around
            PR preprocessor/61638.
            (__INSERT_REGEX_MATCHER): Replace GNU extension with __VA_ARGS__.

diff --git a/libstdc++-v3/include/bits/regex_compiler.tcc b/libstdc++-v3/include/bits/regex_compiler.tcc
index 1f7dd91b643..0c89800ea94 100644
--- a/libstdc++-v3/include/bits/regex_compiler.tcc
+++ b/libstdc++-v3/include/bits/regex_compiler.tcc
@@ -30,8 +30,9 @@
 
 // FIXME make comments doxygen format.
 
+/*
 // This compiler refers to "Regular Expression Matching Can Be Simple And Fast"
-// (http://swtch.com/~rsc/regexp/regexp1.html";),
+// (http://swtch.com/~rsc/regexp/regexp1.html),
 // but doesn't strictly follow it.
 //
 // When compiling, states are *chained* instead of tree- or graph-constructed.
@@ -51,7 +52,8 @@
 // article.
 //
 // That's why we introduced dummy node here ------ "end_tag" is a dummy node.
-// All dummy node will be eliminated at the end of compiling process.
+// All dummy nodes will be eliminated at the end of compilation.
+*/
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -292,18 +294,18 @@ namespace __detail
       return true;
     }
 
-#define __INSERT_REGEX_MATCHER(__func, args...)\
+#define __INSERT_REGEX_MATCHER(__func, ...)\
 	do\
 	  if (!(_M_flags & regex_constants::icase))\
 	    if (!(_M_flags & regex_constants::collate))\
-	      __func<false, false>(args);\
+	      __func<false, false>(__VA_ARGS__);\
 	    else\
-	      __func<false, true>(args);\
+	      __func<false, true>(__VA_ARGS__);\
 	  else\
 	    if (!(_M_flags & regex_constants::collate))\
-	      __func<true, false>(args);\
+	      __func<true, false>(__VA_ARGS__);\
 	    else\
-	      __func<true, true>(args);\
+	      __func<true, true>(__VA_ARGS__);\
 	while (false)
 
   template<typename _TraitsT>

commit f2d7faeec2d63743c5acdc1dc77fca7ba64fce1f
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Dec 4 16:08:34 2017 +0000

    Fix -Wunused warnings in libstdc++ headers
    
            * config/io/basic_file_stdio.h (__basic_file): Remove name of unused
            parameter.
            * include/bits/boost_concept_check.h: Add pragmas to disable
            -Wunused-local-typedef warnings.
            * include/bits/codecvt.h (codecvt_byname<char16_t, char, mbstate_t>)
            (codecvt_byname<char32_t, char, mbstate_t>): Remove name of unused
            parameter.
            * include/bits/locale_facets_nonio.tcc (time_get::do_get_weekday)
            (time_get::do_get_monthname, time_get::do_get_year): Remove unused
            variables.
            * include/std/bitset (_Base_bitset<0>::_M_getword): Remove name of
            unused parameter.
            * include/std/streambuf (_IsUnused): Define.
            (basic_streambuf::imbue, basic_streambuf::pbackfail)
            (basic_streambuf::overflow): Add macro to unused parameters.
            * testsuite/24_iterators/operations/prev_neg.cc: Adjust dg-error.

diff --git a/libstdc++-v3/config/io/basic_file_stdio.h b/libstdc++-v3/config/io/basic_file_stdio.h
index f959ea534cb..76435e417ef 100644
--- a/libstdc++-v3/config/io/basic_file_stdio.h
+++ b/libstdc++-v3/config/io/basic_file_stdio.h
@@ -63,7 +63,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       __basic_file(__c_lock* __lock = 0) throw ();
 
 #if __cplusplus >= 201103L
-      __basic_file(__basic_file&& __rv, __c_lock* __lock = 0) noexcept
+      __basic_file(__basic_file&& __rv, __c_lock* = 0) noexcept
       : _M_cfile(__rv._M_cfile), _M_cfile_created(__rv._M_cfile_created)
       {
 	__rv._M_cfile = nullptr;
diff --git a/libstdc++-v3/include/bits/boost_concept_check.h b/libstdc++-v3/include/bits/boost_concept_check.h
index fb9a643c869..43ab03415e5 100644
--- a/libstdc++-v3/include/bits/boost_concept_check.h
+++ b/libstdc++-v3/include/bits/boost_concept_check.h
@@ -48,6 +48,9 @@ namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
+
 #define _IsUnused __attribute__ ((__unused__))
 
 // When the C-C code is in use, we would like this function to do as little
@@ -783,6 +786,7 @@ struct _Aux_require_same<_Tp,_Tp> { typedef _Tp _Type; };
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
+#pragma GCC diagnostic pop
 #undef _IsUnused
 
 #endif // _GLIBCXX_BOOST_CONCEPT_CHECK
diff --git a/libstdc++-v3/include/bits/codecvt.h b/libstdc++-v3/include/bits/codecvt.h
index fc2da321ab6..09af6d88fd2 100644
--- a/libstdc++-v3/include/bits/codecvt.h
+++ b/libstdc++-v3/include/bits/codecvt.h
@@ -612,7 +612,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     {
     public:
       explicit
-      codecvt_byname(const char* __s, size_t __refs = 0)
+      codecvt_byname(const char*, size_t __refs = 0)
       : codecvt<char16_t, char, mbstate_t>(__refs) { }
 
       explicit
@@ -630,7 +630,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     {
     public:
       explicit
-      codecvt_byname(const char* __s, size_t __refs = 0)
+      codecvt_byname(const char*, size_t __refs = 0)
       : codecvt<char32_t, char, mbstate_t>(__refs) { }
 
       explicit
diff --git a/libstdc++-v3/include/bits/locale_facets_nonio.tcc b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
index 135dd0b9d8f..63e832ea233 100644
--- a/libstdc++-v3/include/bits/locale_facets_nonio.tcc
+++ b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
@@ -1096,7 +1096,6 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
     {
       const locale& __loc = __io._M_getloc();
       const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
-      const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
       const char_type* __days[14];
       __tp._M_days_abbreviated(__days);
       __tp._M_days(__days + 7);
@@ -1123,7 +1122,6 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
     {
       const locale& __loc = __io._M_getloc();
       const __timepunct<_CharT>& __tp = use_facet<__timepunct<_CharT> >(__loc);
-      const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
       const char_type*  __months[24];
       __tp._M_months_abbreviated(__months);
       __tp._M_months(__months + 12);
@@ -1148,8 +1146,6 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
     do_get_year(iter_type __beg, iter_type __end, ios_base& __io,
 		ios_base::iostate& __err, tm* __tm) const
     {
-      const locale& __loc = __io._M_getloc();
-      const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
       int __tmpyear;
       ios_base::iostate __tmperr = ios_base::goodbit;
 
diff --git a/libstdc++-v3/include/std/bitset b/libstdc++-v3/include/std/bitset
index 382886ca224..0afad6e5e0e 100644
--- a/libstdc++-v3/include/std/bitset
+++ b/libstdc++-v3/include/std/bitset
@@ -561,7 +561,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       }
 
       _GLIBCXX_CONSTEXPR _WordT
-      _M_getword(size_t __pos) const _GLIBCXX_NOEXCEPT
+      _M_getword(size_t) const _GLIBCXX_NOEXCEPT
       { return 0; }
 
       _GLIBCXX_CONSTEXPR _WordT
diff --git a/libstdc++-v3/include/std/streambuf b/libstdc++-v3/include/std/streambuf
index c1fd395b827..34fa9a45511 100644
--- a/libstdc++-v3/include/std/streambuf
+++ b/libstdc++-v3/include/std/streambuf
@@ -46,6 +46,8 @@ namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
+#define _IsUnused __attribute__ ((__unused__))
+
   template<typename _CharT, typename _Traits>
     streamsize
     __copy_streambufs_eof(basic_streambuf<_CharT, _Traits>*,
@@ -578,7 +580,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        *  @note  Base class version does nothing.
       */
       virtual void
-      imbue(const locale& __loc)
+      imbue(const locale& __loc _IsUnused)
       { }
 
       // [27.5.2.4.2] buffer management and positioning
@@ -726,7 +728,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        *  @note  Base class version does nothing, returns eof().
       */
       virtual int_type
-      pbackfail(int_type __c  = traits_type::eof())
+      pbackfail(int_type __c _IsUnused  = traits_type::eof())
       { return traits_type::eof(); }
 
       // Put area:
@@ -770,7 +772,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        *  @note  Base class version does nothing, returns eof().
       */
       virtual int_type
-      overflow(int_type __c  = traits_type::eof())
+      overflow(int_type __c _IsUnused  = traits_type::eof())
       { return traits_type::eof(); }
 
 #if _GLIBCXX_USE_DEPRECATED && __cplusplus <= 201402L
@@ -852,6 +854,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 			  basic_streambuf<wchar_t>* __sbout, bool& __ineof);
 #endif
 
+#undef _IsUnused
+
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
diff --git a/libstdc++-v3/testsuite/24_iterators/operations/prev_neg.cc b/libstdc++-v3/testsuite/24_iterators/operations/prev_neg.cc
index bcbde41093d..3fbdb6f6f09 100644
--- a/libstdc++-v3/testsuite/24_iterators/operations/prev_neg.cc
+++ b/libstdc++-v3/testsuite/24_iterators/operations/prev_neg.cc
@@ -38,5 +38,5 @@ test02()
 {
   const Y array[1] = { };
   std::prev(array + 1);
-  // { dg-error "forward_iterator" "" { target *-*-* } 220 }
+  // { dg-error "forward_iterator" "" { target *-*-* } 223 }
 }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]