compat-libgfortran-48/SOURCES/gcc48-pr77375.patch
2021-12-09 11:45:41 +00:00

38 lines
982 B
Diff

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