r600/sfn: Fix test compilation with -fno-rtti
authorMichał Górny <mgorny@gentoo.org>
Thu, 8 Dec 2022 19:07:51 +0000 (20:07 +0100)
committerMarge Bot <emma+marge@anholt.net>
Sat, 17 Dec 2022 11:01:50 +0000 (11:01 +0000)
79ca456b4837b3bc21cf9ef3c03c505c4b4909f6 reintroduced the use
of dynamic_cast<> in r600/sfn tests.  This breaks compilation with
-fno-rtti, as required to build against the LLVM configuration
recommended upstream.  Use static_cast<> instead to fix this.

Fixes: #7820
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20239>

src/gallium/drivers/r600/sfn/tests/sfn_valuefactory_test.cpp

index 12056b3..6127e8b 100644 (file)
@@ -224,11 +224,14 @@ TEST_F(ValuefactoryTest, test_create_const)
    PVirtualValue value1 = factory->src(alu->src[0], 0);
    PVirtualValue value2 = factory->src(alu->src[1], 0);
 
-   const auto& cvalue1 = dynamic_cast<const LiteralConstant&>(*value1);
-   const auto& cvalue2 = dynamic_cast<const LiteralConstant&>(*value2);
+   const auto* cvalue1 = value1->as_literal();
+   const auto* cvalue2 = value2->as_literal();
 
-   EXPECT_EQ(cvalue1.value(), 2);
-   EXPECT_EQ(cvalue2.value(), 4);
+   ASSERT_TRUE(cvalue1);
+   ASSERT_TRUE(cvalue2);
+
+   EXPECT_EQ(cvalue1->value(), 2);
+   EXPECT_EQ(cvalue2->value(), 4);
 }
 
 TEST_F(ValuefactoryTest, test_create_sysvalue)