inform (DECL_SOURCE_LOCATION (fun),
"lambdas are implicitly %<constexpr%> only in C++17 and later");
}
- else if (DECL_DESTRUCTOR_P (fun))
+ else if (DECL_DESTRUCTOR_P (fun) && cxx_dialect < cxx20)
{
- if (cxx_dialect < cxx20)
- {
- ret = false;
- if (complain)
- error_at (DECL_SOURCE_LOCATION (fun),
- "%<constexpr%> destructors only available"
- " with %<-std=c++20%> or %<-std=gnu++20%>");
- }
+ ret = false;
+ if (complain)
+ error_at (DECL_SOURCE_LOCATION (fun),
+ "%<constexpr%> destructors only available with "
+ "%<-std=c++20%> or %<-std=gnu++20%>");
}
- else if (!DECL_CONSTRUCTOR_P (fun))
+ else if (!DECL_CONSTRUCTOR_P (fun) && !DECL_DESTRUCTOR_P (fun))
{
tree rettype = TREE_TYPE (TREE_TYPE (fun));
if (!literal_type_p (rettype))
--- /dev/null
+// PR c++/114426
+// { dg-do compile { target c++11 } }
+
+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' destructors only available with" "" { target c++17_down } .-2 }
--- /dev/null
+// PR c++/114426
+// { dg-do compile }
+// { dg-additional-options "-O2" }
+
+struct A { virtual ~A (); };
+struct B : virtual A { virtual void foo () = 0; };
+struct C : B { C () {} };