<div dir="ltr"><div>Hi,<br><br></div>Sorry for late reply. Attaching updated patch with comments and test case. Please help in reviewing the same.<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Feb 22, 2014 at 4:05 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"><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Thu, Feb 20, 2014 at 8:24 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"><div><div><div><div><div>Hi,<br><br></div>Thanks for the review of the patch.<br><br></div>The test cases which i can think of involves templates are as follows :<br>

<br>1. <br><br></div><i><div>template <typename T> void f(const T);<br>
template <typename T> void f(T);<br><br></div>template <typename T> void f(T x)<div><br>{<br>    x = 0;<br>}<br><br>void f()<br>{<br></div>    f<int>(0);<br>}<br></i><br></div>This won't throw any error, since there exist a declaration <i>template <typename T> void f(T)</i> which matches the instantiation.<br>


</div><div>And i think we are treating both the declaration as separate declarations and not re-declaration, as explained in above mails from you and observed through code flow as well. <br><br></div><div>2. <br><br><i><div>

template <typename T> void f(const T);<br>
<br></div>template <typename T> void f(T x)<div><br>{<br>    x = 0;<br>}<br><br>void f()<br>{<br></div>    f<int>(0);<br>}<br><br></i></div>Even this won't throw any error as the declaration and definition are for separate functions. So basically, the first declaration doesn't have any function definition, and the function defined is a separate declaration itself, which matches the instantiation pattern. <br>


<br>3. <br><i><div><br>template <typename T> void f(const T);<br><br></div>template <typename T> void f(const T x)<div><br>{<br>    x = 0;<br>}<br><br>void f()<br>{<br></div>    f<int>(0);<br>
}</i><br><br>This will throw error since the definition itself has a const qualifier 
for the function variable and we are trying to modify the variable 
inside the function definition. This anyways was true even before applying patch.<br><div><div><br>4. <br><br><i><div>template <typename T><br>struct A<br>{<br>    void f(const int);<br>};<br><br>template <typename T><br>

</div>
void A<T>::f(int x)<div><br>{<br>    x = 0;<br>}<br><br>void f()<br>{<br></div>    A<int> a;<br>    a.f(0);<br>}</i><br><br></div><div>This test case doesn't have dependent function parameter. <br>
</div><div><br><br>
</div><div>The focus of the solution for PR18275 got shifted to templates parameter checking rather than specific CV qualifier, which i completely agree as per your explanation above. And the test case listed in the bug gets inherently resolved with the patch. So, i am bit stuck as to how to form a test case for this patch (specific test case which will throw error because of this patch and it should obviously involve template as we are checking for dependent type). <br>


<br></div><div>Can you please help in pointing out what specific should the test case contain? I am a starter for clang patches. Your help will be a lot more useful in learning things. </div></div></div></blockquote><div>

<br></div></div></div><div>Something like your case 4 above would be a good testcase.</div><div><div class="h5"><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 Thu, Feb 20, 2014 at 2:30 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"><div class="gmail_extra"><div class="gmail_quote"><div>On Wed, Feb 19, 2014 at 12:52 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><div>Thanks Richard for the review. Even i felt that cv qualifier checking and setting is not suitable (though the standard 13.1/3 is specifically related to CV qualifiers). Earlier i was checking CV qualifiers and setting type, which obviously failed for function templates. And i agree to your point that if the parameter is not dependent then set the type as in instantiated function. <br>




<br></div>In that case, do we still need to check if the parameters are CV qualified alongwith checking if parameter is dependent? I am attaching a patch where we do not check if the parameters are CV qualified but only checks if it is not dependent and then set the type. This patch works for the test case in the bug with no regression. Also, if we are not checking CV qualifiers and just checking only dependent type then is it feasible to put comment regarding standard 13.1/3? How should comment look if above patch is fine.<br>



</div></div></div></div></blockquote><div><br></div></div><div>The approach in the patch looks OK.  I don't think referencing 13.1/3 is worthwhile: it's reasonable to expect that anyone reading the Clang source knows that parameter declarations in function redeclarations can differ in top-level cv-qualifiers. What's worth pointing out here is (1) that we need the type to match the pattern we're instantiating, and (2) that we don't need to do this for dependent types because those shouldn't differ in cv-qualifiers (with a FIXME that we currently allow dependent types with different cv-qualifeirs to be treated as redeclarations).</div>


<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><div><div></div>Also, i am pasting test case from the bug itself. Please let me know which file to put it in. I cannot think of a negative test case for this bug.<br>



<br></div>Your help is greatly appreciated.<br><br></div>Test case :<div><br>
<br><pre><i>struct B
{
    void f(const int);
};

void B::f(int x)
{
    x = 0;
}

void f()
{
    B b;
    b.f(0);
}</i></pre></div></div><div><div><div class="gmail_extra"><div class="gmail_quote"></div></div></div></div></blockquote></div><div>This testcase doesn't look right: you need to use a template to trigger the issue.</div>


<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 Wed, Feb 19, 2014 at 12:26 AM, Richard Smith <span dir="ltr"><<a href="mailto:metafoo@gmail.com" target="_blank">metafoo@gmail.com</a>></span> wrote:<br>




<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This patch needs testcases.<div><br></div><div><div>Also, the way in which you're updating the type of the parameter doesn't look correct -- there's no reason to think that the qualifiers will be local.</div>




</div>
<div><br></div><div>We discussed cases like this at the WG21 meeting in Issaquah last week, and decided that cv-stripping should *not* be applied to dependent parameter types when determining whether two function templates are redeclarations. Therefore:</div>





<div><br></div><div>  template<typename T> void f(T);</div><div>  template<typename T> void f(const T);</div><div><br></div><div>... are not redeclarations (because, for instance, they have different parameter types when T = int[]).</div>





<div><br></div><div>That makes this problem easier to fix: if the parameter type within PatternDecl is not dependent, set the type of the parameter in the instantiated function to that type. Otherwise, leave it alone, since we already know it will match.</div>




<div><div>
<br><div>On Tue Feb 18 2014 at 6:02:55 AM, suyog sarda <<a href="mailto:sardask01@gmail.com" target="_blank">sardask01@gmail.com</a>> wrote:</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div dir="ltr">Gentle Ping !! Please help in reviewing the patch for bug 18275.</div><div dir="ltr"><br><div><br clear="all"><br>-- <br>With regards,<br>Suyog Sarda<br>
</div></div></blockquote>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>With regards,<br>Suyog Sarda<br>
</div>
</div></div></blockquote></div></div><br></div></div>
</blockquote></div><br><br clear="all"><br>-- <br>With regards,<br>Suyog Sarda<br>
</div>
</div></div></blockquote></div></div></div><br></div></div>
</blockquote></div><br><br clear="all"><br>-- <br>With regards,<br>Suyog Sarda<br>
</div>