aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/gimplify.c2
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/init/const6.C27
4 files changed, 39 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index dfa628e..be9020e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2008-08-12 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/36688
+ * gimplify.c (gimplify_modify_expr_rhs): Test TREE_READONLY
+ on the VAR_DECL instead of TYPE_READONLY on its type.
+
2008-08-12 Ira Rosen <irar@il.ibm.com>
* tree-vectorizer.c: Depend on langhooks.h.
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index f22111d..753aa59 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -3913,7 +3913,7 @@ gimplify_modify_expr_rhs (tree *expr_p, tree *from_p, tree *to_p,
/* If we're assigning from a constant constructor, move the
constructor expression to the RHS of the MODIFY_EXPR. */
if (DECL_INITIAL (*from_p)
- && TYPE_READONLY (TREE_TYPE (*from_p))
+ && TREE_READONLY (*from_p)
&& !TREE_THIS_VOLATILE (*from_p)
&& TREE_CODE (DECL_INITIAL (*from_p)) == CONSTRUCTOR)
{
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 55f1706..d6f2811 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2008-08-12 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/36688
+ * g++.dg/init/const6.C: New test.
+
2008-08-12 Ira Rosen <irar@il.ibm.com>
* gcc.dg/vect/vect-multitypes-12.c: New.
diff --git a/gcc/testsuite/g++.dg/init/const6.C b/gcc/testsuite/g++.dg/init/const6.C
new file mode 100644
index 0000000..f341969
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/const6.C
@@ -0,0 +1,27 @@
+// PR c++/36688
+// { dg-do compile }
+// { dg-options "-O2" }
+
+struct S
+{
+ long long a;
+ long long b;
+ long long c;
+};
+
+struct T
+{
+ S g;
+ long long h[12];
+};
+
+static const S s = { 1, 2, 3 };
+static const T t = { s, 0 };
+
+int
+main ()
+{
+ T x = t;
+ if (__builtin_memcmp (&x, &t, sizeof (T)))
+ __builtin_abort ();
+}