[PATCH] D124038: [clang] Prevent folding of non-const compound expr

serge via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 20 03:16:33 PDT 2022


serge-sans-paille added a comment.

In D124038#3460731 <https://reviews.llvm.org/D124038#3460731>, @efriedma wrote:

> The fix doesn't look right.
>
> A CompoundLiteralExpr is itself an lvalue; we should catch any issues when we visit it, not a VarDecl that contains a pointer to it.

Well, the visitor for CompoundLiteralExpr explicitly states

>   // Defer visiting the literal until the lvalue-to-rvalue conversion. We can
>   // only see this when folding in C, so there's no standard to follow here.

Which is what I was trying to do in this patch.
We only visit CompoundLiteralExpr once, during initialization of the VarDecl, and that initialization is correct. We don't visit it again during checking of expression constness because we stop at the VarDecl level. I'm checking if we could peform an extra check at that point. But maybe I'm totally taking a wrong turn, feel free to advise :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124038



More information about the cfe-commits mailing list