<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, Nov 8, 2014 at 4:05 PM, Aaron Ballman <span dir="ltr"><<a href="mailto:aaron@aaronballman.com" target="_blank">aaron@aaronballman.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">C++1z now allows attributes on namespace and enumerators. We already<br>
supported deprecated enumerators, but we do not support namespaces.<br>
This patch addresses that.<br>
<br>
A few notes:<br>
<br>
It was decided that the deprecated attribute only applies to things<br>
with names (this makes reporting diagnostics a bit more sane), so this<br>
patch disallows deprecating an anonymous namespace.<br>
<br>
Since the declaration context can now cause deprecations, this<br>
requires updating some other test cases.</blockquote><div><br></div><div>This wasn't the intention when this was discussed with EWG; the idea was that using a deprecated name would result in a warning, but merely naming something that's in a deprecated context would not. So:</div><div><br></div><div>namespace [[deprecated]] N {</div><div>  int x;</div><div>  int y = x; // no warning</div><div>  int f();</div><div>}</div><div>using N::x; // warning</div><div>int z1 = x; // no warning</div><div>using namespace N; // warning</div><div>int z2 = y; // no warning</div><div><br></div><div>// no warnings from this function</div><div>int N::f() {</div><div>  return y;</div><div>}</div><div><br></div><div>This allows, for instance:</div><div><br></div><div>namespace OldNamespace {</div><div>  // old stuff</div><div>}</div><div>namespace NewNamespace {</div><div>  using OldNamespace::a;</div><div>  using OldNamespace::b;</div><div>  namespace C = OldNamespace::Inner;</div><div>}</div><div>namespace [[deprecated("use NewNamespace instead")]] OldNamespace {}</div><div><br></div><div>On the Clang side, the idea would be to check declarations that get used as part of a NestedNameSpecifier to see if they're deprecated, rather than recursing through parents to see if each used declaration is in a deprecated context.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Several of them now receive<br>
two notes -- one for the declaration of a variable of enumerator type,<br>
another for the use of the enumerator.<br>
<br>
There are still improvements to be made for situations where a class<br>
is effectively providing a namespace (static members, inner types,<br>
etc).<br>
<span class="HOEnZb"><font color="#888888"><br>
~Aaron<br>
</font></span></blockquote></div><br></div></div>