[cfe-users] -Wunreachable-code warnings can no longer be suppressed?

2016-08-05 Thread Chris Peterson via cfe-users
I suppressed a -Wunreachable-code warning in Firefox earlier this year 
[1] by adding extra parentheses, as suggested by Xcode's clang on OS X:


objdir-osx/dom/bindings/TestJSImplGenBinding.cpp:47639:20: note: silence 
by adding parentheses to mark code as explicitly dead

   if (false && !CallerSubsumes(temp)) {
^
/* DISABLES CODE */ ()

This is generated C++ code in Firefox, so changing the code generator to 
emit the extra parentheses was easier than complicating the code 
generator's logic for this particular case.


Unfortunately, this Firefox warning is back [2] because clang 3.9 on 
Linux no longer recognizes the parentheses suppression. Is this an 
intentional change to -Wunreachable-code or a regression? I don't see 
the warning string "silence by adding parentheses to mark code as 
explicitly dead" in the clang code on GitHub [3], but I see a few clang 
tests that appear to expect that warning string.


thanks,
chris

[1] https://bugzilla.mozilla.org/show_bug.cgi?id=1223265
[2] https://bugzilla.mozilla.org/show_bug.cgi?id=1291397
[3] https://github.com/llvm-mirror/clang
___
cfe-users mailing list
cfe-users@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


Re: [cfe-users] -Wunreachable-code warnings can no longer be suppressed?

2016-08-09 Thread Chris Peterson via cfe-users



On 8/6/16 9:50 AM, David Blaikie wrote:

Could you provide a small example that fails (warns/doesn't suppress) with 
3.9/ToT but succeeds (successfully suppresses the warning) with earlier?


Thanks for testing, David. Below is a standalone test case that 
reproduces the insuppressible warning even with Xcode's clang (Apple 
LLVM version 7.3.0 (clang-703.0.31)). So there is a latent clang bug 
plus a regression that caused Firefox's previously-suppressible warning 
to no longer be suppressible.


The warning looks like it might only happen when the boolean condition 
involves an expression with a templated type. In the test case below, a 
templated local variable gets copy-constructed to form an argument to a 
boolean helper-function.


I filed clang bug 28918 for this issue:

https://llvm.org/bugs/show_bug.cgi?id=28918

$ clang++ -Wunreachable-code test.cpp
test.cpp:23:5: warning: code will never be executed [-Wunreachable-code]
printf("Does clang warn about this code being unreachable?\n");
^~
1 warning generated.

thanks,
chris


// Compile me like so:
//   clang++ -Wunreachable-code test.cpp
// and see if I produce a build warning.
//
// Note that if you change aSomeVec to be a non-templated type, then
// the build warning goes away.

#include "stdio.h"
#include 

// Note: aSomeVec must be passed by value to trigger the problem, it seems.
// Changing to std::vector& reference silences the warning.
static bool
FuncThatTakesATemplatedArg(std::vector /* aSomeVec */)
{
  return false;
}

int main()
{
  std::vector myVec;
  if ((false) &&
  !FuncThatTakesATemplatedArg(myVec)) {
printf("Does clang warn about this code being unreachable?\n");
return 1;
  }

  return 0;
}
___
cfe-users mailing list
cfe-users@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users