From: Nathan Sidwell Date: Wed, 22 Jul 2020 15:27:30 +0000 (-0700) Subject: c++: structural_comptypes addition X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5324a3e621d9a2eec6addcc439c4adb1befa8ea9;p=gcc.git c++: structural_comptypes addition I had to debug structural_comptypes, and its complex if conditions and tail calling of same_type_p made that hard. I'd hope we can turn the eqivalent of return boolean_fn () ? true : false; into a tail call of the boolean. We also were not dealing with TYPEOF_TYPE. gcc/cp/ * typeck.c (structural_comptypes): [DECLTYPE_TYPE] break apart complex if. [UNDERLYING_TYPE]: Use an if. [TYPEOF_TYPE]: New. --- diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 589e014f855..adc088ce1d7 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -1452,19 +1452,25 @@ structural_comptypes (tree t1, tree t2, int strict) case DECLTYPE_TYPE: if (DECLTYPE_TYPE_ID_EXPR_OR_MEMBER_ACCESS_P (t1) - != DECLTYPE_TYPE_ID_EXPR_OR_MEMBER_ACCESS_P (t2) - || (DECLTYPE_FOR_LAMBDA_CAPTURE (t1) - != DECLTYPE_FOR_LAMBDA_CAPTURE (t2)) - || (DECLTYPE_FOR_LAMBDA_PROXY (t1) - != DECLTYPE_FOR_LAMBDA_PROXY (t2)) - || !cp_tree_equal (DECLTYPE_TYPE_EXPR (t1), - DECLTYPE_TYPE_EXPR (t2))) + != DECLTYPE_TYPE_ID_EXPR_OR_MEMBER_ACCESS_P (t2)) + return false; + if (DECLTYPE_FOR_LAMBDA_CAPTURE (t1) != DECLTYPE_FOR_LAMBDA_CAPTURE (t2)) + return false; + if (DECLTYPE_FOR_LAMBDA_PROXY (t1) != DECLTYPE_FOR_LAMBDA_PROXY (t2)) + return false; + if (!cp_tree_equal (DECLTYPE_TYPE_EXPR (t1), DECLTYPE_TYPE_EXPR (t2))) return false; break; case UNDERLYING_TYPE: - return same_type_p (UNDERLYING_TYPE_TYPE (t1), - UNDERLYING_TYPE_TYPE (t2)); + if (!same_type_p (UNDERLYING_TYPE_TYPE (t1), UNDERLYING_TYPE_TYPE (t2))) + return false; + break; + + case TYPEOF_TYPE: + if (!cp_tree_equal (TYPEOF_TYPE_EXPR (t1), TYPEOF_TYPE_EXPR (t2))) + return false; + break; default: return false;