mirror of git://gcc.gnu.org/git/gcc.git
tree.c (build_constructor): Propagate TREE_SIDE_EFFECTS.
* tree.c (build_constructor): Propagate TREE_SIDE_EFFECTS. testsuite/ * gcc.dg/stmt-expr-4.c: New. From-SVN: r187923
This commit is contained in:
parent
1ca8bef021
commit
253cbc5f37
|
@ -1,3 +1,7 @@
|
||||||
|
2012-05-27 Nathan Sidwell <nathan@acm.org>
|
||||||
|
|
||||||
|
* tree.c (build_constructor): Propagate TREE_SIDE_EFFECTS.
|
||||||
|
|
||||||
2012-05-26 Jason Merrill <jason@redhat.com>
|
2012-05-26 Jason Merrill <jason@redhat.com>
|
||||||
|
|
||||||
PR c++/53220
|
PR c++/53220
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
2012-05-27 Nathan Sidwell <nathan@acm.org>
|
||||||
|
|
||||||
|
* gcc.dg/stmt-expr-4.c: New.
|
||||||
|
|
||||||
2012-05-26 Paolo Carlini <paolo.carlini@oracle.com>
|
2012-05-26 Paolo Carlini <paolo.carlini@oracle.com>
|
||||||
|
|
||||||
PR c++/53491
|
PR c++/53491
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
|
||||||
|
/* { dg-options "-O2 -std=gnu99" } */
|
||||||
|
/* Internal compiler error in iterative_hash_expr */
|
||||||
|
|
||||||
|
struct tree_string
|
||||||
|
{
|
||||||
|
char str[1];
|
||||||
|
};
|
||||||
|
|
||||||
|
union tree_node
|
||||||
|
{
|
||||||
|
struct tree_string string;
|
||||||
|
};
|
||||||
|
|
||||||
|
char *Foo (union tree_node * num_string)
|
||||||
|
{
|
||||||
|
char *str = ((union {const char * _q; char * _nq;})
|
||||||
|
((const char *)(({ __typeof (num_string) const __t
|
||||||
|
= num_string; __t; })
|
||||||
|
->string.str)))._nq;
|
||||||
|
return str;
|
||||||
|
}
|
15
gcc/tree.c
15
gcc/tree.c
|
@ -1416,17 +1416,24 @@ build_constructor (tree type, VEC(constructor_elt,gc) *vals)
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
constructor_elt *elt;
|
constructor_elt *elt;
|
||||||
bool constant_p = true;
|
bool constant_p = true;
|
||||||
|
bool side_effects_p = false;
|
||||||
|
|
||||||
TREE_TYPE (c) = type;
|
TREE_TYPE (c) = type;
|
||||||
CONSTRUCTOR_ELTS (c) = vals;
|
CONSTRUCTOR_ELTS (c) = vals;
|
||||||
|
|
||||||
FOR_EACH_VEC_ELT (constructor_elt, vals, i, elt)
|
FOR_EACH_VEC_ELT (constructor_elt, vals, i, elt)
|
||||||
if (!TREE_CONSTANT (elt->value))
|
{
|
||||||
{
|
/* Mostly ctors will have elts that don't have side-effects, so
|
||||||
|
the usual case is to scan all the elements. Hence a single
|
||||||
|
loop for both const and side effects, rather than one loop
|
||||||
|
each (with early outs). */
|
||||||
|
if (!TREE_CONSTANT (elt->value))
|
||||||
constant_p = false;
|
constant_p = false;
|
||||||
break;
|
if (TREE_SIDE_EFFECTS (elt->value))
|
||||||
}
|
side_effects_p = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
TREE_SIDE_EFFECTS (c) = side_effects_p;
|
||||||
TREE_CONSTANT (c) = constant_p;
|
TREE_CONSTANT (c) = constant_p;
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
|
|
Loading…
Reference in New Issue