This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[4.1 PATCH] Fix tree-ssa-structalias.c on valid, though very lame code (PR tree-optimization/26865)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Daniel Berlin <dberlin at dberlin dot org>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 19 Apr 2006 12:23:07 -0400
- Subject: [4.1 PATCH] Fix tree-ssa-structalias.c on valid, though very lame code (PR tree-optimization/26865)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
This code has been rewritten on the trunk, so doesn't trigger there.
What happens is that when alloca is implicitly declared, calls.c still
marks it as ECF_MAY_BE_ALLOCA, but tree-ssa-structalias.c assumes that
alloca and ECF_MALLOC calls have always a pointer return type.
The following patch just checks that before dereferencing.
Ok for 4.1 (and the testcase for trunk as well)?
2006-04-19 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/26865
* tree-ssa-structalias.c (find_func_aliases): Check that anyoffsetrhs
type is pointer or array type.
* gcc.dg/pr26865.c: New test.
--- gcc/tree-ssa-structalias.c.jj 2006-03-27 14:33:14.000000000 +0200
+++ gcc/tree-ssa-structalias.c 2006-04-19 18:09:10.000000000 +0200
@@ -2950,6 +2950,9 @@ find_func_aliases (tree t, struct alias_
of the RHS. */
if (need_anyoffset || (rhs.type == ADDRESSOF
&& !(get_varinfo (rhs.var)->is_special_var)
+ && (POINTER_TYPE_P (TREE_TYPE (anyoffsetrhs))
+ || TREE_CODE (TREE_TYPE (anyoffsetrhs))
+ == ARRAY_TYPE)
&& AGGREGATE_TYPE_P (TREE_TYPE (TREE_TYPE (anyoffsetrhs)))))
{
rhs.var = anyoffset_id;
--- gcc/testsuite/gcc.dg/pr26865.c.jj 2006-04-19 18:11:07.000000000 +0200
+++ gcc/testsuite/gcc.dg/pr26865.c 2006-04-19 18:12:47.000000000 +0200
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -std=c99" } */
+
+void
+foo (void)
+{
+ char *e = alloca (100); /* { dg-warning "implicit declaration|initialization makes" } */
+}
Jakub