[llvm-bugs] [Bug 31147] New: Unfortunate diagnostic for missing brace
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Nov 23 17:02:48 PST 2016
https://llvm.org/bugs/show_bug.cgi?id=31147
Bug ID: 31147
Summary: Unfortunate diagnostic for missing brace
Product: clang
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: chisophugis at gmail.com
CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
Classification: Unclassified
I'm not sure if there's anything clang can do better here without extreme
measures like looking at whitespace, but a coworker and I lost a solid 15
minutes or more due to a situation like this coming up in the wild:
namespace Qux {
struct Foo {
Foo(int x) : x(x) {}
void bar() {
if (x) {
baz();
}
void baz();
int x;
};
}
There's only one real error here (the missing closing brace of the `if`), but
clang gives a bunch of errors, none of which points at the problem. In the way
that this manifested in the wild, the outer namespace actually continued on for
many many more lines, so there was a huge wall of spurious errors.
sean:~/tmp % clang++ -fsyntax-only test.cc
test.cc:3:16: error: member initializer 'x' does not name a non-static data
member or base class
Foo(int x) : x(x) {}
^~~~
test.cc:6:9: error: use of undeclared identifier 'x'
if (x) {
^
test.cc:7:7: error: use of undeclared identifier 'baz'; did you mean 'bar'?
baz();
^~~
bar
test.cc:5:8: note: 'bar' declared here
void bar() {
^
test.cc:14:2: error: expected ';' after struct
}
^
;
test.cc:16:1: error: expected '}'
^
test.cc:1:15: note: to match this '{'
namespace Qux {
^
5 errors generated.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20161124/1989fc8d/attachment.html>
More information about the llvm-bugs
mailing list