forked from OSchip/llvm-project
Avoid assert-crash in a case where the expression passed to EmitConstantExpr
legitimately has side-effects (and needs to be generated as a non-constant). llvm-svn: 88767
This commit is contained in:
parent
b210fc598f
commit
274ab904d0
|
@ -821,9 +821,7 @@ llvm::Constant *CodeGenModule::EmitConstantExpr(const Expr *E,
|
|||
else
|
||||
Success = E->Evaluate(Result, Context);
|
||||
|
||||
if (Success) {
|
||||
assert(!Result.HasSideEffects &&
|
||||
"Constant expr should not have any side effects!");
|
||||
if (Success && !Result.HasSideEffects) {
|
||||
switch (Result.Val.getKind()) {
|
||||
case APValue::Uninitialized:
|
||||
assert(0 && "Constant expressions should be initialized.");
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
// RUN: clang-cc -emit-llvm-only -verify %s
|
||||
|
||||
// Make sure we don't crash generating y; its value is constant, but the
|
||||
// initializer has side effects, so EmitConstantExpr should fail.
|
||||
int x();
|
||||
int y = x() && 0;
|
Loading…
Reference in New Issue