Fix PR37418
Richard Guenther
rguenther@suse.de
Thu Oct 16 10:19:00 GMT 2008
This fixes PR37418, the fix was discussed at length about a month ago,
I just picked up the testcases from Josephs patch and used my tweak
to the type system.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.
Richard.
2008-10-16 Richard Guenther <rguenther@suse.de>
PR middle-end/37418
* tree-ssa.c (useless_type_conversion_p_1): Do not treat
volatile qualified functions or methods as relevant.
testsuite:
2008-10-16 Joseph Myers <joseph@codesourcery.com>
PR middle-end/37418
* gcc.c-torture/compile/pr37418-1.c,
gcc.c-torture/compile/pr37418-2.c,
gcc.c-torture/compile/pr37418-3.c,
gcc.c-torture/compile/pr37418-4.c: New tests.
Index: gcc/testsuite/gcc.c-torture/compile/pr37418-1.c
===================================================================
--- gcc/testsuite/gcc.c-torture/compile/pr37418-1.c (revision 0)
+++ gcc/testsuite/gcc.c-torture/compile/pr37418-1.c (revision 0)
@@ -0,0 +1,6 @@
+typedef void ft(int);
+void f(int args)__attribute__((noreturn));
+void f2(ft *p __attribute__((noreturn)))
+{
+ p = f;
+}
Index: gcc/testsuite/gcc.c-torture/compile/pr37418-2.c
===================================================================
--- gcc/testsuite/gcc.c-torture/compile/pr37418-2.c (revision 0)
+++ gcc/testsuite/gcc.c-torture/compile/pr37418-2.c (revision 0)
@@ -0,0 +1,6 @@
+typedef void ft(int);
+volatile ft f;
+void f2(ft *p __attribute__((noreturn)))
+{
+ p = f;
+}
Index: gcc/testsuite/gcc.c-torture/compile/pr37418-3.c
===================================================================
--- gcc/testsuite/gcc.c-torture/compile/pr37418-3.c (revision 0)
+++ gcc/testsuite/gcc.c-torture/compile/pr37418-3.c (revision 0)
@@ -0,0 +1,6 @@
+typedef void ft(int);
+void f(int args)__attribute__((const));
+void f2(ft *p __attribute__((const)))
+{
+ p = f;
+}
Index: gcc/testsuite/gcc.c-torture/compile/pr37418-4.c
===================================================================
--- gcc/testsuite/gcc.c-torture/compile/pr37418-4.c (revision 0)
+++ gcc/testsuite/gcc.c-torture/compile/pr37418-4.c (revision 0)
@@ -0,0 +1,6 @@
+typedef void ft(int);
+const ft f;
+void f2(ft *p __attribute__((const)))
+{
+ p = f;
+}
Index: gcc/tree-ssa.c
===================================================================
*** gcc/tree-ssa.c (revision 141150)
--- gcc/tree-ssa.c (working copy)
*************** useless_type_conversion_p_1 (tree outer_
*** 1125,1133 ****
{
/* Don't lose casts between pointers to volatile and non-volatile
qualified types. Doing so would result in changing the semantics
! of later accesses. */
! if ((TYPE_VOLATILE (TREE_TYPE (outer_type))
! != TYPE_VOLATILE (TREE_TYPE (inner_type)))
&& TYPE_VOLATILE (TREE_TYPE (outer_type)))
return false;
--- 1125,1138 ----
{
/* Don't lose casts between pointers to volatile and non-volatile
qualified types. Doing so would result in changing the semantics
! of later accesses. For function types the volatile qualifier
! is used to indicate noreturn functions. */
! if (TREE_CODE (TREE_TYPE (outer_type)) != FUNCTION_TYPE
! && TREE_CODE (TREE_TYPE (outer_type)) != METHOD_TYPE
! && TREE_CODE (TREE_TYPE (inner_type)) != FUNCTION_TYPE
! && TREE_CODE (TREE_TYPE (inner_type)) != METHOD_TYPE
! && (TYPE_VOLATILE (TREE_TYPE (outer_type))
! != TYPE_VOLATILE (TREE_TYPE (inner_type)))
&& TYPE_VOLATILE (TREE_TYPE (outer_type)))
return false;
More information about the Gcc-patches
mailing list