diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -7491,6 +7491,10 @@ TreeTransform::TransformCompoundStmt(CompoundStmt *S, bool IsStmtExpr) { Sema::CompoundScopeRAII CompoundScope(getSema()); + Sema::FPFeaturesStateRAII FPSave(getSema()); + if (S->hasStoredFPFeatures()) + getSema().resetFPOptions( + S->getStoredFPFeatures().applyOverrides(getSema().getLangOpts())); const Stmt *ExprResult = S->getStmtExprResult(); bool SubStmtInvalid = false; diff --git a/clang/test/SemaCXX/template-64605.cpp b/clang/test/SemaCXX/template-64605.cpp new file mode 100644 --- /dev/null +++ b/clang/test/SemaCXX/template-64605.cpp @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -ast-dump -ast-dump-filter=b_64605 %s | FileCheck %s + +// https://github.com/llvm/llvm-project/issues/64605 + +#pragma STDC FENV_ACCESS ON +template +int b_64605() { + int x; + if ((float)0xFFFFFFFF != (float)0x100000000) { + x = 1; + } + return x; +} +int f() { return b_64605(); } + +// CHECK: ImplicitCastExpr {{.*}} 'float' RoundingMath=1 AllowFEnvAccess=1 +// CHECK-NEXT: IntegerLiteral {{.*}} 4294967295 + +// CHECK: FunctionDecl {{.*}} b_64605 'int ()' implicit_instantiation +// CHECK-NEXT: TemplateArgument type 'void' + +// CHECK: ImplicitCastExpr {{.*}} 'float' RoundingMath=1 AllowFEnvAccess=1 +// CHECK-NEXT: IntegerLiteral {{.*}} 4294967295