aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2010-03-11 13:13:53 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2010-03-11 13:13:53 +0000
commit108ba00bcf8c2e98a1c097687b52f66f7e772306 (patch)
treec5ead7d502e43b0e780c079d238f6ac58b1a9889 /gcc
parent1aeffaf59881e8a4a08838607b28a0edcd76c1c4 (diff)
downloadgcc-108ba00bcf8c2e98a1c097687b52f66f7e772306.zip
gcc-108ba00bcf8c2e98a1c097687b52f66f7e772306.tar.gz
gcc-108ba00bcf8c2e98a1c097687b52f66f7e772306.tar.bz2
re PR lto/43200 ([LTO] tree check: expected array_type, have pointer_type in array_ref_low_bound)
2010-03-11 Richard Guenther <rguenther@suse.de> PR lto/43200 * lto-streamer-in.c (maybe_fixup_decls): Simplify. (input_gimple_stmt): Fixup handled component types during operand read. Also fix up decls in ADDR_EXPRs. * gcc.dg/lto/20100227-1_0.c: New testcase. * gcc.dg/lto/20100227-1_1.c: Likewise. From-SVN: r157385
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/lto-streamer-in.c42
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.dg/lto/20100227-1_0.c14
-rw-r--r--gcc/testsuite/gcc.dg/lto/20100227-1_1.c8
5 files changed, 68 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 01d4193..f10f808 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2010-03-11 Richard Guenther <rguenther@suse.de>
+
+ PR lto/43200
+ * lto-streamer-in.c (maybe_fixup_decls): Simplify.
+ (input_gimple_stmt): Fixup handled component types during
+ operand read. Also fix up decls in ADDR_EXPRs.
+
2010-03-10 Eric Botcazou <ebotcazou@adacore.com>
* config/sparc/sol2-bi.h (CC1_SPEC): Default to -mcpu=v9 for -m32.
diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c
index b098be2..6c50019 100644
--- a/gcc/lto-streamer-in.c
+++ b/gcc/lto-streamer-in.c
@@ -946,7 +946,8 @@ maybe_fixup_handled_component (tree op)
}
/* Fixup reference tree operands for substituted prevailing decls
- with mismatched types in STMT. */
+ with mismatched types in STMT. This handles plain DECLs where
+ we need the stmt for context to lookup the required type. */
static void
maybe_fixup_decls (gimple stmt)
@@ -967,8 +968,6 @@ maybe_fixup_decls (gimple stmt)
gimple_assign_set_rhs1 (stmt, build1 (VIEW_CONVERT_EXPR,
TREE_TYPE (lhs), rhs));
}
- else if (handled_component_p (rhs))
- maybe_fixup_handled_component (rhs);
/* Then catch scalar stores. */
else if (TREE_CODE (lhs) == VAR_DECL)
{
@@ -976,8 +975,6 @@ maybe_fixup_decls (gimple stmt)
gimple_assign_set_lhs (stmt, build1 (VIEW_CONVERT_EXPR,
TREE_TYPE (rhs), lhs));
}
- else if (handled_component_p (lhs))
- maybe_fixup_handled_component (lhs);
}
else if (is_gimple_call (stmt))
{
@@ -991,8 +988,6 @@ maybe_fixup_decls (gimple stmt)
gimple_call_return_type (stmt),
lhs));
}
- else if (lhs && handled_component_p (lhs))
- maybe_fixup_handled_component (lhs);
/* Arguments, especially for varargs functions will be funny... */
}
@@ -1069,9 +1064,29 @@ input_gimple_stmt (struct lto_input_block *ib, struct data_in *data_in,
{
tree op = lto_input_tree (ib, data_in);
gimple_set_op (stmt, i, op);
+ if (!op)
+ continue;
+
+ /* Fixup reference tree operands for substituted prevailing decls
+ with mismatched types. For plain VAR_DECLs we need to look
+ at context to determine the wanted type - we do that below
+ after the stmt is completed. */
+ if (TREE_CODE (op) == ADDR_EXPR
+ && TREE_CODE (TREE_OPERAND (op, 0)) == VAR_DECL
+ && !useless_type_conversion_p (TREE_TYPE (TREE_TYPE (op)),
+ TREE_TYPE (op)))
+ {
+ TREE_OPERAND (op, 0)
+ = build1 (VIEW_CONVERT_EXPR, TREE_TYPE (TREE_TYPE (op)),
+ TREE_OPERAND (op, 0));
+ continue;
+ }
- /* Fixup FIELD_DECLs. */
- while (op && handled_component_p (op))
+ /* 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)
{
@@ -1096,8 +1111,17 @@ input_gimple_stmt (struct lto_input_block *ib, struct data_in *data_in,
TREE_OPERAND (op, 1) = tem;
}
+ /* Preserve the last handled component for the fixup of
+ its operand below. */
+ if (!handled_component_p (TREE_OPERAND (op, 0)))
+ break;
op = TREE_OPERAND (op, 0);
}
+
+ /* Fixup reference tree operands for substituted prevailing decls
+ with mismatched types. */
+ if (handled_component_p (op))
+ maybe_fixup_handled_component (op);
}
break;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5638af3..bf7d44b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2010-03-11 Richard Guenther <rguenther@suse.de>
+
+ PR lto/43200
+ * gcc.dg/lto/20100227-1_0.c: New testcase.
+ * gcc.dg/lto/20100227-1_1.c: Likewise.
+
2010-03-10 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libfortran/43320
diff --git a/gcc/testsuite/gcc.dg/lto/20100227-1_0.c b/gcc/testsuite/gcc.dg/lto/20100227-1_0.c
new file mode 100644
index 0000000..4145c70
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20100227-1_0.c
@@ -0,0 +1,14 @@
+/* { dg-lto-do link } */
+/* { dg-extra-ld-options "-w" } */
+
+/* Make sure we do not ICE on the invalid re-declaration of s. */
+
+extern void f(void);
+const char *s = "Hello, world!";
+
+int main(void)
+{
+ f();
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/lto/20100227-1_1.c b/gcc/testsuite/gcc.dg/lto/20100227-1_1.c
new file mode 100644
index 0000000..a10ba02
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20100227-1_1.c
@@ -0,0 +1,8 @@
+extern int puts(const char *);
+extern const char s[];
+
+void f(void)
+{
+ puts(s);
+}
+