]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c++/77375 (constant object with mutable subobject allocated in read...
authorJakub Jelinek <jakub@redhat.com>
Tue, 30 May 2017 07:24:56 +0000 (09:24 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 30 May 2017 07:24:56 +0000 (09:24 +0200)
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.

From-SVN: r248608

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/mutable1.C [new file with mode: 0644]

index 167d78e938b1565c9366dfc67ca18eef84fd7736..487e2c7bb97b516d31eef683f43ca6650a1ad0f3 100644 (file)
@@ -1,6 +1,12 @@
 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.
+
        2016-08-11  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/72868
index 9dc15da2825704e81939a7c83b356556fc2d5a79..50fbe24459063331f990a438c014e3842f607fd6 100644 (file)
@@ -1763,6 +1763,8 @@ check_bases (tree t,
       SET_CLASSTYPE_REF_FIELDS_NEED_INIT
        (t, CLASSTYPE_REF_FIELDS_NEED_INIT (t)
         | CLASSTYPE_REF_FIELDS_NEED_INIT (basetype));
+      if (TYPE_HAS_MUTABLE_P (basetype))
+       CLASSTYPE_HAS_MUTABLE (t) = 1;
 
       /*  A standard-layout class is a class that:
          ...
index 8618807b782c0eb2350779a1abfed3da42af0c0a..f7cdcc87a0b6f65a32a306e22d9f35fd6f0dc3c5 100644 (file)
@@ -1,6 +1,11 @@
 2017-05-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2016-09-16  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/77375
+       * g++.dg/cpp0x/mutable1.C: New test.
+
        2016-09-16  Jakub Jelinek  <jakub@redhat.com>
                    Eric Botcazou  <ebotcazou@adacore.com>
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/mutable1.C b/gcc/testsuite/g++.dg/cpp0x/mutable1.C
new file mode 100644 (file)
index 0000000..4dd3718
--- /dev/null
@@ -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;
+}