[clang] [clang] Do not clear FP pragma stack when instantiating functions (PR #70646)

Serge Pavlov via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 30 12:24:00 PDT 2023


spavloff wrote:

> To be clear, we're still ensuring the current pragma state during instantiation is what it was when the template is parsed, we're just not incorrectly dropping all of the saved pragma state when we're doing it?

Yes, the pragma is used at parse stage to set correct FP options is AST nodes. During template instantiation the function `resetFPOptions` is used to set the required FP options in Sema, because in some cases (ImplicitCast) the options are taken from Sema and not AST node. As a result the new AST nodes get FP otions as they are specified in the template pattern.

The issue with `resetFPOptions` was that it also reset pragma stack. It is OK for late template parse, or for the functions that are instantiated at the end of translation unit, but not for templates that are instantiated immediately, like consexpr functions.

https://github.com/llvm/llvm-project/pull/70646


More information about the cfe-commits mailing list