<div dir="ltr">Bill, this is a good candidate for the 3.5 branch.</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jul 23, 2014 at 7:27 PM, Richard Smith <span dir="ltr"><<a href="mailto:richard-llvm@metafoo.co.uk" target="_blank">richard-llvm@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">Author: rsmith<br>
Date: Wed Jul 23 21:27:39 2014<br>
New Revision: 213834<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=213834&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=213834&view=rev</a><br>
Log:<br>
Take the canonical type when forming a canonical template argument with<br>
'nullptr' value. Fixes profiling of such template arguments to always give the<br>
same value.<br>
<br>
Modified:<br>
cfe/trunk/lib/Sema/SemaTemplate.cpp<br>
cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx11.cpp<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=213834&r1=213833&r2=213834&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=213834&r1=213833&r2=213834&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Wed Jul 23 21:27:39 2014<br>
@@ -4438,7 +4438,8 @@ CheckTemplateArgumentAddressOfObjectOrFu<br>
switch (NPV) {<br>
case NPV_NullPointer:<br>
S.Diag(Arg->getExprLoc(), diag::warn_cxx98_compat_template_arg_null);<br>
- Converted = TemplateArgument(ParamType, /*isNullPtr=*/true);<br>
+ Converted = TemplateArgument(S.Context.getCanonicalType(ParamType),<br>
+ /*isNullPtr=*/true);<br>
return false;<br>
<br>
case NPV_Error:<br>
@@ -4633,7 +4634,8 @@ static bool CheckTemplateArgumentPointer<br>
return true;<br>
case NPV_NullPointer:<br>
S.Diag(Arg->getExprLoc(), diag::warn_cxx98_compat_template_arg_null);<br>
- Converted = TemplateArgument(ParamType, /*isNullPtr*/true);<br>
+ Converted = TemplateArgument(S.Context.getCanonicalType(ParamType),<br>
+ /*isNullPtr*/true);<br>
if (S.Context.getTargetInfo().getCXXABI().isMicrosoft())<br>
S.RequireCompleteType(Arg->getExprLoc(), ParamType, 0);<br>
return false;<br>
@@ -5089,7 +5091,8 @@ ExprResult Sema::CheckTemplateArgument(N<br>
<br>
case NPV_NullPointer:<br>
Diag(Arg->getExprLoc(), diag::warn_cxx98_compat_template_arg_null);<br>
- Converted = TemplateArgument(ParamType, /*isNullPtr*/true);<br>
+ Converted = TemplateArgument(Context.getCanonicalType(ParamType),<br>
+ /*isNullPtr*/true);<br>
return Arg;<br>
}<br>
}<br>
<br>
Modified: cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx11.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx11.cpp?rev=213834&r1=213833&r2=213834&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx11.cpp?rev=213834&r1=213833&r2=213834&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx11.cpp (original)<br>
+++ cfe/trunk/test/SemaTemplate/temp_arg_nontype_cxx11.cpp Wed Jul 23 21:27:39 2014<br>
@@ -8,3 +8,18 @@ namespace PR15360 {<br>
f<int[3], int*, nullptr>(); // expected-note{{in instantiation of}}<br>
}<br>
}<br>
+<br>
+namespace CanonicalNullptr {<br>
+ template<typename T> struct get { typedef T type; };<br>
+ struct X {};<br>
+ template<typename T, typename get<T *>::type P = nullptr> struct A {};<br>
+ template<typename T, typename get<decltype((T(), nullptr))>::type P = nullptr> struct B {};<br>
+ template<typename T, typename get<T X::*>::type P = nullptr> struct C {};<br>
+<br>
+ template<typename T> A<T> MakeA();<br>
+ template<typename T> B<T> MakeB();<br>
+ template<typename T> C<T> MakeC();<br>
+ A<int> a = MakeA<int>();<br>
+ B<int> b = MakeB<int>();<br>
+ C<int> c = MakeC<int>();<br>
+}<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">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>
</blockquote></div><br></div>