[LLVMbugs] [Bug 7823] New: warn on use of variable in else clause

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Aug 4 23:40:37 PDT 2010


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: unassignedclangbugs at nondot.org
        ReportedBy: nicholas at mxc.ca
                CC: llvmbugs at cs.uiuc.edu


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.



More information about the llvm-bugs mailing list