[PATCH] D86048: [AST][RecoveryExpr] Popagate the error-bit from a VarDecl's initializer to DeclRefExpr.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 3 07:31:11 PDT 2020


sammccall added a subscriber: rsmith.
sammccall added a comment.

Neither of the testcases look like the right behavior to me, and I think the bug is elsewhere in clang.

The crux is we're forcing `decltype(N)` to be a (unique) dependent type, which feels wrong.
This isn't specific to error-dependence, the same is true in

  template <int K> void foo() {
    constexpr int N = K;
    decltype(K) // dependent?
  }

ASTContext::getDecltypeType() has to determine whether http://eel.is/c++draft/temp.type#4 applies.
There are three behaviors:

- standard up to C++14: traversing the expr looking for a template param to be lexically included (this is my reading of the standard)
- what clang actually does: check instantiation dependence, which I think pulls in too many cases
- standard after http://wg21.link/cwg2064: check type dependence

I think it's probably OK to adopt the C++17 behavior for all versions (if I'm right that the current behavior is a bug).
@rsmith It's your DR, what do you think :-)

(Per offline discussion, this was reduced from a related bug that didn't involve decltype, but I think we should treat that one as distinct)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86048



More information about the cfe-commits mailing list