[all-commits] [llvm/llvm-project] fde592: [clang] Reset FP options before template instantia...

Serge Pavlov via All-commits all-commits at lists.llvm.org
Wed Jul 12 21:51:03 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: fde5924dcc69fe814085482df259b8cfee236f2c
      https://github.com/llvm/llvm-project/commit/fde5924dcc69fe814085482df259b8cfee236f2c
  Author: Serge Pavlov <sepavloff at gmail.com>
  Date:   2023-07-13 (Thu, 13 Jul 2023)

  Changed paths:
    M clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
    M clang/test/CodeGen/fp-template.cpp

  Log Message:
  -----------
  [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




More information about the All-commits mailing list