[PATCH] D87528: Enable '#pragma STDC FENV_ACCESS' in frontend cf. D69272 - Work in Progress
Richard Smith - zygoloid via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Sep 13 23:26:04 PDT 2020
rsmith added a comment.
> @rsmith asked "I don't see changes to the constant evaluator". The semantic rules for enabling this pragma require that strict or precise semantics be in effect., see SemaAttr.cpp And the floating point constant evaluation doesn't occur when strict or precise
What do you mean "the floating point constant evaluation doesn't occur when strict or precise"? I don't see any code to do that in `ExprConstant.cpp`, neither in trunk nor in this patch. The constant evaluator certainly is still invoked when we're in strict or precise mode. I would expect the evaluator would need to check for FP strictness whenever it encounters a floating-point operator (eg, here: https://github.com/llvm/llvm-project/blob/master/clang/lib/AST/ExprConstant.cpp#L13340), and treat such cases as non-constant.
I'd like to see a C++ test for something like this:
float myAdd() {
#pragma STDC FENV_ACCESS ON
static double v = 1.0 / 3.0;
return v;
}
If that generates a runtime guarded initialization for `v`, then I'd be a bit more convinced we're getting this right.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D87528/new/
https://reviews.llvm.org/D87528
More information about the cfe-commits
mailing list