Hi,
thus, as explained by Jason in the audit trail, the reason why we are
ICE-ing here and failing to provide satisfactory diagnostics is that we
are not checking for virtual base classes, which are explicitly
forbidden in C++11 for constexpr constructors.
Thus I'm simply doing the below, tested x86_64-linux.
Thanks,
Paolo.
PS: I was not 100% sure, thus I double checked that defaulted and
deleted are handled elsewhere.
//////////////////////
/cp
2011-12-20 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/51612
* semantics.c (is_valid_constexpr_fn): In case of constexpr
constructors also check for virtual base classes.
/testsuite
2011-12-20 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/51612
* g++.dg/cpp0x/constexpr-ice4.C: New.
Index: testsuite/g++.dg/cpp0x/constexpr-ice4.C
===================================================================
--- testsuite/g++.dg/cpp0x/constexpr-ice4.C (revision 0)
+++ testsuite/g++.dg/cpp0x/constexpr-ice4.C (revision 0)
@@ -0,0 +1,9 @@
+// PR c++/51612
+// { dg-options -std=c++0x }
+
+struct A {};
+
+struct B : virtual A
+{
+ constexpr B() { } // { dg-error "has virtual base classes" }
+};
Index: cp/semantics.c
===================================================================
--- cp/semantics.c (revision 182508)
+++ cp/semantics.c (working copy)
@@ -5730,6 +5730,12 @@ is_valid_constexpr_fn (tree fun, bool complain)
}
}
}
+ else if (CLASSTYPE_VBASECLASSES (DECL_CONTEXT (fun)))
+ {
+ ret = false;
+ if (complain)
+ error ("%q#T has virtual base classes", DECL_CONTEXT (fun));
+ }
return ret;
}