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



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D80925: F... Richard Smith - zygoloid via Phabricator via cfe-commits

Reply via email to