[PATCH] D88462: FP math settings for static duration initialization - work in progress
Melanie Blower via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 28 19:14:19 PDT 2020
mibintc created this revision.
mibintc added a reviewer: sepavloff.
mibintc added a project: clang.
mibintc requested review of this revision.
When compiling this C test case with -frounding-math there is an error diagnostic due to the rounding
float F3d = 0x1.000001p0;
This patch resets the FP settings around the initialization expression
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D88462
Files:
clang/lib/Parse/ParseDecl.cpp
Index: clang/lib/Parse/ParseDecl.cpp
===================================================================
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -2178,8 +2178,23 @@
}
P.Actions.ActOnCXXEnterDeclInitializer(S, ThisDecl);
}
+ auto ThisVarDecl = dyn_cast_or_null<VarDecl>(ThisDecl);
+ if (ThisVarDecl) {
+ FPOptionsOverride NewFPFeatures;
+ NewFPFeatures.setRoundingModeOverride(llvm::RoundingMode::NearestTiesToEven);
+ P.Actions.FpPragmaStack.Act(ThisDecl->getLocation(),
+ Sema::PSK_Push_Set, StringRef(), NewFPFeatures);
+ }
+ }
+ ~InitializerScopeRAII() {
+ pop();
+ auto ThisVarDecl = dyn_cast_or_null<VarDecl>(ThisDecl);
+ if (ThisVarDecl) {
+ FPOptionsOverride NewFPFeatures;
+ P.Actions.FpPragmaStack.Act(SourceLocation(),
+ Sema::PSK_Pop, StringRef(), NewFPFeatures);
+ }
}
- ~InitializerScopeRAII() { pop(); }
void pop() {
if (ThisDecl && P.getLangOpts().CPlusPlus) {
Scope *S = nullptr;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88462.294865.patch
Type: text/x-patch
Size: 1105 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200929/02f6cb27/attachment.bin>
More information about the cfe-commits
mailing list