initializers, so the result of the evaluation doesn't leak through
inconsistently. Also, don't evaluate references to variables with
initializers with side-effects.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113128
91177308-0d34-0410-b5e6-
96231b3b80d8
VD->setEvaluatingValue();
- if (Visit(const_cast<Expr*>(Init))) {
+ Expr::EvalResult EResult;
+ if (Init->Evaluate(EResult, Info.Ctx) && !EResult.HasSideEffects &&
+ EResult.Val.isInt()) {
// Cache the evaluated value in the variable declaration.
+ Result = EResult.Val;
VD->setEvaluatedValue(Result);
return true;
}
--- /dev/null
+// RUN: %clang_cc1 -verify -emit-llvm-only
+
+// PR7242: Check that this doesn't crash.
+int main(void)
+{
+ int __negative = 1;
+ const int __max = __negative && 0 ;
+ __max / 0;
+}