Patch looks good, but don't you need to also change all the other calls to QualType::getLinkageAndVisibility? In C++14 at least, a no-linkage type can completely leak out of a function and be used as a type of a non-type template parameter. For instance:<div>
<br></div><div>inline auto f() {</div><div>  struct S {};</div><div>  return S();</div><div>}</div><div>template<decltype(f())*> struct X { X() {} };</div><div>X<nullptr> x;<br><br>Right now, this incorrectly generates @x as an internal-linkage symbol. You can probably observe the same bug in C++11 by passing S to a template like this:</div>
<div><br></div><div>template<typename T> struct Outer { template<T *p> struct Inner { ... }; };</div><div><br><div class="gmail_quote">On Tue, May 14, 2013 at 9:29 PM, Rafael Espíndola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 14 May 2013 16:10, Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>> wrote:<br>

> This isn't quite right. You need to scan up to the outermost such entity.<br>
> For instance:<br>
><br>
> template<typename T> int *get() { static int k; return &k; }<br>
><br>
> /*inline*/<br>
> int *f() {<br>
>   struct S {<br>
>     int *g() {<br>
>       struct T {};<br>
>       return get<T>();<br>
>     }<br>
>   } s;<br>
>   return s.g();<br>
> }<br>
><br>
> Here, we should not treat get<f::S::g::T> as being externally-visible, but<br>
> if we uncomment the 'inline', then it should be externally-visible.<br>
<br>
</div>I finally understand what you went by outermost in the bug report.<br>
Thanks, a new patch is attached.<br>
<div class="im"><br>
> (And technically, in either case, getFormalLinkage for get<...> should<br>
> return ExternalLinkage.)<br>
<br>
</div>That is defect is the standard, no? In the non-inline case there is no<br>
way for another TU to refer to this and the current draft defines<br>
external linkage as<br>
<br>
* When a name has external linkage , the entity it denotes can be<br>
referred to by names from scopes of other translation units or from<br>
other scopes of the same translation unit.<br>
<br>
Cheers,<br>
Rafael<br>
</blockquote></div><br></div>