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
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
};
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
+}