Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion clang/lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14135,7 +14135,6 @@ static QualType getCommonSugarTypeNode(ASTContext &Ctx, const Type *X,
CANONICAL_TYPE(IncompleteArray)
CANONICAL_TYPE(HLSLAttributedResource)
CANONICAL_TYPE(LValueReference)
CANONICAL_TYPE(MemberPointer)
CANONICAL_TYPE(ObjCInterface)
CANONICAL_TYPE(ObjCObject)
CANONICAL_TYPE(ObjCObjectPointer)
Expand Down Expand Up @@ -14313,6 +14312,15 @@ static QualType getCommonSugarTypeNode(ASTContext &Ctx, const Type *X,
return QualType();
return Ctx.getUsingType(CD, Ctx.getQualifiedType(Underlying));
}
case Type::MemberPointer: {
const auto *PX = cast<MemberPointerType>(X),
*PY = cast<MemberPointerType>(Y);
CXXRecordDecl *Cls = PX->getMostRecentCXXRecordDecl();
assert(Cls == PY->getMostRecentCXXRecordDecl());
return Ctx.getMemberPointerType(
::getCommonPointeeType(Ctx, PX, PY),
::getCommonQualifier(Ctx, PX, PY, /*IsSame=*/false), Cls);
}
case Type::CountAttributed: {
const auto *DX = cast<CountAttributedType>(X),
*DY = cast<CountAttributedType>(Y);
Expand Down
16 changes: 16 additions & 0 deletions clang/test/SemaCXX/sugar-common-types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,19 @@ namespace arrays {
// expected-error@-1 {{lvalue of type 'const volatile volatile B1[1]' (aka 'const volatile volatile int[1]')}}
} // namespace balanced_qualifiers
} // namespace arrays

namespace member_pointers {
template <class T> struct W {
X1 a;
Y1 b;
};
struct W1 : W<X2> {};
struct W2 : W<Y2> {};

N t1 = 0 ? &W<X2>::a : &W<Y2>::b;
// expected-error@-1 {{rvalue of type 'B1 W<B2>::*'}}

// FIXME: adjusted MemberPointer does not preserve qualifier
N t3 = 0 ? &W1::a : &W2::b;
// expected-error@-1 {{rvalue of type 'B1 W<void>::*'}}
} // namespace member_pointers