85359c
2017-05-30  Jakub Jelinek  <jakub@redhat.com>
85359c
 
85359c
 	Backported from mainline
85359c
	2016-09-16  Jakub Jelinek  <jakub@redhat.com>
85359c
85359c
	PR c++/77375
85359c
	* class.c (check_bases): Set CLASSTYPE_HAS_MUTABLE if any
85359c
	TYPE_HAS_MUTABLE_P for any bases.
85359c
85359c
	* g++.dg/cpp0x/mutable1.C: New test.
85359c
85359c
--- gcc/cp/class.c	2017-10-17 17:27:32.287980595 +0200
85359c
+++ gcc/cp/class.c	2017-10-17 17:29:11.104213281 +0200
85359c
@@ -1479,6 +1479,8 @@ check_bases (tree t,
85359c
 	|= CLASSTYPE_CONTAINS_EMPTY_CLASS_P (basetype);
85359c
       TYPE_HAS_COMPLEX_DFLT (t) |= (!TYPE_HAS_DEFAULT_CONSTRUCTOR (basetype)
85359c
 				    || TYPE_HAS_COMPLEX_DFLT (basetype));
85359c
+      if (TYPE_HAS_MUTABLE_P (basetype))
85359c
+	CLASSTYPE_HAS_MUTABLE (t) = 1;
85359c
 
85359c
       /*  A standard-layout class is a class that:
85359c
 	  ...
85359c
--- /dev/null
85359c
+++ gcc/testsuite/g++.dg/cpp0x/mutable1.C
85359c
@@ -0,0 +1,12 @@
85359c
+// PR c++/77375
85359c
+// { dg-do run { target c++11 } }
85359c
+
85359c
+struct Base { mutable int i; };
85359c
+struct Derived : Base {};
85359c
+const Derived foo{};
85359c
+
85359c
+int
85359c
+main ()
85359c
+{
85359c
+  foo.i = 42;
85359c
+}