This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
On 9/22/19 3:23 PM, Marek Polacek wrote:
+ /* Informally, two types are similar if, ignoring top-level cv-qualification: + * they are the same type; or + * they are both pointers, and the pointed-to types are similar; or + * they are both pointers to member of the same class, and the types of + the pointed-to members are similar; or + * they are both arrays of the same size or both arrays of unknown bound, + and the array element types are similar. */
Yes.
+ if ((TREE_CODE (type1) == POINTER_TYPE && TREE_CODE (type2) == POINTER_TYPE) + || (TYPE_PTRDATAMEM_P (type1) && TYPE_PTRDATAMEM_P (type2)) + || (TREE_CODE (type1) == ARRAY_TYPE && TREE_CODE (type2) == ARRAY_TYPE)) + { + int result = comp_cv_qual_signature (TREE_TYPE (type1), + TREE_TYPE (type2));
Using comp_cv_qual_signature means that we only return true if one cv-qualification signature is a subset of the other, but the definition of 'similar' is such that we should completely ignore cv-quals. int const ** and int *const* are similar even though neither can convert to the other.
Jason
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |