[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
Fri Apr 24 17:22:12 PDT 2020


rsmith added a comment.

We should reject a definition of a class that has a non-dependent base class that's an incomplete type. We need non-dependent bases to be complete in order to be able to do name lookup into them when processing the template definition. (The C++ standard permits us to reject such cases but does not require it, because "a hypothetical instantiation of [the templated class] immediately following its definition would be ill-formed due to a construct that does not depend on a template parameter".)

Then there's a question of error recovery and AST invariants: should we permit a base specifier to name a non-dependent type that's not a complete class type? If so, we'll need to make sure that all code that iterates over base classes checks for this condition (I bet there are more cases than the two that you found). But tooling use cases probably do want to know that such base specifiers were written. So perhaps we should allow such base classes but mark the class definition as invalid if we find them -- in which case we would want something like this patch as part of the error recovery.


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