[PATCH] D78760: Check a class has a definition before iterating over its base classes

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 28 14:02:30 PDT 2020


rsmith added a comment.

In D78760#2005874 <https://reviews.llvm.org/D78760#2005874>, @ahatanak wrote:

> `TagDecl::isDependentType()` is returning true.


Oh, sorry, we do already do the thing I was suggesting. But in your testcase the issue is that the base class `B0` is dependent but is also resolved during template instantiation to a (dependent) class type. We should handle this by skipping dependent base classes, not by skipping incomplete base classes. For example, consider this testcase (which currently asserts):

  struct A {};
  template<typename T> struct X {
    struct B : A {};
    struct C : A, B {};
  };

here, we can resolve the `B` base of `C` to the member `C` of the current instantiation, but we should not traverse to `B`'s base class list when considering the base classes of `C`, because we do not know that that definition of `B` will be used by any particular instantiation of `C`. For example:

  template<> struct X<int>::B {};
  X<int>::C c; // has only one `A` base class


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78760/new/

https://reviews.llvm.org/D78760





More information about the cfe-commits mailing list