<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Apr 14, 2014 at 1:09 AM, suyog sarda <span dir="ltr"><<a href="mailto:sardask01@gmail.com" target="_blank">sardask01@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 dir="ltr">Hi Richard,<div><br></div><div>Thanks for the review. I Agree to your explaination. Following are the points what i understood :</div>

<div><br></div><div>1. <span style="font-size:13px;font-family:arial,sans-serif">setInstantiatedFromMemberTempl</span><span style="font-size:13px;font-family:arial,sans-serif">ate call should not be skipped since it causes mix up of </span> <span style="font-family:arial,sans-serif;font-size:13px">template parameter list numbering and wrong substitutions, </span></div>


<div><span style="font-family:arial,sans-serif;font-size:13px">    which is clearly visible in the test case as well.</span></div></div></blockquote><div><br></div><div>More fundamentally, it shouldn't be skipped because this function is instantiated from a "member template" (it's not actually a member, but this really means class-scope template, not member template).</div>

<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><span style="font-family:arial,sans-serif;font-size:13px">2. When C is instantiated twice, it should throw re-definition error of function f, which is not done (with or without my patch).</span></div>
</div></blockquote><div><br></div><div>That should be handled by the 'if (isFriend) {' loop starting at around line 1424.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">

<div><span style="font-family:arial,sans-serif;font-size:13px">3. In the same function call 'TemplateDeclInstantiator::VisitFunctionDecl', there is a check 'if (isFriend)'. </span></div><div><span style="font-family:arial,sans-serif;font-size:13px">    There is a standard described '[temp.friend] p4 (DR329)' inside that check, which checks if the <i>FunctionDecl D </i>is Declared as well as Defined (isThisDeclarationADefintion).</span></div>


<div><span style="font-family:arial,sans-serif;font-size:13px">    In my opinion, at this point the function defintion is not being set for friend function defined inside the class template. </span></div></div></blockquote>

<div><br></div><div>There's also something strange going on in VisitFunctionTemplateDecl -- that code is also calling setInstantiatedFromMemberTemplate for a friend template definition. So at least there appears to be some redundancy here.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div><span style="font-family:arial,sans-serif;font-size:13px">4. While debugging, it is seen that, the </span><i style="font-family:arial,sans-serif;font-size:13px">FunctionDecl D </i><span style="font-family:arial,sans-serif;font-size:13px">is </span><i style="font-family:arial,sans-serif;font-size:13px">defined </i><span style="font-family:arial,sans-serif;font-size:13px">holds true but '</span><i style="font-family:arial,sans-serif;font-size:13px">Function->isDefined(Definition)</i><span style="font-family:arial,sans-serif;font-size:13px">' evaluates to false (I did not get why it evaluates to false),                 because of which re-defintion error is not emitted.</span></div>
</div></blockquote><div><br></div><div>The function isn't defined because we've not instantiated its definition yet; that's probably to be expected.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div><span style="font-family:arial,sans-serif;font-size:13px">There is a similar bug for operator overloading - Bug 14785. There also same case is happening - not able to identify if friend function (in 14785 its operator overloading function) is defined inside class template.</span></div>


<div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">Can you please help me out if my above analysis is correct as well as indicate where/how to set the definition of the declared function? Your help is highly appreciated.  </span></div>
</div></blockquote><div><br></div><div>I don't get see what's going wrong, but I suspect something in FunctionDecl::getTemplateInstantiationPattern() is broken.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div><div class="gmail_extra"><div class="gmail_quote">On Sat, Apr 12, 2014 at 1:57 AM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</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">Hi!<div><br></div><div>I'm afraid this patch is incorrect; it even does the wrong thing in your test case. Skipping the setInstantiatedFromMemberTemplate call causes us to mix up the template parameter list numbering -- we substitute the argument given for T as the value U, and we don't substitute anything for T. For instance, in the definition of f instantiated for the f(3.0) call, we should have T=double, U=int, but we actually have T=<no value>, U=double, as can be seen in the AST dump.</div>



<div><br></div><div>This also does the wrong thing if C is instantiated twice -- such a case should be an error, because f would have multiple definitions.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">


<div><div>
On Mon, Mar 24, 2014 at 5:29 AM, suyog sarda <span dir="ltr"><<a href="mailto:sardask01@gmail.com" target="_blank">sardask01@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div><div>
<div dir="ltr">Gentle Ping!!</div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Mar 20, 2014 at 9:46 AM, suyog sarda <span dir="ltr"><<a href="mailto:sardask01@gmail.com" target="_blank">sardask01@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 dir="ltr">Gentle Ping!!<br></div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Fri, Mar 14, 2014 at 10:29 PM, suyog sarda <span dir="ltr"><<a href="mailto:sardask01@gmail.com" target="_blank">sardask01@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 dir="ltr"><div><div><div>Hi,<br><br></div>Attaching patch for bug 19095. Please help in reviewing the same.<br><br>





</div>Also, I haven't attached a test case yet in the patch as i am not sure how it should be and in which file it should be. <br>
<br></div>In my opinion, the test case would go into <i>tools/clang/test/SemaCXX/friend.cpp </i>would be something like below (similar to that mentioned in the bug)<br><span><span><i><br>
template <class T><br>void f(T);<br><br>template <class U><br>class C<br>{<br>  template <class T><br>  friend void f(T)<br>  {<br>     C<U> c;<br>     c.i = 3;<br>  }<br><br>  public :<br><br>     void g()<br>






     {<br>       f(3.0); // OK<br>     }<br>    int i;<br>};<br><br>void h ()<br>{<br>  f(7); // OK<br>  C<double> c;<br>  c.g();<br>}</i><br clear="all"></span></span><div><div><div><div><br></div><div><br></div><div>






Please help in reviewing the patch as well as the test case.<span><font color="#888888"><br></font></span></div><span><font color="#888888"><div>-- <br>With regards,<br>Suyog Sarda<br>
</div></font></span></div></div></div></div>
</blockquote></div><br><br clear="all"><br>-- <br>With regards,<br>Suyog Sarda<br>
</div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>With regards,<br>Suyog Sarda<br>
</div>
</div></div><br></div></div>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>With regards,<br>Suyog Sarda<br>
</div>
</div></div></blockquote></div><br></div></div>