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;
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;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits