<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Unfortunate diagnostic for missing brace"
   href="https://llvm.org/bugs/show_bug.cgi?id=31147">31147</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Unfortunate diagnostic for missing brace
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>chisophugis@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>