diff options
author | Jason Merrill <jason@redhat.com> | 2016-11-03 15:52:58 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2016-11-03 15:52:58 -0400 |
commit | 1906d6b4dc4cf6bddb82e9dc3534438230030a8e (patch) | |
tree | bba16b05930156885aa3e5b7fb63e4b7cfd29e1f | |
parent | b302001e3a04e8d2911989816c8907bf3e5c2389 (diff) | |
download | gcc-1906d6b4dc4cf6bddb82e9dc3534438230030a8e.zip gcc-1906d6b4dc4cf6bddb82e9dc3534438230030a8e.tar.gz gcc-1906d6b4dc4cf6bddb82e9dc3534438230030a8e.tar.bz2 |
Use type_hash_eq langhook in check_qualified_type.
gcc/
* tree.c (check_lang_type): New.
(check_qualified_type): Use it.
(check_aligned_type): Use it.
* tree.h: Declare it.
gcc/cp/
* tree.c (cp_check_qualified_type): Call check_base_type instead
of check_qualified_type.
(cxx_type_hash_eq): Check ref-qualifiers.
* typeck.c (apply_memfn_quals): No need to mess with TYPE_CANONICAL.
From-SVN: r241831
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/tree.c | 9 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 7 | ||||
-rw-r--r-- | gcc/langhooks.h | 2 | ||||
-rw-r--r-- | gcc/tree.c | 21 | ||||
-rw-r--r-- | gcc/tree.h | 5 |
7 files changed, 44 insertions, 14 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3888d21..dbbdba7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2016-11-03 Jason Merrill <jason@redhat.com> + + * tree.c (check_lang_type): New. + (check_qualified_type): Use it. + (check_aligned_type): Use it. + * tree.h: Declare it. + 2016-11-03 Richard Earnshaw <rearnsha@arm.com> * config.gcc (arm-wrs-vxworks): Set target_cpu_cname. diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5eabdc2..c60c81d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2016-11-03 Jason Merrill <jason@redhat.com> + + * tree.c (cp_check_qualified_type): Call check_base_type instead + of check_qualified_type. + (cxx_type_hash_eq): Check ref-qualifiers. + * typeck.c (apply_memfn_quals): No need to mess with TYPE_CANONICAL. + 2016-11-01 Jason Merrill <jason@redhat.com> Implement P0136R1, Rewording inheriting constructors. diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index ac15d67..4dc6e22 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1980,7 +1980,8 @@ static bool cp_check_qualified_type (const_tree cand, const_tree base, int type_quals, cp_ref_qualifier rqual, tree raises) { - return (check_qualified_type (cand, base, type_quals) + return (TYPE_QUALS (cand) == type_quals + && check_base_type (cand, base) && comp_except_specs (raises, TYPE_RAISES_EXCEPTIONS (cand), ce_exact) && type_memfn_rqual (cand) == rqual); @@ -4080,9 +4081,7 @@ cp_build_type_attribute_variant (tree type, tree attributes) } /* Return TRUE if TYPE1 and TYPE2 are identical for type hashing purposes. - Called only after doing all language independent checks. Only - to check TYPE_RAISES_EXCEPTIONS for FUNCTION_TYPE, the rest is already - compared in type_hash_eq. */ + Called only after doing all language independent checks. */ bool cxx_type_hash_eq (const_tree typea, const_tree typeb) @@ -4090,6 +4089,8 @@ cxx_type_hash_eq (const_tree typea, const_tree typeb) gcc_assert (TREE_CODE (typea) == FUNCTION_TYPE || TREE_CODE (typea) == METHOD_TYPE); + if (type_memfn_rqual (typea) != type_memfn_rqual (typeb)) + return false; return comp_except_specs (TYPE_RAISES_EXCEPTIONS (typea), TYPE_RAISES_EXCEPTIONS (typeb), ce_exact); } diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 569442f..45b7d26 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -9227,13 +9227,6 @@ apply_memfn_quals (tree type, cp_cv_quals memfn_quals, cp_ref_qualifier rqual) /* This should really have a different TYPE_MAIN_VARIANT, but that gets complex. */ tree result = build_qualified_type (type, memfn_quals); - if (tree canon = TYPE_CANONICAL (result)) - if (canon != result) - /* check_qualified_type doesn't check the ref-qualifier, so make sure - TYPE_CANONICAL is correct. */ - TYPE_CANONICAL (result) - = build_ref_qualified_type (canon, type_memfn_rqual (result)); - result = build_exception_variant (result, TYPE_RAISES_EXCEPTIONS (type)); return build_ref_qualified_type (result, rqual); } diff --git a/gcc/langhooks.h b/gcc/langhooks.h index 8116b17..6cd01a7 100644 --- a/gcc/langhooks.h +++ b/gcc/langhooks.h @@ -120,7 +120,7 @@ struct lang_hooks_for_types /* Return TRUE if TYPE1 and TYPE2 are identical for type hashing purposes. Called only after doing all language independent checks. At present, this function is only called when both TYPE1 and TYPE2 are - FUNCTION_TYPEs. */ + FUNCTION_TYPE or METHOD_TYPE. */ bool (*type_hash_eq) (const_tree, const_tree); /* Return TRUE if TYPE uses a hidden descriptor and fills in information @@ -6497,6 +6497,21 @@ set_type_quals (tree type, int type_quals) TYPE_ADDR_SPACE (type) = DECODE_QUAL_ADDR_SPACE (type_quals); } +/* Returns true iff CAND and BASE have equivalent language-specific + qualifiers. */ + +bool +check_lang_type (const_tree cand, const_tree base) +{ + if (lang_hooks.types.type_hash_eq == NULL) + return true; + /* type_hash_eq currently only applies to these types. */ + if (TREE_CODE (cand) != FUNCTION_TYPE + && TREE_CODE (cand) != METHOD_TYPE) + return true; + return lang_hooks.types.type_hash_eq (cand, base); +} + /* Returns true iff unqualified CAND and BASE are equivalent. */ bool @@ -6517,7 +6532,8 @@ bool check_qualified_type (const_tree cand, const_tree base, int type_quals) { return (TYPE_QUALS (cand) == type_quals - && check_base_type (cand, base)); + && check_base_type (cand, base) + && check_lang_type (cand, base)); } /* Returns true iff CAND is equivalent to BASE with ALIGN. */ @@ -6532,7 +6548,8 @@ check_aligned_type (const_tree cand, const_tree base, unsigned int align) /* Check alignment. */ && TYPE_ALIGN (cand) == align && attribute_list_equal (TYPE_ATTRIBUTES (cand), - TYPE_ATTRIBUTES (base))); + TYPE_ATTRIBUTES (base)) + && check_lang_type (cand, base)); } /* This function checks to see if TYPE matches the size one of the built-in @@ -4214,6 +4214,11 @@ extern tree merge_dllimport_decl_attributes (tree, tree); /* Handle a "dllimport" or "dllexport" attribute. */ extern tree handle_dll_attribute (tree *, tree, tree, int, bool *); +/* Returns true iff CAND and BASE have equivalent language-specific + qualifiers. */ + +extern bool check_lang_type (const_tree cand, const_tree base); + /* Returns true iff unqualified CAND and BASE are equivalent. */ extern bool check_base_type (const_tree cand, const_tree base); |