rsmith added inline comments.

================
Comment at: clang/lib/AST/ExprConstant.cpp:4876
+        assert(E->containsErrors());
+        return ESR_Failed;
+      }
----------------
This should not result in failure when checking for a potential constant 
expression; if an expression contains errors we should treat it as being 
potentially constant, because (depending on how the error is resolved) it could 
be constant. We should `noteSideEffect()` here and continue unless it asks us 
to stop.

I guess I'm thinking of something like:

```
if (E->isValueDependent()) {
  if (E->noteSideEffect())
    return ESR_Succeeded;
  assert(E->containsErrors() && "non-value-dependent expression should never 
reach valid value-dependent expression");
  return ESR_Failed;
}
```

It might also be interesting to produce a diagnostic saying that evaluation 
failed due to a prior error on the `ESR_Failed` path; we could special-case 
that diagnostic when we diagnose expressions that are supposed to be constant 
but aren't in order to fully suppress the follow-on diagnostic.

(Same comment on all the below instances of this same pattern; adding a helper 
function for the above seems warranted.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84637

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

Reply via email to