<div dir="ltr">I'm not qualified to comment on the implementation, but I'm a bit skeptical that this warning is appropriate in the first place. I've often declared friend non-template functions, e.g. swap(). I've never intended to declare a friend <i>template specialization</i>. Is declaring friend template specializations something that people do often? Is it something that Clang should be encouraging newbies to do <i>more</i> often?<div><br></div><div>GCC suppresses the diagnostic when the friend function is declared inline, which is good, because it shuts up the diagnostic in this very common case:</div><div><div><br></div><div><font face="monospace, monospace">template<class T></font></div><div><font face="monospace, monospace">struct vector {</font></div><div><font face="monospace, monospace">    void swap(vector& b) { /* swap members */ }</font></div><div><font face="monospace, monospace">    friend void swap(vector& a, vector& b) { a.swap(b); }  // friend non-template function</font></div><div><font face="monospace, monospace">};</font></div><div><br></div><div>IMHO you should add an explicit test confirming that the warning is suppressed in this case.</div><div><br></div><div>The example in PR23342 doesn't seem like a good example, because GCC gives not only the proposed warning for that code, but also a linker error; i.e., there's no danger of someone accidentally getting wrong runtime behavior there. Is there a compelling example of how someone could write code that has wrong runtime behavior, <i>and</i> which code would be <i>fixed</i> by the suggested addition of <font face="monospace, monospace">template<></font>? I think it's much more likely that the appropriate fix would be to move the function definition inline.</div><div><a href="https://llvm.org/bugs/show_bug.cgi?id=23342">https://llvm.org/bugs/show_bug.cgi?id=23342<br></a></div><div><br></div>Why did you need to suppress the warning in "test/CXX/temp/temp.decls/temp.friend/p1.cpp"? Unless I'm mistaken, GCC doesn't give the diagnostic on that file (and nor should it).</div><div><br></div><div>my $.02,</div><div>–Arthur</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 17, 2016 at 9:21 AM, Serge Pavlov 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 dir="ltr">Ping.</div><div class="gmail_extra"><br clear="all"><div><div>Thanks,<br>--Serge<br></div></div><div><div class="h5">
<br><div class="gmail_quote">2016-02-26 12:20 GMT+06:00 Serge Pavlov <span dir="ltr"><<a href="mailto:sepavloff@gmail.com" target="_blank">sepavloff@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Could someone provide a feedback?</div><div class="gmail_extra"><br clear="all"><div><div>Thanks,<br>--Serge<br></div></div>
<br><div class="gmail_quote"><span>2016-01-26 20:55 GMT+06:00 Serge Pavlov <span dir="ltr"><<a href="mailto:sepavloff@gmail.com" target="_blank">sepavloff@gmail.com</a>></span>:<br></span><div><div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">sepavloff created this revision.<br>
sepavloff added a subscriber: cfe-commits.<br>
<br>
Declaration of friend function may depend on template parameters,<br>
however it does not become a template function:<br>
<br>
    template<typename T> class C1 {<br>
      friend void func(T x);<br>
    };<br>
<br>
It may be not obvious for user, so compiler could emit a warning in<br>
such case. This patch implements appropriate warning, the wording is<br>
taken from GCC message. The patch fixes PR23342.<br>
<br>
<a href="http://reviews.llvm.org/D16579" rel="noreferrer" target="_blank">http://reviews.llvm.org/D16579</a><br>
<br>
Files:<br>
  include/clang/Basic/DiagnosticGroups.td<br>
  include/clang/Basic/DiagnosticSemaKinds.td<br>
  lib/Sema/SemaDecl.cpp<br>
  test/CXX/drs/dr3xx.cpp<br>
  test/CXX/drs/dr5xx.cpp<br>
  test/CXX/temp/temp.decls/temp.friend/p1.cpp<br>
  test/PCH/cxx-templates.cpp<br>
  test/PCH/cxx-templates.h<br>
  test/SemaCXX/friend.cpp<br>
  test/SemaCXX/overload-call.cpp<br>
<br>
</blockquote></div></div></div><br></div>
</blockquote></div><br></div></div></div>
<br>_______________________________________________<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/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div><br></div>