Commit 587b2f67 by Marek Polacek Committed by Marek Polacek

re PR c++/84590 (-fsanitize=undefined internal compiler error: tree check:…

re PR c++/84590 (-fsanitize=undefined internal compiler error: tree check: expected constructor, have target_expr in split_nonconstant_init_1, at cp/typeck2.c:629)

	PR c++/84590
	* cp-gimplify.c (cp_fully_fold): Unwrap TARGET_EXPR or a CONSTRUCTOR
	wrapped in VIEW_CONVERT_EXPR.

	* c-c++-common/ubsan/shift-11.c: New test.

From-SVN: r258132
parent 70088b95
2018-03-02 Marek Polacek <polacek@redhat.com>
PR c++/84590
* cp-gimplify.c (cp_fully_fold): Unwrap TARGET_EXPR or a CONSTRUCTOR
wrapped in VIEW_CONVERT_EXPR.
2018-03-01 Martin Sebor <msebor@redhat.com>
PR c++/84294
......
......@@ -2037,7 +2037,17 @@ cp_fully_fold (tree x)
/* FIXME cp_fold ought to be a superset of maybe_constant_value so we don't
have to call both. */
if (cxx_dialect >= cxx11)
x = maybe_constant_value (x);
{
x = maybe_constant_value (x);
/* Sometimes we are given a CONSTRUCTOR but the call above wraps it into
a TARGET_EXPR; undo that here. */
if (TREE_CODE (x) == TARGET_EXPR)
x = TARGET_EXPR_INITIAL (x);
else if (TREE_CODE (x) == VIEW_CONVERT_EXPR
&& TREE_CODE (TREE_OPERAND (x, 0)) == CONSTRUCTOR
&& TREE_TYPE (TREE_OPERAND (x, 0)) == TREE_TYPE (x))
x = TREE_OPERAND (x, 0);
}
return cp_fold_rvalue (x);
}
......
2018-03-02 Marek Polacek <polacek@redhat.com>
PR c++/84590
* c-c++-common/ubsan/shift-11.c: New test.
2018-03-02 Richard Sandiford <richard.sandiford@linaro.org>
* gcc.dg/vect/vect-alias-check-13.c: New test.
......
/* PR c++/84590 */
/* { dg-do compile } */
/* { dg-options "-fsanitize=shift" } */
struct S {
int b;
};
void
fn (void)
{
struct S c1 = { 1 << -1 }; /* { dg-warning "left shift" } */
}
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