[Clang] Propagate const context info when emitting compound literal
This patch fixes a crash when trying to emit a constant compound literal. For C++ Clang evaluates either casts or binary operations at translation time, but doesn't pass on the InConstantContext information that was inferred when parsing the statement. Because of this, strict FP evaluation (-ftrapping-math) which shouldn't be in effect yet, then causes checkFloatingpointResult to return false, which in tryEmitGlobalCompoundLiteral will trigger an assert that the compound literal wasn't constant. The discussion here around 'manifestly constant evaluated contexts' was very helpful to me when trying to understand what LLVM's position is on what evaluation context should be in effect, together with the explanatory text in that patch itself: https://reviews.llvm.org/D87528 Reviewed By: rjmccall, DavidSpickett Differential Revision: https://reviews.llvm.org/D131555
Loading
Please sign in to comment