[PATCH] D128083: [C++20] Correctly handle constexpr/consteval explicitly defaulted special member instantiation behavior

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 17 11:48:14 PDT 2022


aaron.ballman created this revision.
aaron.ballman added reviewers: rsmith, erichkeane, clang-language-wg, jyknight.
Herald added a project: All.
aaron.ballman requested review of this revision.
Herald added a project: clang.

When instantiating a class template, if the primary class template special member function declaration was declared `constexpr` or `consteval`, the instantiation is also considered to be a consteval function even if the instantiation would not be valid to use in a constant expression (http://eel.is/c++draft/dcl.constexpr#7). However, when instantiating such a class, we were incorrectly saying the special member was not a constexpr function when a base class or member variable would cause the instantiation to not be usable in a constant expression. This addresses the issue by falling back to the primary declaration of the explicitly defaulted special member function.

This caused some unexpected test failures with friend declaration checking, but the standard is quite unclear on what's expected there. We also have existing bugs in that particular area (https://godbolt.org/z/cPKGvx746). I raised some questions on the Core reflectors about what is expected and put a FIXME into the test to make it clear that's unresolved.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128083

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/AST/DeclCXX.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/cxx0x-defaulted-functions.cpp
  clang/test/SemaCXX/cxx2a-consteval.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128083.437983.patch
Type: text/x-patch
Size: 7735 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220617/514e0b4c/attachment.bin>


More information about the cfe-commits mailing list