<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 14, 2014 at 1:42 PM, 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:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="">On Tue, Oct 14, 2014 at 1:31 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br></span><span class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">So I'm looking at addressing PR21216</div></blockquote><div><br></div></span><div>Are you sure that's the right bug number?</div></div></div></div></blockquote><div><br></div><div>Nope, sorry about that. Actually PR21246: <a href="http://llvm.org/bugs/show_bug.cgi?id=21246">http://llvm.org/bugs/show_bug.cgi?id=21246</a></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div class="h5"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">and I've come across a few hiccups:<br><br>* I can fix the bug as filed by using TemplateArgument's isDeclForReferenceParameter to either create a reference or a pointer type for the argument<br><br>* But this doesn't include const-ness. How would I differentiate the types of the arguments to these template parameters: "template<const int&, int&>" ?<br><br>* This also doesn't include rvalue ref-ness. How would I differentiate the types of the arguments to these template parameters: "template<int &, int&&>" ? <br><br>* Clang prints the desugared name (which we use in the debug info, but can also appear in diagnostics) somewhat strange/incorrectly:<br><br><div>int i;</div><div>template<int& I, int *J, int&& K, const int &L></div><div>struct foo {</div><div>};</div><div><br></div><div>foo<i, &i, i, i> f;</div><div><br></div><div>void f1(int);</div><div><br></div><div>template<typename T></div><div>void f2(T t) {</div><div>  f1(t);</div><div>}</div><div><br></div><div>int main() {</div><div>  f1(f);</div><div>  f2(f);</div><div>}<br><br>Clang produces (just cutting to the notes in question):<br><div><div>templ.cpp:16:3: error: no matching function for call to 'f1'</div><div>  f1(f);</div><div>  ^~</div><div>templ.cpp:8:6: note: candidate function not viable: no known conversion from 'foo<i, &i, i, i>' to 'int' for 1st argument</div><div>void f1(int);</div><div>     ^</div><div>templ.cpp:12:3: error: no matching function for call to 'f1'</div><div>  f1(t);</div><div>  ^~</div><div>templ.cpp:17:3: note: in instantiation of function template specialization 'f2<foo<&i, &i, &i, &i> >' requested here</div><div>  f2(f);</div><div>  ^</div><div>templ.cpp:8:6: note: candidate function not viable: no known conversion from 'foo<&i, &i, &i, &i>' to 'int' for 1st argument</div><div>void f1(int);</div><div>     ^<br><br>Note the desugaring of the template adds '&' to all the parameters, even the reference parameters.<br><br>GCC gets something that looks ugly but probably correct:<br><div>templ.cpp: In function ‘int main()’:</div><div>templ.cpp:16:7: error: cannot convert ‘foo<(* & i), (& i), (* & i), ((const int&)(& i))>’ to ‘int’ for argument ‘1’ to ‘void f1(int)’</div><div>   f1(f);</div><div>       ^<br><br>Though, weirdly, GCC doesn't reject the call to f2... which is weird.<br><br>Anyway: where should I get the right type for my non-type template arguments? Do I have to go spelunking through the template parameters (can I get to them from the template arguments) & try to stitch the type together? That's probably not ideal... <br></div></div></div></div></div></blockquote><div><br></div></div></div><div>Right now, I think you need the template parameters.</div></div></div></div></blockquote><div><br></div><div>Hrm. I'm a bit concerned about trying to make this work with complex dependent types... <br><br><div>template<typename T, typename T::foo F> struct foo { };</div><div>struct outer { typedef const int &foo; };</div><div>int i;<br></div><div>foo<outer, i> f;<br><br>is that going to be easier than I'm thinking? I'm a bit concerned about figuring out the instantiation of T::foo from the template parameter description... </div></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class=""><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><div><div><div>& what can we do about the type printing for non-type template parameters? (I haven't spent too long searching for where those extra '&' are coming from yet - but pointers would be appreciated)<br><br>Thanks,<br>- David</div></div></div></div></div>
</blockquote></span></div><br></div></div>
</blockquote></div><br></div></div>