llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Serge Pavlov (spavloff) <details> <summary>Changes</summary> After https://github.com/llvm/llvm-project/pull/85605 ([clang] Set correct FPOptions if attribute 'optnone' presents) the current FP options in Sema are saved during parsing function because Sema can modify them if optnone is present. However they were saved too late, it caused fails in some cases when precompiled headers are used. This patch moves the storing earlier. --- Full diff: https://github.com/llvm/llvm-project/pull/92146.diff 2 Files Affected: - (modified) clang/lib/Parse/Parser.cpp (+2-2) - (added) clang/test/PCH/optnone.cpp (+6) ``````````diff diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index adcbe5858bc78..869b9c6669c27 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -1439,6 +1439,8 @@ Decl *Parser::ParseFunctionDefinition(ParsingDeclarator &D, } } + Sema::FPFeaturesStateRAII SaveFPFeatures(Actions); + // Tell the actions module that we have entered a function definition with the // specified Declarator for the function. SkipBodyInfo SkipBody; @@ -1497,8 +1499,6 @@ Decl *Parser::ParseFunctionDefinition(ParsingDeclarator &D, return Actions.ActOnFinishFunctionBody(Res, nullptr, false); } - Sema::FPFeaturesStateRAII SaveFPFeatures(Actions); - if (Tok.is(tok::kw_try)) return ParseFunctionTryBlock(Res, BodyScope); diff --git a/clang/test/PCH/optnone.cpp b/clang/test/PCH/optnone.cpp new file mode 100644 index 0000000000000..734527b0d3f7d --- /dev/null +++ b/clang/test/PCH/optnone.cpp @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -emit-pch -DHEADER -x c++-header %s -o %t.pch +// RUN: %clang_cc1 -emit-llvm -include-pch %t.pch %s -o /dev/null + +#ifdef HEADER +__attribute__((optnone)) void foo() {} +#endif \ No newline at end of file `````````` </details> https://github.com/llvm/llvm-project/pull/92146 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits