http://llvm.org/bugs/show_bug.cgi?id=7823
Summary: warn on use of variable in else clause
Product: clang
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected]
We'd like to warn on uses of the 'tested-as-zero-value' variable declared
inside an if-statement. For example:
if (x = test()) {
...
} else {
doSomething(x);
}
should issue a warning. However, this requires dataflow to do correctly:
if (x = test()) {
...
} else {
x = test2();
doSomething(x);
}
should not issue a warning. Even more evil:
if (x = test()) {
...
goto label;
} else {
label:
doSomething(x);
}
shouldn't issue a warning either. Please see bug 7100 for issues with the
previous implementation of this warning and
test/SemaCXX/warn-for-var-in-else.cpp for more examples we should warn about. (
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-for-var-in-else.cpp?revision=91446&view=markup&pathrev=110313
)
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs