forked from OSchip/llvm-project
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. llvm-svn: 193461
This commit is contained in:
parent
be640b28c0
commit
3ae0bfa244
|
@ -5075,7 +5075,8 @@ Sema::BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg,
|
|||
ValueDecl *VD = cast<ValueDecl>(Arg.getAsDecl());
|
||||
|
||||
if (VD->getDeclContext()->isRecord() &&
|
||||
(isa<CXXMethodDecl>(VD) || isa<FieldDecl>(VD))) {
|
||||
(isa<CXXMethodDecl>(VD) || isa<FieldDecl>(VD) ||
|
||||
isa<IndirectFieldDecl>(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
|
||||
|
|
|
@ -350,3 +350,17 @@ namespace rdar13806270 {
|
|||
};
|
||||
void foo() {}
|
||||
}
|
||||
|
||||
namespace PR17696 {
|
||||
struct a {
|
||||
union {
|
||||
int i;
|
||||
};
|
||||
};
|
||||
|
||||
template <int (a::*p)> struct b : a {
|
||||
b() { this->*p = 0; }
|
||||
};
|
||||
|
||||
b<&a::i> c; // okay
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue