jyknight added a comment.

I think -Wuninitialized (UninitializedValues.cpp) should be taught how to 
detect the use of output variables in error blocks, at least for trivial cases.

Actually, for some reason -- it looks like the warning is failing the wrong way 
right now, and emits an uninitialized use warning even where there shouldn't be 
one.

E.g. this example should be okay:

  int foo(int x) {
    int y;
    asm goto("# %0 %1 %2" : "=r"(y) : "r"(x) : : err);
    return y;
  err:
    return -1;
  }

But now warns:

  $ clang -Wall -fsyntax-only foo.c
  foo.c:4:10: warning: variable 'y' is uninitialized when used here 
[-Wuninitialized]
    return y;
           ^
  foo.c:2:8: note: initialize the variable 'y' to silence this warning
    int y;
         ^
          = 0
  1 warning generated.

I'd expect a warning only if the code was modified to say "return y" in the err 
block.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69876/new/

https://reviews.llvm.org/D69876



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to