c++: structural_comptypes addition
authorNathan Sidwell <nathan@acm.org>
Wed, 22 Jul 2020 15:27:30 +0000 (08:27 -0700)
committerNathan Sidwell <nathan@acm.org>
Wed, 22 Jul 2020 15:43:25 +0000 (08:43 -0700)
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.

gcc/cp/typeck.c

index 589e014f8552df6946a9335a77f399b1e9ed3efd..adc088ce1d7b3ef5116eb2f8fa45cdde6627d627 100644 (file)
@@ -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;