summaryrefslogtreecommitdiff
path: root/clang/lib
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Lex/PPMacroExpansion.cpp37
-rw-r--r--clang/lib/Lex/Preprocessor.cpp5
-rw-r--r--clang/lib/Sema/SemaAttr.cpp17
3 files changed, 8 insertions, 51 deletions
diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp
index bbc271e5611e..76d0d53ed31d 100644
--- a/clang/lib/Lex/PPMacroExpansion.cpp
+++ b/clang/lib/Lex/PPMacroExpansion.cpp
@@ -1637,35 +1637,14 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
Tok.setKind(tok::string_literal);
} else if (II == Ident__FLT_EVAL_METHOD__) {
// __FLT_EVAL_METHOD__ is set to the default value.
- if (getTUFPEvalMethod() ==
- LangOptions::FPEvalMethodKind::FEM_Indeterminable) {
- // This is possible if `AllowFPReassoc` or `AllowReciprocal` is enabled.
- // These modes can be triggered via the command line option `-ffast-math`
- // or via a `pragam float_control`.
- // __FLT_EVAL_METHOD__ expands to -1.
- // The `minus` operator is the next token we read from the stream.
- auto Toks = std::make_unique<Token[]>(1);
- OS << "-";
- Tok.setKind(tok::minus);
- // Push the token `1` to the stream.
- Token NumberToken;
- NumberToken.startToken();
- NumberToken.setKind(tok::numeric_constant);
- NumberToken.setLiteralData("1");
- NumberToken.setLength(1);
- Toks[0] = NumberToken;
- EnterTokenStream(std::move(Toks), 1, /*DisableMacroExpansion*/ false,
- /*IsReinject*/ false);
- } else {
- OS << getTUFPEvalMethod();
- // __FLT_EVAL_METHOD__ expands to a simple numeric value.
- Tok.setKind(tok::numeric_constant);
- if (getLastFPEvalPragmaLocation().isValid()) {
- // The program is ill-formed. The value of __FLT_EVAL_METHOD__ is
- // altered by the pragma.
- Diag(Tok, diag::err_illegal_use_of_flt_eval_macro);
- Diag(getLastFPEvalPragmaLocation(), diag::note_pragma_entered_here);
- }
+ OS << getTUFPEvalMethod();
+ // __FLT_EVAL_METHOD__ expands to a simple numeric value.
+ Tok.setKind(tok::numeric_constant);
+ if (getLastFPEvalPragmaLocation().isValid()) {
+ // The program is ill-formed. The value of __FLT_EVAL_METHOD__ is altered
+ // by the pragma.
+ Diag(Tok, diag::err_illegal_use_of_flt_eval_macro);
+ Diag(getLastFPEvalPragmaLocation(), diag::note_pragma_entered_here);
}
} else if (II == Ident__COUNTER__) {
// __COUNTER__ expands to a simple numeric value.
diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp
index d9a51b7e9da6..0d411abf8f1c 100644
--- a/clang/lib/Lex/Preprocessor.cpp
+++ b/clang/lib/Lex/Preprocessor.cpp
@@ -207,11 +207,6 @@ void Preprocessor::Initialize(const TargetInfo &Target,
else
// Set initial value of __FLT_EVAL_METHOD__ from the command line.
setCurrentFPEvalMethod(SourceLocation(), getLangOpts().getFPEvalMethod());
- // When `-ffast-math` option is enabled, it triggers several driver math
- // options to be enabled. Among those, only one the following two modes
- // affect the eval-method: reciprocal or reassociate.
- if (getLangOpts().AllowFPReassoc || getLangOpts().AllowRecip)
- setCurrentFPEvalMethod(SourceLocation(), LangOptions::FEM_Indeterminable);
}
void Preprocessor::InitializeForModelFile() {
diff --git a/clang/lib/Sema/SemaAttr.cpp b/clang/lib/Sema/SemaAttr.cpp
index 42f582724564..3ea97f6aa8f2 100644
--- a/clang/lib/Sema/SemaAttr.cpp
+++ b/clang/lib/Sema/SemaAttr.cpp
@@ -565,13 +565,6 @@ void Sema::ActOnPragmaFloatControl(SourceLocation Loc,
case PFC_Precise:
NewFPFeatures.setFPPreciseEnabled(true);
FpPragmaStack.Act(Loc, Action, StringRef(), NewFPFeatures);
- if (PP.getCurrentFPEvalMethod() ==
- LangOptions::FPEvalMethodKind::FEM_Indeterminable &&
- PP.getLastFPEvalPragmaLocation().isValid())
- // A preceding `pragma float_control(precise,off)` has changed
- // the value of the evaluation method.
- // Set it back to its old value.
- PP.setCurrentFPEvalMethod(SourceLocation(), PP.getLastFPEvalMethod());
break;
case PFC_NoPrecise:
if (CurFPFeatures.getExceptionMode() == LangOptions::FPE_Strict)
@@ -581,10 +574,6 @@ void Sema::ActOnPragmaFloatControl(SourceLocation Loc,
else
NewFPFeatures.setFPPreciseEnabled(false);
FpPragmaStack.Act(Loc, Action, StringRef(), NewFPFeatures);
- PP.setLastFPEvalMethod(PP.getCurrentFPEvalMethod());
- // `AllowFPReassoc` or `AllowReciprocal` option is enabled.
- PP.setCurrentFPEvalMethod(
- Loc, LangOptions::FPEvalMethodKind::FEM_Indeterminable);
break;
case PFC_Except:
if (!isPreciseFPEnabled())
@@ -608,12 +597,6 @@ void Sema::ActOnPragmaFloatControl(SourceLocation Loc,
}
FpPragmaStack.Act(Loc, Action, StringRef(), NewFPFeatures);
NewFPFeatures = FpPragmaStack.CurrentValue;
- if (CurFPFeatures.getAllowFPReassociate() ||
- CurFPFeatures.getAllowReciprocal())
- // Since we are popping the pragma, we don't want to be passing
- // a location here.
- PP.setCurrentFPEvalMethod(SourceLocation(),
- CurFPFeatures.getFPEvalMethod());
break;
}
CurFPFeatures = NewFPFeatures.applyOverrides(getLangOpts());