On 5/13/25 4:29 PM, Ville Voutilainen wrote:
On Tue, 13 May 2025 at 23:23, Jason Merrill <ja...@redhat.com> wrote:
/* Check that the return and argument types are sane before
folding. */
- if (INDIRECT_TYPE_P (TREE_TYPE (x))
- && INDIRECT_TYPE_P (TREE_TYPE (r)))
+ if (id_equal (DECL_NAME (callee), "to_underlying")
+ || (INDIRECT_TYPE_P (TREE_TYPE (x))
+ && INDIRECT_TYPE_P (TREE_TYPE (r))))
Maybe instead of INDIRECT_TYPE_P, check ! AGGREGATE_TYPE_P ? I'm not
sure how much sanity checking we need here, maybe we should just trust
the library.
I.. ..don't think AGGREGATE_TYPE_P is right?
I was suggesting *not* AGGREGATE_TYPE_P, because build_nop doesn't work
for such types.
It seems to me that this
sanity check is checking that it's a cast between
references for the other ones, and that's just unsuitable for
to_underlying. I would suggest just removing that sanity
check and trusting the library.
That's fine too.
+// { dg-final { scan-tree-dump-not "= std::move" "gimple" } }
+// { dg-final { scan-tree-dump-not "= std::forward" "gimple" } }
+// { dg-final { scan-tree-dump-not "= std::addressof" "gimple" } }
+// { dg-final { scan-tree-dump-not "= std::__addressof" "gimple" } }
+// { dg-final { scan-tree-dump-not "= std::as_const" "gimple" } }
+// { dg-final { scan-tree-dump-not "= std::forward_like" "gimple" } }
+// { dg-final { scan-tree-dump-not "= std::to_underlying" "gimple" } }
Why check for a lot of things that aren't used in the testcase?
No good reason, just "oh, I can leave those there for paranoia
reasons", happy to remove the fluff.