I thought this diagnostic could be clearer that the problem is the
combination of virtual bases and constexpr constructor, not just complain
that the class has virtual bases without context.
gcc/cp/ChangeLog:
* constexpr.cc (is_valid_constexpr_fn): Improve diagnostic.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/constexpr-dtor16.C: Adjust diagnostic.
* g++.dg/cpp2a/constexpr-dynamic10.C: Likewise.
{
ret = false;
if (complain)
- error ("%q#T has virtual base classes", DECL_CONTEXT (fun));
+ {
+ if (DECL_CONSTRUCTOR_P (fun))
+ error ("%<constexpr%> constructor in %q#T that has "
+ "virtual base classes", DECL_CONTEXT (fun));
+ else
+ error ("%<constexpr%> destructor in %q#T that has "
+ "virtual base classes", DECL_CONTEXT (fun));
+ }
}
return ret;
struct A { virtual ~A (); };
struct B : virtual A { constexpr ~B () {} };
-// { dg-error "'struct B' has virtual base classes" "" { target c++20 } .-1 }
+// { dg-error "'constexpr' destructor in 'struct B' that has virtual base classes" "" { target c++20 } .-1 }
// { dg-error "'constexpr' destructors only available with" "" { target c++17_down } .-2 }
struct C { virtual void a(); };
struct B { virtual void b(); };
-struct A : virtual B, C { virtual void c(); }; // { dg-error ".struct A. has virtual base classes" }
+struct A : virtual B, C { virtual void c(); }; // { dg-error "virtual base classes" }
constexpr A a; // { dg-error "call" }