Skip to content

Commit 82a3969

Browse files
committed
Revert "[Clang] Reset FP options before function instantiations"
This reverts commit 98390cc. It caused issue #63542.
1 parent bf8e92c commit 82a3969

File tree

4 files changed

+0
-49
lines changed

4 files changed

+0
-49
lines changed

clang/include/clang/Sema/Sema.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -710,12 +710,6 @@ class Sema final {
710710
return result;
711711
}
712712

713-
void resetFPOptions(FPOptions FPO) {
714-
CurFPFeatures = FPO;
715-
FpPragmaStack.Stack.clear();
716-
FpPragmaStack.CurrentValue = FPO.getChangesFrom(FPOptions(LangOpts));
717-
}
718-
719713
// RAII object to push / pop sentinel slots for all MS #pragma stacks.
720714
// Actions should be performed only if we enter / exit a C++ method body.
721715
class PragmaStackSentinelRAII {
@@ -14007,8 +14001,6 @@ struct LateParsedTemplate {
1400714001
CachedTokens Toks;
1400814002
/// The template function declaration to be late parsed.
1400914003
Decl *D;
14010-
/// Floating-point options in the point of definition.
14011-
FPOptions FPO;
1401214004
};
1401314005

1401414006
template <>

clang/lib/Parse/ParseTemplate.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,10 +1742,6 @@ void Parser::ParseLateTemplatedFuncDef(LateParsedTemplate &LPT) {
17421742
Actions.PushDeclContext(Actions.getCurScope(), DC);
17431743
}
17441744

1745-
// Parsing should occur with empty FP pragma stack and FP options used in the
1746-
// point of the template definition.
1747-
Actions.resetFPOptions(LPT.FPO);
1748-
17491745
assert(!LPT.Toks.empty() && "Empty body!");
17501746

17511747
// Append the current token at the end of the new token stream so that it

clang/lib/Sema/SemaTemplate.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11342,7 +11342,6 @@ void Sema::MarkAsLateParsedTemplate(FunctionDecl *FD, Decl *FnD,
1134211342
// Take tokens to avoid allocations
1134311343
LPT->Toks.swap(Toks);
1134411344
LPT->D = FnD;
11345-
LPT->FPO = getCurFPFeatures();
1134611345
LateParsedTemplateMap.insert(std::make_pair(FD, std::move(LPT)));
1134711346

1134811347
FD->setLateTemplateParsed(true);

clang/test/CodeGen/fp-template.cpp

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,40 +15,4 @@ float func_01(float x, float y) {
1515
// CHECK-SAME: (float noundef %{{.*}}, float noundef %{{.*}}) #[[ATTR01:[0-9]+]]{{.*}} {
1616
// CHECK: call float @llvm.experimental.constrained.fadd.f32
1717

18-
19-
template <typename Ty>
20-
Ty templ_02(Ty x, Ty y) {
21-
return x + y;
22-
}
23-
24-
#pragma STDC FENV_ROUND FE_UPWARD
25-
26-
template <typename Ty>
27-
Ty templ_03(Ty x, Ty y) {
28-
return x - y;
29-
}
30-
31-
#pragma STDC FENV_ROUND FE_TONEAREST
32-
33-
float func_02(float x, float y) {
34-
return templ_02(x, y);
35-
}
36-
37-
// CHECK-LABEL: define {{.*}} float @_Z8templ_02IfET_S0_S0_
38-
// CHECK: %add = fadd float %0, %1
39-
40-
float func_03(float x, float y) {
41-
return templ_03(x, y);
42-
}
43-
44-
// CHECK-LABEL: define {{.*}} float @_Z8templ_03IfET_S0_S0_
45-
// CHECK: call float @llvm.experimental.constrained.fsub.f32({{.*}}, metadata !"round.upward", metadata !"fpexcept.ignore")
46-
47-
48-
// This pragma sets non-default rounding mode before delayed parsing occurs. It
49-
// is used to check that the parsing uses FP options defined by command line
50-
// options or by pragma before the template definition but not by this pragma.
51-
#pragma STDC FENV_ROUND FE_TOWARDZERO
52-
53-
5418
// CHECK: attributes #[[ATTR01]] = { {{.*}}strictfp

0 commit comments

Comments
 (0)