[clang] [Clang][Sema] Ensure explicitly defaulted functions respect FP pragmas from their declaration site (PR #207429)
Kyungtak Woo via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 3 14:59:00 PDT 2026
================
@@ -6906,6 +6906,25 @@ Sema::getDefaultedFunctionKind(const FunctionDecl *FD) {
return DefaultedFunctionKind();
}
+namespace {
+/// RAII object to restore the floating-point (FP) features active at the time
+/// a defaulted function was declared. This ensures that the synthesized body
+/// of the function respects the FP pragmas (e.g., #pragma STDC FENV_ACCESS)
+/// that were in effect when the function was explicitly defaulted.
+struct DefaultedFunctionFPFeaturesRAII {
----------------
kevinwkt wrote:
Good point, the cleanup is automatically handled by the implicit destruction of the `SavedFPFeatures` member (`Sema::FPFeaturesStateRAII`), but I've added an explicitly defaulted destructor (`~DefaultedFunctionFPFeaturesRAII() = default;`) to make the RAII contract clearer to readers.
https://github.com/llvm/llvm-project/pull/207429
More information about the cfe-commits
mailing list