rjmccall added inline comments.
================
Comment at: lib/CodeGen/CGExpr.cpp:1323
+ if (result.HasSideEffects && !AllowSideEffects) {
+ assert(!isa<DeclRefExpr>(E) && "declrefs should not have side effects");
return ConstantEmission();
----------------
The side effects here are those associated with the initializer of the
referenced declaration, not the DRE itself. Some expressions can be
constant-evaluated despite having side-effects because the side-effects occur
in an ignored operand, like the LHS of a comma or the base of a MemberExpr that
refers to a static member.
We can't allow side effects here because (1) we're not actually collecting the
side-effectful expressions to emit and (2) we'd need some permission from the
context to decide that we're allowed to do so anyway (with a lambda capture,
those side-effects have actually already been emitted, but I'm not convinced
that's always true).
On the other hand, I think we need to be able to emit MemberExprs to static
members as constants despite the presence of side-effects in their base
expressions, and I can't think of any reasonable way to do that except actually
making a temporary DeclRefExpr to try to constant-emit instead.
Repository:
rL LLVM
https://reviews.llvm.org/D36876
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits