aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.h
diff options
context:
space:
mode:
authorJan Hubicka <hubicka@ucw.cz>2015-06-04 18:38:50 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2015-06-04 16:38:50 +0000
commit9cb9b9379e8683825f064c91cd283fd0fb97a738 (patch)
treec8294be6e931cc9efefd835049d806e5c39a7f5a /gcc/tree.h
parent19cd26a6b937349161ef2f7ae6bf41cee61bc81b (diff)
downloadgcc-9cb9b9379e8683825f064c91cd283fd0fb97a738.zip
gcc-9cb9b9379e8683825f064c91cd283fd0fb97a738.tar.gz
gcc-9cb9b9379e8683825f064c91cd283fd0fb97a738.tar.bz2
lto.c (hash_canonical_type): Use tree_code_for_canonical_type_merging.
* lto.c (hash_canonical_type): Use tree_code_for_canonical_type_merging. * tree.h (tree_code_for_canonical_type_merging): New function. * tree.c (gimple_canonical_types_compatible_p): Use tree_code_for_canonical_type_merging.. * gcc.dg/lto/c-compatible-types_0.c: New testcase. * gcc.dg/lto/c-compatible-types_1.c: New testcase. From-SVN: r224135
Diffstat (limited to 'gcc/tree.h')
-rw-r--r--gcc/tree.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/gcc/tree.h b/gcc/tree.h
index 732a61c..ca5e681 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -4598,6 +4598,27 @@ extern int tree_map_base_marked_p (const void *);
extern void DEBUG_FUNCTION verify_type (const_tree t);
extern bool gimple_canonical_types_compatible_p (const_tree, const_tree,
bool trust_type_canonical = true);
+/* Return simplified tree code of type that is used for canonical type merging. */
+inline enum tree_code
+tree_code_for_canonical_type_merging (enum tree_code code)
+{
+ /* By C standard, each enumerated type shall be compatible with char,
+ a signed integer, or an unsigned integer. The choice of type is
+ implementation defined (in our case it depends on -fshort-enum).
+
+ For this reason we make no distinction between ENUMERAL_TYPE and INTEGER
+ type and compare only by their signedness and precision. */
+ if (code == ENUMERAL_TYPE)
+ return INTEGER_TYPE;
+ /* To allow inter-operability between languages having references and
+ C, we consider reference types and pointers alike. Note that this is
+ not strictly necessary for C-Fortran 2008 interoperability because
+ Fortran define C_PTR type that needs to be compatible with C pointers
+ and we handle this one as ptr_type_node. */
+ if (code == REFERENCE_TYPE)
+ return POINTER_TYPE;
+ return code;
+}
#define tree_map_eq tree_map_base_eq
extern unsigned int tree_map_hash (const void *);