git: 1cd9788408aa - main - Merge commit fde5924dcc69 from llvm-project (by Serge Pavlov):
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 13 Jul 2023 18:59:23 UTC
The branch main has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=1cd9788408aa9ea4fd0fbc3e06bd9a4eaf8d8d22 commit 1cd9788408aa9ea4fd0fbc3e06bd9a4eaf8d8d22 Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2023-07-13 18:57:22 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2023-07-13 18:57:22 +0000 Merge commit fde5924dcc69 from llvm-project (by Serge Pavlov): [clang] Reset FP options before template instantiation AST nodes that may depend on FP options keep them as a difference relative to the options outside the AST node. At the moment of instantiation the FP options may be different from the default values, defined by command-line option. In such case FP attributes would have unexpected values. For example, the code: template <class C> void func_01(int last, C) { func_01(last, int()); } void func_02() { func_01(0, 1); } #pragma STDC FENV_ACCESS ON caused compiler crash, because template instantiation takes place at the end of translation unit, where pragma STDC FENV_ACCESS is in effect. As a result, code in the template instantiation would use constrained intrinsics while the function does not have StrictFP attribute. To solve this problem, FP attributes in Sema must be set to default values, defined by command line options. This change resolves https://github.com/llvm/llvm-project/issues/63542. Differential Revision: https://reviews.llvm.org/D154359 Requested by: pkubaj PR: 265755, 265758 MFC after: 1 month --- contrib/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/contrib/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/contrib/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 7a0da8d08333..bed5237749c5 100644 --- a/contrib/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/contrib/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -5057,6 +5057,10 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, // PushDeclContext because we don't have a scope. Sema::ContextRAII savedContext(*this, Function); + FPFeaturesStateRAII SavedFPFeatures(*this); + CurFPFeatures = FPOptions(getLangOpts()); + FpPragmaStack.CurrentValue = FPOptionsOverride(); + if (addInstantiatedParametersToScope(Function, PatternDecl, Scope, TemplateArgs)) return;