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: [email protected]
ReportedBy: [email protected]
CC: [email protected], [email protected]
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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs