* gcc.dg/tree.ssa/pr22051-1.c: New test. * gcc.dg/tree.ssa/pr22051-2.c: New test. Index: gcc.dg/tree-ssa/pr22051-1.c =================================================================== RCS file: gcc.dg/tree-ssa/pr22051-1.c diff -N gcc.dg/tree-ssa/pr22051-1.c *** /dev/null 1 Jan 1970 00:00:00 -0000 --- gcc.dg/tree-ssa/pr22051-1.c 11 Jul 2005 20:09:30 -0000 *************** *** 0 **** --- 1,23 ---- + /* { dg-do compile } */ + /* { dg-options "-O2 -fdump-tree-optimized" } */ + + + void *arf (); + int + foo() + { + void *p = arf (); + + if ((void (*)(void))p != 0) + return 1; + else + return 2; + } + + /* The cast to a function pointer type must remain after all optimizations + are complete so that function pointer canonicalization works on those + targets which require it. */ + /* { dg-final { scan-tree-dump-times "if \\(\\(void \\(\\*<.*>\\) \\(void\\)\\) p" 1 "optimized" } } */ + /* { dg-final { cleanup-tree-dump "optimized" } } */ + + Index: gcc.dg/tree-ssa/pr22051-2.c =================================================================== RCS file: gcc.dg/tree-ssa/pr22051-2.c diff -N gcc.dg/tree-ssa/pr22051-2.c *** /dev/null 1 Jan 1970 00:00:00 -0000 --- gcc.dg/tree-ssa/pr22051-2.c 11 Jul 2005 20:09:30 -0000 *************** *** 0 **** --- 1,25 ---- + /* { dg-do compile } */ + /* { dg-options "-O2 -fdump-tree-optimized -w" } */ + + + + + void *arf (); + int + foo() + { + void (*q)(void); + int r = q; + + if (r != 0) + return 1; + else + return 2; + } + + /* The cast to an int type must remain after all optimizations are complete + so that we do not try to canonicalize a function pointer for the + comparison when no such canonicalization is wanted. */ + /* { dg-final { scan-tree-dump-times "if \\(\\(int\\) q" 1 "optimized" } } */ + /* { dg-final { cleanup-tree-dump "optimized" } } */ +