aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Hubicka <hubicka@ucw.cz>2015-06-08 22:24:57 +0000
committerJan Hubicka <hubicka@ucw.cz>2015-06-08 22:24:57 +0000
commitc3fc8960d81e28ba40bf8e505df9dec83138c37e (patch)
tree35be7a92fc2dbe146f3c69e913968b9856f0f396
parentde9f35f122ab2648b19f3c86d33094be2742e13a (diff)
* lto.c (hash_canonical_type): Drop hashing of TYPE_STRING_FLAG.
* tree.c (gimple_canonical_types_compatible_p): Drop comparsion of TYPE_STRING_FLAG. * gfortran.dg/lto/bind_c-2b_0.f90: New testcase * gfortran.dg/lto/bind_c-2b_1.c: New testcase git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@224252 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/lto/ChangeLog4
-rw-r--r--gcc/lto/lto.c12
-rw-r--r--gcc/testsuite/gfortran.dg/lto/bind_c-2b_0.f9021
-rw-r--r--gcc/testsuite/gfortran.dg/lto/bind_c-2b_1.c36
-rw-r--r--gcc/tree.c6
6 files changed, 74 insertions, 10 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f8e8e6de4ce..18c4538d09e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,10 @@
2015-06-08 Jan Hubicka <hubicka@ucw.cz>
+ * tree.c (gimple_canonical_types_compatible_p): Drop comparsion of
+ TYPE_STRING_FLAG.
+
+2015-06-08 Jan Hubicka <hubicka@ucw.cz>
+
* lto-streamer-out.c (lto_output_location): Stream
reserved locations correctly.
* lto-streamer-in.c (lto_output_location): Likewise.
diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog
index 86771fe53a0..5d0e8881a17 100644
--- a/gcc/lto/ChangeLog
+++ b/gcc/lto/ChangeLog
@@ -1,3 +1,7 @@
+2015-06-08 Jan Hubicka <hubicka@ucw.cz>
+
+ * lto.c (hash_canonical_type): Drop hashing of TYPE_STRING_FLAG.
+
2015-06-08 Andrew MacLeod <amacleod@redhat.com>
* lto-lang.c : Adjust include files.
diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c
index b8e73cd489f..b9b11106ac3 100644
--- a/gcc/lto/lto.c
+++ b/gcc/lto/lto.c
@@ -332,17 +332,15 @@ hash_canonical_type (tree type)
if (TREE_CODE (type) == COMPLEX_TYPE)
hstate.add_int (TYPE_UNSIGNED (type));
+ /* Fortran's C_SIGNED_CHAR is !TYPE_STRING_FLAG but needs to be
+ interoperable with "signed char". Unless all frontends are revisited to
+ agree on these types, we must ignore the flag completely. */
+
/* Fortran standard define C_PTR type that is compatible with every
C pointer. For this reason we need to glob all pointers into one.
Still pointers in different address spaces are not compatible. */
if (POINTER_TYPE_P (type))
- {
- hstate.add_int (TYPE_ADDR_SPACE (TREE_TYPE (type)));
- }
-
- /* For integer types hash only the string flag. */
- if (TREE_CODE (type) == INTEGER_TYPE)
- hstate.add_int (TYPE_STRING_FLAG (type));
+ hstate.add_int (TYPE_ADDR_SPACE (TREE_TYPE (type)));
/* For array types hash the domain bounds and the string flag. */
if (TREE_CODE (type) == ARRAY_TYPE && TYPE_DOMAIN (type))
diff --git a/gcc/testsuite/gfortran.dg/lto/bind_c-2b_0.f90 b/gcc/testsuite/gfortran.dg/lto/bind_c-2b_0.f90
new file mode 100644
index 00000000000..705282d8dde
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/lto/bind_c-2b_0.f90
@@ -0,0 +1,21 @@
+! { dg-lto-do run }
+! { dg-lto-options {{ -O3 -flto }} }
+! This testcase will abort if C_SIGNED_CHAR is not interoperable with signed
+! char
+module lto_type_merge_test
+ use, intrinsic :: iso_c_binding
+ implicit none
+
+ type, bind(c) :: MYFTYPE_1
+ integer(c_signed_char) :: chr
+ integer(c_signed_char) :: chrb
+ end type MYFTYPE_1
+
+ type(myftype_1), bind(c, name="myVar") :: myVar
+
+contains
+ subroutine types_test() bind(c)
+ myVar%chr = myVar%chrb
+ end subroutine types_test
+end module lto_type_merge_test
+
diff --git a/gcc/testsuite/gfortran.dg/lto/bind_c-2b_1.c b/gcc/testsuite/gfortran.dg/lto/bind_c-2b_1.c
new file mode 100644
index 00000000000..d00508123b9
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/lto/bind_c-2b_1.c
@@ -0,0 +1,36 @@
+#include <stdlib.h>
+/* interopse with myftype_1 */
+typedef struct {
+ signed char chr;
+ signed char chr2;
+} myctype_t;
+
+
+extern void abort(void);
+void types_test(void);
+/* declared in the fortran module */
+extern myctype_t myVar;
+
+int main(int argc, char **argv)
+{
+ myctype_t *cchr;
+ asm("":"=r"(cchr):"0"(&myVar));
+ cchr->chr = 1;
+ cchr->chr2 = 2;
+
+ types_test();
+
+ if(cchr->chr != 2)
+ abort();
+ if(cchr->chr2 != 2)
+ abort();
+ myVar.chr2 = 3;
+ types_test();
+
+ if(myVar.chr != 3)
+ abort();
+ if(myVar.chr2 != 3)
+ abort();
+ return 0;
+}
+
diff --git a/gcc/tree.c b/gcc/tree.c
index db4ea8e1b10..be01d0e19c9 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -12948,9 +12948,9 @@ gimple_canonical_types_compatible_p (const_tree t1, const_tree t2,
|| TYPE_UNSIGNED (t1) != TYPE_UNSIGNED (t2))
return false;
- if (TREE_CODE (t1) == INTEGER_TYPE
- && TYPE_STRING_FLAG (t1) != TYPE_STRING_FLAG (t2))
- return false;
+ /* Fortran's C_SIGNED_CHAR is !TYPE_STRING_FLAG but needs to be
+ interoperable with "signed char". Unless all frontends are revisited
+ to agree on these types, we must ignore the flag completely. */
/* Fortran standard define C_PTR type that is compatible with every
C pointer. For this reason we need to glob all pointers into one.