зеркало из https://github.com/microsoft/clang-1.git
When emitting member function pointers, use the canonical decl if the member function is virtual. Fixes PR5940.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92680 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
fc4e4e1511
Коммит
7af4ec744e
|
@ -313,7 +313,8 @@ void AggExprEmitter::VisitUnaryAddrOf(const UnaryOperator *E) {
|
|||
"Unexpected member pointer type!");
|
||||
|
||||
const DeclRefExpr *DRE = cast<DeclRefExpr>(E->getSubExpr());
|
||||
const CXXMethodDecl *MD = cast<CXXMethodDecl>(DRE->getDecl());
|
||||
const CXXMethodDecl *MD =
|
||||
cast<CXXMethodDecl>(DRE->getDecl())->getCanonicalDecl();
|
||||
|
||||
const llvm::Type *PtrDiffTy =
|
||||
CGF.ConvertType(CGF.getContext().getPointerDiffType());
|
||||
|
|
|
@ -408,6 +408,8 @@ public:
|
|||
llvm::Constant *EmitMemberFunctionPointer(CXXMethodDecl *MD) {
|
||||
assert(MD->isInstance() && "Member function must not be static!");
|
||||
|
||||
MD = MD->getCanonicalDecl();
|
||||
|
||||
const llvm::Type *PtrDiffTy =
|
||||
CGM.getTypes().ConvertType(CGM.getContext().getPointerDiffType());
|
||||
|
||||
|
|
|
@ -128,3 +128,14 @@ namespace BoolMemberPointer {
|
|||
}
|
||||
}
|
||||
|
||||
// PR5940
|
||||
namespace PR5940 {
|
||||
class foo {
|
||||
public:
|
||||
virtual void baz(void);
|
||||
};
|
||||
|
||||
void foo::baz(void) {
|
||||
void (foo::*ptr)(void) = &foo::baz;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче