[LLVMbugs] [Bug 11874] New: bad diagnostics when class-name and function name conflict
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri Jan 27 17:25:30 PST 2012
http://llvm.org/bugs/show_bug.cgi?id=11874
Bug #: 11874
Summary: bad diagnostics when class-name and function name
conflict
Product: clang
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: nlewycky at google.com
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
Testcase:
void foo();
class foo {};
class bar {
bar() {
const foo* f1 = 0; // Good but not perfect.
foo* f2 = 0; // Bad diagnostic.
foo f3; // Terrible diagnostic!!
}
};
This produces:
b5933700.cc:6:11: error: must use 'class' tag to refer to type 'foo' in this
scope
const foo* f1 = 0;
^
class
b5933700.cc:7:10: error: use of undeclared identifier 'f2'
foo* f2 = 0;
^
b5933700.cc:8:8: error: expected ';' after expression
foo f3;
^
;
b5933700.cc:8:9: error: use of undeclared identifier 'f3'
foo f3;
^
b5933700.cc:8:5: warning: expression result unused [-Wunused-value]
foo f3;
^~~
1 warning and 4 errors generated.
For f1 we get a nice diagnostic with a fixit, but the user doesn't know why
this class needs a class keyword on it. (Uhm, this isn't C.) This is actually
the only issue reported by the user.
For f2 we aren't given an obvious declstmt vs. expression distinguishing point,
so we're left multiplying against an undeclared variable. Oops.
But our behaviour on f3 is atrocious with three errors on a single line, one of
which is a wrong fixit, and should be easier to detect than the f2 case. We
named a function then followed with a space and an undeclared name. Given that
the function is also a type, we could've spotted that!
--
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