[cfe-dev] blog post about clang diagnostics

James Widman widman at gimpel.com
Tue Apr 13 08:31:28 PDT 2010

On Apr 6, 2010, at 2:36 AM, Chris Lattner wrote:

> FYI, it's been too long since we've had a blog post, so I wrote this up tonight:
> http://blog.llvm.org/2010/04/amazing-feats-of-clang-error-recovery.html
> Thoughts and comments welcome!

Apologies in advance, because I know I'm being pedantic, *but*...

You wrote:
> [...] if you comment out the two
> using directives in the example above [...]

Many seasoned C++ programmers get this terminology wrong.

The aforementioned things in the example:

  using B1::f;  using B2::f;

... are using-declarations, not using-directives.  This might help to keep it straight:

A using-declaration is a *declaration* in the sense that it *declares* (introduces) a name in the scope where it appears.

A using-directive is not a declaration *at all*, and it doesn't introduce any names in the scope where it appears.  It is a *directive* in the sense that it sort of *tells name lookup to behave differently* (whereas a declaration tends to alter just the input to name lookup but not the behavior).

And a using-directive always names a *namespace*.

 namespace N{}
 using namespace N; // ok

 namespace Q{ void f(); }
 using namespace Q::f(); // error (expected a namespace name)

... whereas a using-declaration can name just about anything that can be named with a qualified-id (with the exception of a template-id (grammar term)).

James Widman  
Gimpel Software 

More information about the cfe-dev mailing list