diff options
author | Bill Wendling <isanbard@gmail.com> | 2014-08-04 18:38:09 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2014-08-04 18:38:09 +0000 |
commit | c36922035294cc489aed74e79d80298cd9b2afa8 (patch) | |
tree | b456a56fe176910b06ae5e5ea909aac5cc51ae96 /clang | |
parent | 001a4b73cd6f6c51bff07f8dccb29385967fa941 (diff) | |
download | llvm-c36922035294cc489aed74e79d80298cd9b2afa8.zip llvm-c36922035294cc489aed74e79d80298cd9b2afa8.tar.gz llvm-c36922035294cc489aed74e79d80298cd9b2afa8.tar.bz2 |
Merging r213834:
------------------------------------------------------------------------
r213834 | rsmith | 2014-07-23 19:27:39 -0700 (Wed, 23 Jul 2014) | 4 lines
Take the canonical type when forming a canonical template argument with
'nullptr' value. Fixes profiling of such template arguments to always give the
same value.
------------------------------------------------------------------------
llvm-svn: 214751
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/Sema/SemaTemplate.cpp | 9 | ||||
-rw-r--r-- | clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp | 15 |
2 files changed, 21 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index d0f9b84..d81f651 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -4438,7 +4438,8 @@ CheckTemplateArgumentAddressOfObjectOrFunction(Sema &S, switch (NPV) { case NPV_NullPointer: S.Diag(Arg->getExprLoc(), diag::warn_cxx98_compat_template_arg_null); - Converted = TemplateArgument(ParamType, /*isNullPtr=*/true); + Converted = TemplateArgument(S.Context.getCanonicalType(ParamType), + /*isNullPtr=*/true); return false; case NPV_Error: @@ -4633,7 +4634,8 @@ static bool CheckTemplateArgumentPointerToMember(Sema &S, return true; case NPV_NullPointer: S.Diag(Arg->getExprLoc(), diag::warn_cxx98_compat_template_arg_null); - Converted = TemplateArgument(ParamType, /*isNullPtr*/true); + Converted = TemplateArgument(S.Context.getCanonicalType(ParamType), + /*isNullPtr*/true); if (S.Context.getTargetInfo().getCXXABI().isMicrosoft()) S.RequireCompleteType(Arg->getExprLoc(), ParamType, 0); return false; @@ -5089,7 +5091,8 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, case NPV_NullPointer: Diag(Arg->getExprLoc(), diag::warn_cxx98_compat_template_arg_null); - Converted = TemplateArgument(ParamType, /*isNullPtr*/true); + Converted = TemplateArgument(Context.getCanonicalType(ParamType), + /*isNullPtr*/true); return Arg; } } diff --git a/clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp b/clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp index d773c64..15c9c25 100644 --- a/clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp +++ b/clang/test/SemaTemplate/temp_arg_nontype_cxx11.cpp @@ -8,3 +8,18 @@ namespace PR15360 { f<int[3], int*, nullptr>(); // expected-note{{in instantiation of}} } } + +namespace CanonicalNullptr { + template<typename T> struct get { typedef T type; }; + struct X {}; + template<typename T, typename get<T *>::type P = nullptr> struct A {}; + template<typename T, typename get<decltype((T(), nullptr))>::type P = nullptr> struct B {}; + template<typename T, typename get<T X::*>::type P = nullptr> struct C {}; + + template<typename T> A<T> MakeA(); + template<typename T> B<T> MakeB(); + template<typename T> C<T> MakeC(); + A<int> a = MakeA<int>(); + B<int> b = MakeB<int>(); + C<int> c = MakeC<int>(); +} |