[MS ABI] Select an inheritance model in template arguments

We used to only select an inheritance model if the pointer to member was
nullptr.  Instead, select a model regardless of the member pointer's
value.

N.B.  This bug was exposed by making member pointers report true for
isIncompleteType but has been latent since the member pointer scheme's
inception.

llvm-svn: 247464
This commit is contained in:
David Majnemer 2015-09-11 20:18:09 +00:00
parent 0123af994e
commit 69c3ddc44a
2 changed files with 16 additions and 3 deletions

View File

@ -4222,7 +4222,11 @@ isNullPointerValueTemplateArgument(Sema &S, NonTypeTemplateParmDecl *Param,
QualType ParamType, Expr *Arg) {
if (Arg->isValueDependent() || Arg->isTypeDependent())
return NPV_NotNullPointer;
if (ParamType->isMemberPointerType())
if (S.Context.getTargetInfo().getCXXABI().isMicrosoft())
S.RequireCompleteType(Arg->getExprLoc(), ParamType, 0);
if (!S.getLangOpts().CPlusPlus11)
return NPV_NotNullPointer;
@ -4670,8 +4674,6 @@ static bool CheckTemplateArgumentPointerToMember(Sema &S,
S.Diag(Arg->getExprLoc(), diag::warn_cxx98_compat_template_arg_null);
Converted = TemplateArgument(S.Context.getCanonicalType(ParamType),
/*isNullPtr*/true);
if (S.Context.getTargetInfo().getCXXABI().isMicrosoft())
S.RequireCompleteType(Arg->getExprLoc(), ParamType, 0);
return false;
case NPV_NotNullPointer:
break;

View File

@ -768,3 +768,14 @@ bool g(int J::*&p, int J::*&q) { return p == q; }
// CHECK-LABEL: @"\01?h@ReferenceToMPTWithIncompleteClass@@YAHAAPQK@1@H@Z"(
int h(int K::*&p) { return k->*p; }
}
namespace PMFInTemplateArgument {
template <class C, int (C::*M)(int)>
void JSMethod();
class A {
int printd(int);
void printd();
};
void A::printd() { JSMethod<A, &A::printd>(); }
// CHECK-LABEL: @"\01??$JSMethod@VA@PMFInTemplateArgument@@$1?printd@12@AAEHH@Z@PMFInTemplateArgument@@YAXXZ"(
}