[PATCH] D158540: Improve error message for constexpr constructors of virtual base classes

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 2 11:55:01 PDT 2023


aaron.ballman added inline comments.


================
Comment at: clang/docs/ReleaseNotes.rst:211-212
   with terminals with dark background colors. This is also more consistent with GCC.
+- Clang now displays an improved diagnostic and a note when defaulted special 
+  member is a contexpr in a class with virtual base class
 
----------------



================
Comment at: clang/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp:26-33
+struct Base {
+ constexpr Base() = default;
+};
+struct Derived : virtual Base { // expected-note 3{{virtual base class declared here}}
+  constexpr Derived() = default; // expected-error {{default constructor cannot be 'constexpr' in a class with virtual base class}}
+  constexpr Derived(const Derived&) = default; // expected-error {{copy constructor cannot be 'constexpr' in a class with virtual base class}}
+  constexpr Derived(Derived&&) = default; // expected-error {{move constructor cannot be 'constexpr' in a class with virtual base class}}
----------------
I think the test coverage should live in `clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp` as that's where the wording is in the standard for this restriction (https://eel.is/c++draft/dcl.constexpr).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158540/new/

https://reviews.llvm.org/D158540



More information about the cfe-commits mailing list