<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Nov 2, 2016 at 3:51 PM, Jordan Rose via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div class="h5"><br><div><blockquote type="cite"><div>On Nov 2, 2016, at 15:48, Richard Smith <<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>> wrote:</div><br class="m_4103563763562392798Apple-interchange-newline"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Nov 2, 2016 at 2:34 PM, Jordan Rose via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><span><blockquote type="cite"><div>On Nov 2, 2016, at 14:31, Richard Smith <<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>> wrote:</div><br class="m_4103563763562392798m_-4883782072324447123Apple-interchange-newline"><div><div dir="auto"><div><div class="gmail_extra"><div class="gmail_quote">On 2 Nov 2016 1:53 pm, "Jordan Rose via cfe-commits" <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>> wrote:<br type="attribution"><blockquote class="m_4103563763562392798m_-4883782072324447123quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: jrose<br>
Date: Wed Nov  2 15:44:07 2016<br>
New Revision: 285856<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=285856&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject?rev=285856&view=rev</a><br>
Log:<br>
Don't require nullability on template parameters in typedefs.<br>
<br>
Previously the following code would warn on the use of "T":<br>
<br>
  template <typename T><br>
  struct X {<br>
    typedef T *type;<br>
  };<br>
<br>
...because nullability is /allowed/ on template parameters (because<br>
they could be pointers). (Actually putting nullability on this use of<br>
'T' will of course break if the argument is a non-pointer type.)<br></blockquote></div></div></div><div><br></div><div>This doesn't make any sense to me. Why would T need to be a pointer type for a nullability qualifier to be valid on a T*?</div></div></div></blockquote><div><br></div></span><div>Sorry, this is referring to the following change to the example:</div><div><br></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><span><div><div>template <typename T></div></div><div><div>struct X {</div></div></span><div><div>  typedef T _Nullable *type;</div></div><div><div>};</div></div></blockquote><div><div><br></div><div>This is legal, but of course `X<int>` then produces an error. So we want to accept nullability in this position (in case T is implicitly required to be a pointer type by the definition of X) but not warn when it’s missing (in case it isn’t).</div></div></div></blockquote><div><br></div><div>Oh, I see. Your testcase is very confusing, though, since it wraps the problematic use of T in a completely-unrelated pointer type. The actual problem being fixed is much more obvious in a case like this:</div><div><br></div><div>int *_Nullable p;</div><div>template<typename T> struct X {</div><div>  T t; // warns without your fix</div><div>};</div><div><br></div><div>It'd be easier on future readers of this code to use the more obvious test case here.</div></div></div></div></div></blockquote><br></div></div></div><div>Ah, that case doesn’t actually trigger the issue, because a typedef doesn’t require nullability on its outermost pointer type. (It’s assumed that the use site may need to make some uses of the typedef nullable and some non-nullable.)</div></div></blockquote><div><br></div><div>The testcase I gave above definitely produces a bogus warning before your patch. I've not actually checked whether the patch fixes it, though.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>We <i>do</i> still see this issue for <i>fields</i> of type ’T’, but that seemed trickier to deal with. I might have been overthinking it, though.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Jordan</div><br></font></span></div><br>______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div><br></div></div>