From d7b485599cf23605e0e7e9846a7c5df11783b9f7 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Sat, 26 Oct 2013 05:02:13 +0000 Subject: [PATCH] Sema: Correctly build pointer-to-member arguments from a template argument with an IndirectFieldDecl We only considered FieldDecl and CXXMethodDecl as appropriate which would cause us to believe the IndirectFieldDecl corresponded to an argument of it's field type instead of a pointer-to-member type. This fixes PR17696. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193461 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaTemplate.cpp | 3 ++- test/SemaTemplate/temp_arg_nontype.cpp | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index c8e2b0dd89..198b479ba1 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -5075,7 +5075,8 @@ Sema::BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg, ValueDecl *VD = cast(Arg.getAsDecl()); if (VD->getDeclContext()->isRecord() && - (isa(VD) || isa(VD))) { + (isa(VD) || isa(VD) || + isa(VD))) { // If the value is a class member, we might have a pointer-to-member. // Determine whether the non-type template template parameter is of // pointer-to-member type. If so, we need to build an appropriate diff --git a/test/SemaTemplate/temp_arg_nontype.cpp b/test/SemaTemplate/temp_arg_nontype.cpp index fcdfd458f3..8f6cc192fa 100644 --- a/test/SemaTemplate/temp_arg_nontype.cpp +++ b/test/SemaTemplate/temp_arg_nontype.cpp @@ -350,3 +350,17 @@ namespace rdar13806270 { }; void foo() {} } + +namespace PR17696 { + struct a { + union { + int i; + }; + }; + + template struct b : a { + b() { this->*p = 0; } + }; + + b<&a::i> c; // okay +} -- 2.40.0