[LLVMbugs] [Bug 7351] New: Bad recovery from "redefinition of 'x' with a different type"

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jun 10 14:49:25 PDT 2010


http://llvm.org/bugs/show_bug.cgi?id=7351

           Summary: Bad recovery from "redefinition of 'x' with a
                    different type"
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Keywords: quality-of-implementation
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: jyasskin at google.com
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


When we find a redefinition of a name with a new type, we should recover by
hiding the old variable and proceeding with the name bound to the new type.
That is, in the following example, the last 2 diagnostics shouldn't happen.


$ cat test2.cc
int foo(int *ids_begin, int *ids_end) {
    for (int *id = ids_begin; id != ids_end; ++id) {
        int id = *id;
        if (id != 7)
            return id;
    }
    return 0;
}
$ ./clang++ -fsyntax-only test2.cc
test2.cc:3:13: error: redefinition of 'id' with a different type
        int id = *id;
            ^
test2.cc:2:15: note: previous definition is here
    for (int *id = ids_begin; id != ids_end; ++id) {
              ^
test2.cc:4:16: warning: comparison between pointer and integer ('int *' and
'int')
        if (id != 7)
            ~~ ^  ~
test2.cc:5:20: error: cannot initialize return object of type 'int' with an
lvalue of type 'int *'
            return id;
                   ^~
1 warning and 2 errors generated.

-- 
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