[PATCH] D47503: Sema: Add a warning for member pointers with incomplete base types.

Reid Kleckner via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 29 16:19:20 PDT 2018


rnk added a comment.

Should we do this in exactly the places we would lock in an inheritance model in the MS ABI, i.e. when the member pointer type is required to be complete? I think we could take this code:

  bool Sema::RequireCompleteTypeImpl(SourceLocation Loc, QualType T,
                                     TypeDiagnoser *Diagnoser) {
    // FIXME: Add this assertion to make sure we always get instantiation points.
    //  assert(!Loc.isInvalid() && "Invalid location in RequireCompleteType");
    // FIXME: Add this assertion to help us flush out problems with
    // checking for dependent types and type-dependent expressions.
    //
    //  assert(!T->isDependentType() &&
    //         "Can't ask whether a dependent type is complete");
  
    // We lock in the inheritance model once somebody has asked us to ensure
    // that a pointer-to-member type is complete.
    if (Context.getTargetInfo().getCXXABI().isMicrosoft()) {
      if (const MemberPointerType *MPTy = T->getAs<MemberPointerType>()) {
        if (!MPTy->getClass()->isDependentType()) {
          (void)isCompleteType(Loc, QualType(MPTy->getClass(), 0));
          assignInheritanceModel(*this, MPTy->getMostRecentCXXRecordDecl());
        }
      }
    }

And rewrite the side-effecting isCompleteType call to use RequireCompleteType with the warning diagnostic. I guess we would change the `isMicrosoft` check to alternatively check if the diagnostic is enabled. It still has the problem that enabling a warning can cause template instantiation errors, but oh well.


https://reviews.llvm.org/D47503





More information about the cfe-commits mailing list