[Clang] Fix consteval propagation for aggregates and defaulted constructors
authorCorentin Jabot <corentinjabot@gmail.com>
Mon, 10 Jul 2023 06:54:15 +0000 (08:54 +0200)
committerCorentin Jabot <corentinjabot@gmail.com>
Mon, 24 Jul 2023 16:15:38 +0000 (18:15 +0200)
commit8698262a4365bf22b5b0c96e77bfecd3dcf084a7
tree78c01a94f51a758084d3d17c7709cad968a4d3c0
parent331a54d670722f5ee6b64a25d1547df3679d6c51
[Clang] Fix consteval propagation for aggregates and defaulted constructors

This patch does a few things:

* Fix aggregate initialization.
  When an aggregate has an initializer that is immediate-escalating,
  the context in which it is used automatically becomes an immediate function.
  The wording does that by rpretending an aggregate initialization is itself
  an invocation which is not really how clang works, so my previous attempt
  was... wrong.

* Fix initialization of defaulted constructors with immediate escalating
  default member initializers.
  The wording was silent about that case and I did not handled it fully
  https://cplusplus.github.io/CWG/issues/2760.html

* Fix diagnostics
  In some cases clang would produce additional and unhelpful
  diagnostics by listing the invalid references to consteval
  function that appear in immediate escalating functions

Fixes https://github.com/llvm/llvm-project/issues/63742

Reviewed By: aaron.ballman, #clang-language-wg, Fznamznon

Differential Revision: https://reviews.llvm.org/D155175
clang/include/clang/AST/RecursiveASTVisitor.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/CodeGenCXX/cxx2c-consteval-propagate.cpp [new file with mode: 0644]
clang/test/SemaCXX/cxx2a-consteval-default-params.cpp
clang/test/SemaCXX/cxx2b-consteval-propagate.cpp