[PATCH] D80925: Fix compiler crash when an expression parsed in the tentative parsing and must be claimed in the another evaluation context.

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 27 17:55:20 PDT 2020


rsmith added a comment.

This is at best only a partial fix. `Sema::NC_ContextIndependentExpr` is supposed to be used (unsurprisingly) only if we form a context-independent annotation, but here we're forming a context-dependent expression that depends on whether it appears in an unevaluated context. I think the better approach would be to fix the case in `Sema::ClassifyName` that violates context-independence instead (there's a FIXME there for this issue).

This fix changed us from producing a bad AST if the member reference was not supposed to be evaluated, to producing a bad AST if the member reference **was** supposed to be annotated and is type-dependent -- we now crash in CodeGen on this invalid code:

  struct C { void g(); };
  template<typename T> struct A {
    T x;
    static void f() {
      (x.g());
    }
  };
  void h() { A<C>::f(); }

... because we now incorrectly form an unevaluated `DeclRefExpr` for `x` when disambiguating between a cast and a parenthesized expression (and we don't fix it due to the added "type-dependent" check).

I'm going to try to fix this a different way, by fixing the bad case in `Sema::ClassifyName` instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80925





More information about the cfe-commits mailing list