diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b9a1b088573..8a8bb9e3a32 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2012-12-05 Richard Biener + + PR lto/55525 + * gimple-streamer-in.c (input_gimple_stmt): Fixup ARRAY_REFs as well. + 2012-12-04 Ian Lance Taylor * godump.c (find_dummy_types): Output a dummy type if we couldn't diff --git a/gcc/gimple-streamer-in.c b/gcc/gimple-streamer-in.c index 6736defcec5..49c4fe47a1f 100644 --- a/gcc/gimple-streamer-in.c +++ b/gcc/gimple-streamer-in.c @@ -148,14 +148,14 @@ input_gimple_stmt (struct lto_input_block *ib, struct data_in *data_in, if (!op) continue; - /* Fixup FIELD_DECLs in COMPONENT_REFs, they are not handled - by decl merging. */ if (TREE_CODE (op) == ADDR_EXPR) op = TREE_OPERAND (op, 0); while (handled_component_p (op)) { if (TREE_CODE (op) == COMPONENT_REF) { + /* Fixup FIELD_DECLs in COMPONENT_REFs, they are not handled + by decl merging. */ tree field, type, tem; tree closest_match = NULL_TREE; field = TREE_OPERAND (op, 1); @@ -215,6 +215,18 @@ input_gimple_stmt (struct lto_input_block *ib, struct data_in *data_in, else TREE_OPERAND (op, 1) = tem; } + else if ((TREE_CODE (op) == ARRAY_REF + || TREE_CODE (op) == ARRAY_RANGE_REF) + && (TREE_CODE (TREE_TYPE (TREE_OPERAND (op, 0))) + != ARRAY_TYPE)) + { + /* And ARRAY_REFs to objects that had mismatched types + during symbol merging to avoid ICEs. */ + TREE_OPERAND (op, 0) + = build1 (VIEW_CONVERT_EXPR, + build_array_type (TREE_TYPE (op), NULL_TREE), + TREE_OPERAND (op, 0)); + } op = TREE_OPERAND (op, 0); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 80a1af4cda7..ba114ee2b37 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2012-12-05 Richard Biener + + PR lto/55525 + * gcc.dg/lto/pr55525_0.c: New testcase. + * gcc.dg/lto/pr55525_1.c: Likewise. + 2012-12-04 Tobias Burnus * gfortran.dg/quad_3.f90: Really fix an if condition. diff --git a/gcc/testsuite/gcc.dg/lto/pr55525_0.c b/gcc/testsuite/gcc.dg/lto/pr55525_0.c new file mode 100644 index 00000000000..7f06918a41f --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr55525_0.c @@ -0,0 +1,8 @@ +/* { dg-lto-do link } */ +/* { dg-lto-options { { -flto -w } } } */ + +char s[8]; +int main(void) +{ + return strcmp(&s[1], "foo"); +} diff --git a/gcc/testsuite/gcc.dg/lto/pr55525_1.c b/gcc/testsuite/gcc.dg/lto/pr55525_1.c new file mode 100644 index 00000000000..3c3381780ba --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr55525_1.c @@ -0,0 +1 @@ +char *s = (char *) 0;