Patchwork [v3] Avoid -Wall warnings in the testsuite

login
register
mail settings
Submitter Paolo Carlini
Date June 22, 2011, 9:48 p.m.
Message ID <4E02633B.9020902@oracle.com>
Download mbox | patch
Permalink /patch/101556/
State New
Headers show

Comments

Paolo Carlini - June 22, 2011, 9:48 p.m.
... all, besides that corresponding to c++/49508.

Committed to mainline.

Thanks,
Paolo.

//////////////////
2011-06-22  Paolo Carlini  <paolo.carlini@oracle.com>

	* testsuite/20_util/reference_wrapper/invoke.cc: Avoid -Wall warnings.
	* testsuite/20_util/reference_wrapper/typedefs-3.cc: Likewise.
	* testsuite/20_util/reference_wrapper/invoke-2.cc: Likewise.
	* testsuite/20_util/allocator_traits/members/allocate_hint.cc:
	Likewise.
	* testsuite/20_util/ratio/operations/ops_overflow_neg.cc: Likewise.
	* testsuite/20_util/bind/socket.cc: Likewise.
	* testsuite/20_util/pointer_traits/pointer_to.cc: Likewise.
	* testsuite/util/testsuite_random.h: Likewise.
Paolo Carlini - June 22, 2011, 10:02 p.m.
... actually, there are also bogus "statement has no effect" warnings 
for line 1321 of ext/pb_ds/detail/pat_trie_/pat_trie_base.hpp which also 
seem bogus:

     PB_DS_CLASS_T_DEC
     typename PB_DS_CLASS_C_DEC::size_type
     PB_DS_CLASS_C_DEC::
     get_begin_pos() const
     {
       size_type i = 0;
       for (i; i < arr_size && m_a_p_children[i] == 0; ++i) // here
     ;
       return i;
     }

Paolo.
Andrew Pinski - June 22, 2011, 10:04 p.m.
On Wed, Jun 22, 2011 at 3:02 PM, Paolo Carlini <paolo.carlini@oracle.com> wrote:
> ... actually, there are also bogus "statement has no effect" warnings for
> line 1321 of ext/pb_ds/detail/pat_trie_/pat_trie_base.hpp which also seem
> bogus:
>
>    PB_DS_CLASS_T_DEC
>    typename PB_DS_CLASS_C_DEC::size_type
>    PB_DS_CLASS_C_DEC::
>    get_begin_pos() const
>    {
>      size_type i = 0;
>      for (i; i < arr_size && m_a_p_children[i] == 0; ++i) // here
>    ;

No I think that warning is correct "for (i;" the statement i; has no effect.

Thanks,
Andrew Pinski
Paolo Carlini - June 22, 2011, 10:07 p.m.
On 06/23/2011 12:04 AM, Andrew Pinski wrote:
> No I think that warning is correct "for (i;" the statement i; has no effect.
Thanks, now I see, let's remove that i.

Paolo.

Patch

Index: testsuite/util/testsuite_random.h
===================================================================
--- testsuite/util/testsuite_random.h	(revision 175315)
+++ testsuite/util/testsuite_random.h	(working copy)
@@ -48,7 +48,7 @@ 
       for (unsigned long i = 0; i < N; i++)
 	{
 	  auto r = f();
-	  if (r >= 0 && r < BINS)
+	  if (r >= 0 && (unsigned long)r < BINS)
 	    count[r]++;
 	}
 
@@ -116,7 +116,7 @@ 
     if (!wl.size())
       wl = { 1.0 };
 
-    if (k < 0 || k >= wl.size())
+    if (k < 0 || (std::size_t)k >= wl.size())
       return 0.0;
     else
       {
Index: testsuite/20_util/reference_wrapper/invoke.cc
===================================================================
--- testsuite/20_util/reference_wrapper/invoke.cc	(revision 175315)
+++ testsuite/20_util/reference_wrapper/invoke.cc	(working copy)
@@ -75,7 +75,8 @@ 
   int (::X::* p_foo_c)(float) const = &::X::foo_c;
   int (::X::* p_foo_v)(float) volatile = &::X::foo_v;
   int (::X::* p_foo_cv)(float) const volatile = &::X::foo_cv;
-  int (::X::* p_foo_varargs)(float, ...) = &::X::foo_varargs;
+  int (::X::* p_foo_varargs)(float, ...) __attribute__((unused))
+    = &::X::foo_varargs;
   int ::X::* p_bar = &::X::bar;
 
   const float pi = 3.14;
Index: testsuite/20_util/reference_wrapper/typedefs-3.cc
===================================================================
--- testsuite/20_util/reference_wrapper/typedefs-3.cc	(revision 175315)
+++ testsuite/20_util/reference_wrapper/typedefs-3.cc	(working copy)
@@ -124,14 +124,14 @@ 
 template<typename T>
   void test()
   {
-    test_arg_type<T> t;
-    test_arg_type<const T> tc;
-    test_arg_type<volatile T> tv;
-    test_arg_type<const volatile T> tcv;
-    test_1st_2nd_arg_types<T> t12;
-    test_1st_2nd_arg_types<const T> t12c;
-    test_1st_2nd_arg_types<volatile T> t12v;
-    test_1st_2nd_arg_types<const volatile T> t12cv;
+    test_arg_type<T> t __attribute__((unused));
+    test_arg_type<const T> tc __attribute__((unused));
+    test_arg_type<volatile T> tv __attribute__((unused));
+    test_arg_type<const volatile T> tcv __attribute__((unused));
+    test_1st_2nd_arg_types<T> t12 __attribute__((unused));
+    test_1st_2nd_arg_types<const T> t12c __attribute__((unused));
+    test_1st_2nd_arg_types<volatile T> t12v __attribute__((unused));
+    test_1st_2nd_arg_types<const volatile T> t12cv __attribute__((unused));
   }
 
 int main()
Index: testsuite/20_util/reference_wrapper/invoke-2.cc
===================================================================
--- testsuite/20_util/reference_wrapper/invoke-2.cc	(revision 175315)
+++ testsuite/20_util/reference_wrapper/invoke-2.cc	(working copy)
@@ -36,8 +36,8 @@ 
   X x = { };
   std::ref(m)(x, 1);
   std::ref(m)(&x, 1);
-  int& i1 = std::ref(m2)(x);
-  int& i2 = std::ref(m2)(&x);
+  int& i1 __attribute__((unused)) = std::ref(m2)(x);
+  int& i2 __attribute__((unused)) = std::ref(m2)(&x);
 }
 
 int main()
Index: testsuite/20_util/allocator_traits/members/allocate_hint.cc
===================================================================
--- testsuite/20_util/allocator_traits/members/allocate_hint.cc	(revision 175315)
+++ testsuite/20_util/allocator_traits/members/allocate_hint.cc	(working copy)
@@ -51,7 +51,7 @@ 
   typedef std::allocator_traits<hintable_allocator<X>> traits_type;
   traits_type::allocator_type a;
   traits_type::const_void_pointer v;
-  X* p = traits_type::allocate(a, 1, v);
+  X* p __attribute__((unused)) = traits_type::allocate(a, 1, v);
   VERIFY( a.called );
 }
 
@@ -79,7 +79,7 @@ 
   typedef std::allocator_traits<unhintable_allocator<X>> traits_type;
   traits_type::allocator_type a;
   traits_type::const_void_pointer v;
-  X* p = traits_type::allocate(a, 1, v);
+  X* p __attribute__((unused)) = traits_type::allocate(a, 1, v);
   VERIFY( a.called );
 }
 
Index: testsuite/20_util/ratio/operations/ops_overflow_neg.cc
===================================================================
--- testsuite/20_util/ratio/operations/ops_overflow_neg.cc	(revision 175315)
+++ testsuite/20_util/ratio/operations/ops_overflow_neg.cc	(working copy)
@@ -26,19 +26,22 @@ 
 void
 test01()
 {
-  std::ratio_add<std::ratio<INTMAX_MAX, 1>, std::ratio<1>>::type r1;
+  std::ratio_add<std::ratio<INTMAX_MAX, 1>, std::ratio<1>>::type r1
+    __attribute__((unused));
 }
 
 void
 test02()
 {  
-  std::ratio_multiply<std::ratio<-INTMAX_MAX, 2>, std::ratio<3, 2>>::type r1;
-  std::ratio_multiply<std::ratio<INTMAX_MAX>, std::ratio<INTMAX_MAX>>::type r2;
+  std::ratio_multiply<std::ratio<-INTMAX_MAX, 2>, std::ratio<3, 2>>::type r1
+    __attribute__((unused));
+  std::ratio_multiply<std::ratio<INTMAX_MAX>, std::ratio<INTMAX_MAX>>::type r2
+    __attribute__((unused));
 }
 
 // { dg-error "required from here" "" { target *-*-* } 29 }
-// { dg-error "required from here" "" { target *-*-* } 35 }
 // { dg-error "required from here" "" { target *-*-* } 36 }
+// { dg-error "required from here" "" { target *-*-* } 38 }
 // { dg-error "overflow in addition" "" { target *-*-* } 432 }
 // { dg-error "overflow in multiplication" "" { target *-*-* } 104 }
 // { dg-error "overflow in multiplication" "" { target *-*-* } 100 }
Index: testsuite/20_util/bind/socket.cc
===================================================================
--- testsuite/20_util/bind/socket.cc	(revision 175315)
+++ testsuite/20_util/bind/socket.cc	(working copy)
@@ -35,7 +35,7 @@ 
 {
   int fd = 1;
   my_sockaddr sa;           // N.B. non-const
-  size_t len = sizeof(sa);  // N.B. size_t not socklen_t
+  size_t len __attribute__((unused)) = sizeof(sa); // N.B. size_t not socklen_t
   return bind(fd, &sa, sizeof(sa));
 }
 
Index: testsuite/20_util/pointer_traits/pointer_to.cc
===================================================================
--- testsuite/20_util/pointer_traits/pointer_to.cc	(revision 175315)
+++ testsuite/20_util/pointer_traits/pointer_to.cc	(working copy)
@@ -32,7 +32,7 @@ 
 void test01()
 {
   bool test = true;
-  Ptr p{&test};
+  Ptr p __attribute__((unused)) {&test};
 
   VERIFY( std::pointer_traits<Ptr>::pointer_to(test).value == &test );
 }