Unclosed namespace causes cryptic errors
| Bugzilla Link | 25303 |
| Resolution | WONTFIX |
| Resolved on | Oct 23, 2015 21:46 |
| Version | unspecified |
| OS | Windows NT |
| CC | @DougGregor,@zygoloid |
Extended Description
consider: namespace Foo {
namespace Bar { void thud(); } void qux() { ::Bar::thud(); }
clang generates the following diagnostics: error: no member named 'Bar' in the global namespace; did you mean simply 'Bar'? ::Bar::thud(); ^~~~~ Bar note: 'Bar' declared here namespace Bar { void thud(); } ^ error: expected '}' } ^ note: to match this '{' namespace Foo { ^ 2 errors generated.
It would have been nicer to recover by inserting a '}' before 'namespace Bar'.
It would have been nicer to recover by inserting a '}' before 'namespace Bar'.
That would require extreme lookahead or reverting a lot of parser state, both of which are not feasible. Nothing is obviously wrong here until we reach the ill-formed call to ::Bar::thud, and that error is indistinguishable from the nested name specifier on the call being wrong, which is what we say.
I don't think this is feasible for us to improve, unless you have some specific suggestion for how we would detect the problem.