diff mbox

[C++] PR 51612

Message ID 4EEFDF28.2030905@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Dec. 20, 2011, 1:04 a.m. UTC
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.carlini@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.carlini@oracle.com>

	PR c++/51612
	* g++.dg/cpp0x/constexpr-ice4.C: New.

Comments

Jason Merrill Dec. 20, 2011, 2:21 a.m. UTC | #1
OK.

Jason
diff mbox

Patch

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;
 }