Skip to content

Commit 9bbefb7

Browse files
authored
[clang] Store FPOptions earlier when parsing function (#92146)
After #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.
1 parent 54c6ee9 commit 9bbefb7

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

clang/lib/Parse/Parser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,6 +1439,8 @@ Decl *Parser::ParseFunctionDefinition(ParsingDeclarator &D,
14391439
}
14401440
}
14411441

1442+
Sema::FPFeaturesStateRAII SaveFPFeatures(Actions);
1443+
14421444
// Tell the actions module that we have entered a function definition with the
14431445
// specified Declarator for the function.
14441446
SkipBodyInfo SkipBody;
@@ -1497,8 +1499,6 @@ Decl *Parser::ParseFunctionDefinition(ParsingDeclarator &D,
14971499
return Actions.ActOnFinishFunctionBody(Res, nullptr, false);
14981500
}
14991501

1500-
Sema::FPFeaturesStateRAII SaveFPFeatures(Actions);
1501-
15021502
if (Tok.is(tok::kw_try))
15031503
return ParseFunctionTryBlock(Res, BodyScope);
15041504

clang/test/PCH/optnone.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: %clang_cc1 -emit-pch -x c++-header %s -o %t.pch
2+
// RUN: %clang_cc1 -emit-llvm -DMAIN -include-pch %t.pch %s -o /dev/null
3+
4+
#ifndef MAIN
5+
__attribute__((optnone)) void foo() {}
6+
#endif

0 commit comments

Comments
 (0)