lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] Stifling "unused" warnings


From: Greg Chicares
Subject: Re: [lmi] Stifling "unused" warnings
Date: Wed, 27 Oct 2021 22:33:32 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0

On 10/27/21 6:02 PM, Vadim Zeitlin wrote:
[...]
> GC> For {a,b,c}, those tests are straightforward. If I comment out
> GC> the stifle_unused_warning() calls, then gcc gives warnings;
> GC> with those calls left in place, it gives none.
> 
>  The question is whether it would be worth running the compiler with
> "-Dstifle_unused_warning(x)=''" on the command line and checking that it
> fails with the expected warning?

Since commit bc7259fb, the question is whether clang
gives zero warnings with origin/master, but gives
exactly the two warnings expected with the patch below.
(I haven't yet tried
  s/T const&/T&/
as recommended here:
  https://lists.nongnu.org/archive/html/lmi/2021-04/msg00058.html
because I'm still pondering the ramifications.)

diff --git a/miscellany_test.cpp b/miscellany_test.cpp
index 0de17a638..8c70510cb 100644
--- a/miscellany_test.cpp
+++ b/miscellany_test.cpp
@@ -461,7 +461,7 @@ class partly_unused
         ,unused_ {unused}
         {
         // suppress clang '-wunused-private-field' warnings:
-        stifle_unused_warning(unused_);
+//      stifle_unused_warning(unused_);
         }
     int used() {return used_;}
 
@@ -490,7 +490,7 @@ void test_stifle_unused_warning()
 
     // variable initialized and later used...
     int volatile d {4};
-//  stifle_unused_warning(d); // [see below]
+    stifle_unused_warning(d); // [see below]
     // ...but last value assigned...
     for(int i = 0; i < 7; ++i)
         {
@@ -498,7 +498,7 @@ void test_stifle_unused_warning()
         }
     // ...is not subsequently used. in this case, for clang at least,
     // it is necessary to stifle the warning here:
-    stifle_unused_warning(d);
+//  stifle_unused_warning(d);
     // rather than in the commented-out location above. see:
     //   https://lists.nongnu.org/archive/html/lmi/2021-04/msg00058.html


reply via email to

[Prev in Thread] Current Thread [Next in Thread]