summaryrefslogtreecommitdiff
path: root/gcc48-pr80129.patch
diff options
context:
space:
mode:
authorCoprDistGit <infra@openeuler.org>2024-08-05 01:49:16 +0000
committerCoprDistGit <infra@openeuler.org>2024-08-05 01:49:16 +0000
commita7b7e4a7981e56c8a7f015a6890a9bc70e77d277 (patch)
tree22200b7326b32ca672ffb6e4ce6d19a09dc476e5 /gcc48-pr80129.patch
parent28ea859f51e6ad6daf821902dabb4dec086ab981 (diff)
automatic import of compat-libgfortran-48openeuler24.03_LTS
Diffstat (limited to 'gcc48-pr80129.patch')
-rw-r--r--gcc48-pr80129.patch45
1 files changed, 45 insertions, 0 deletions
diff --git a/gcc48-pr80129.patch b/gcc48-pr80129.patch
new file mode 100644
index 0000000..34e160e
--- /dev/null
+++ b/gcc48-pr80129.patch
@@ -0,0 +1,45 @@
+2017-05-30 Jakub Jelinek <jakub@redhat.com>
+
+ Backported from mainline
+ 2017-03-22 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/80129
+ * gimplify.c (gimplify_modify_expr_rhs) <case COND_EXPR>: Clear
+ TREE_READONLY on result if writing it more than once.
+
+ * g++.dg/torture/pr80129.C: New test.
+
+--- gcc/gimplify.c
++++ gcc/gimplify.c
+@@ -4293,6 +4293,14 @@ gimplify_modify_expr_rhs (tree *expr_p, tree *from_p, tree *to_p,
+ if (ret != GS_ERROR)
+ ret = GS_OK;
+
++ /* If we are going to write RESULT more than once, clear
++ TREE_READONLY flag, otherwise we might incorrectly promote
++ the variable to static const and initialize it at compile
++ time in one of the branches. */
++ if (TREE_CODE (result) == VAR_DECL
++ && TREE_TYPE (TREE_OPERAND (cond, 1)) != void_type_node
++ && TREE_TYPE (TREE_OPERAND (cond, 2)) != void_type_node)
++ TREE_READONLY (result) = 0;
+ if (TREE_TYPE (TREE_OPERAND (cond, 1)) != void_type_node)
+ TREE_OPERAND (cond, 1)
+ = build2 (code, void_type_node, result,
+--- /dev/null
++++ gcc/testsuite/g++.dg/torture/pr80129.C
+@@ -0,0 +1,14 @@
++// PR c++/80129
++// { dg-do run }
++// { dg-options "-std=c++11" }
++
++struct A { bool a; int b; };
++
++int
++main ()
++{
++ bool c = false;
++ const A x = c ? A {true, 1} : A {false, 0};
++ if (x.a)
++ __builtin_abort ();
++}