Commit 2d7231a3 by Jakub Jelinek Committed by Jakub Jelinek

re PR c++/36688 (Incorrect struct assignments with nested const initializers)

	PR c++/36688
	* gimplify.c (gimplify_modify_expr_rhs): Test TREE_READONLY
	on the VAR_DECL instead of TYPE_READONLY on its type.

	* g++.dg/init/const6.C: New test.

From-SVN: r139004
parent be349cac
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> 2008-08-12 Ira Rosen <irar@il.ibm.com>
* tree-vectorizer.c: Depend on langhooks.h. * tree-vectorizer.c: Depend on langhooks.h.
......
...@@ -3913,7 +3913,7 @@ gimplify_modify_expr_rhs (tree *expr_p, tree *from_p, tree *to_p, ...@@ -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 /* If we're assigning from a constant constructor, move the
constructor expression to the RHS of the MODIFY_EXPR. */ constructor expression to the RHS of the MODIFY_EXPR. */
if (DECL_INITIAL (*from_p) if (DECL_INITIAL (*from_p)
&& TYPE_READONLY (TREE_TYPE (*from_p)) && TREE_READONLY (*from_p)
&& !TREE_THIS_VOLATILE (*from_p) && !TREE_THIS_VOLATILE (*from_p)
&& TREE_CODE (DECL_INITIAL (*from_p)) == CONSTRUCTOR) && TREE_CODE (DECL_INITIAL (*from_p)) == CONSTRUCTOR)
{ {
......
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> 2008-08-12 Ira Rosen <irar@il.ibm.com>
* gcc.dg/vect/vect-multitypes-12.c: New. * gcc.dg/vect/vect-multitypes-12.c: New.
......
// 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 ();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment