Skip to content

Commit 9bc6c80

Browse files
committed
Avoid warnings on typeid expression site-effects.
Use a local reference as a typeid argument instead of expression.
1 parent 2f0cbd9 commit 9bc6c80

4 files changed

Lines changed: 20 additions & 9 deletions

File tree

src/tests/TestNoMetaStructureAdapter.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ class TestNoMetaStructureAdapter : public CxxTest::TestSuite
104104
TS_ASSERT_EQUALS(56, pswtbare1->countSites());
105105
TS_ASSERT_EQUALS(string("Pb"), pswtbare1->siteAtomType(0));
106106
TS_ASSERT_EQUALS(string("Ti"), pswtbare1->siteAtomType(55));
107-
TS_ASSERT(typeid(NoMetaStructureAdapter) == typeid(*pswtbare1));
107+
StructureAdapter& r_pswtbare1 = *pswtbare1;
108+
TS_ASSERT(typeid(NoMetaStructureAdapter) == typeid(r_pswtbare1));
108109
}
109110

110111
}; // class TestNoMetaStructureAdapter

src/tests/TestObjCrystStructureAdapter.hpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ class TestObjCrystStructureAdapter : public CxxTest::TestSuite
111111

112112
void test_typeid()
113113
{
114-
TS_ASSERT(typeid(CrystalStructureAdapter) == typeid(*m_ni));
114+
StructureAdapter& r_ni = *m_ni;
115+
TS_ASSERT(typeid(CrystalStructureAdapter) == typeid(r_ni));
115116
}
116117

117118

@@ -275,8 +276,9 @@ class TestObjCrystStructureBondGenerator : public CxxTest::TestSuite
275276

276277
void test_typeid()
277278
{
279+
BaseBondGenerator& r_nibnds = *m_nibnds;
278280
TS_ASSERT(typeid(CrystalStructureBondGenerator) ==
279-
typeid(*m_nibnds));
281+
typeid(r_nibnds));
280282
}
281283

282284

@@ -424,7 +426,8 @@ class TestObjCrystMoleculeAdapter : public CxxTest::TestSuite
424426

425427
void test_typeid()
426428
{
427-
TS_ASSERT(typeid(AtomicStructureAdapter) == typeid(*m_c60));
429+
StructureAdapter& r_c60 = *m_c60;
430+
TS_ASSERT(typeid(AtomicStructureAdapter) == typeid(r_c60));
428431
}
429432

430433

@@ -539,7 +542,8 @@ class TestObjCrystMoleculeBondGenerator : public CxxTest::TestSuite
539542

540543
void test_typeid()
541544
{
542-
TS_ASSERT(typeid(BaseBondGenerator) == typeid(*m_c60bnds));
545+
BaseBondGenerator& r_c60bnds = *m_c60bnds;
546+
TS_ASSERT(typeid(BaseBondGenerator) == typeid(r_c60bnds));
543547
}
544548

545549

src/tests/TestPeriodicStructureAdapter.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ class TestPeriodicStructureAdapter : public CxxTest::TestSuite
106106

107107
void test_typeid()
108108
{
109-
TS_ASSERT(typeid(PeriodicStructureAdapter) == typeid(*m_ni));
109+
StructureAdapter& r_ni = *m_ni;
110+
TS_ASSERT(typeid(PeriodicStructureAdapter) == typeid(r_ni));
110111
}
111112

112113

@@ -280,8 +281,9 @@ class TestPeriodicStructureBondGenerator : public CxxTest::TestSuite
280281

281282
void test_typeid()
282283
{
284+
BaseBondGenerator& r_nibnds = *m_nibnds;
283285
TS_ASSERT(typeid(PeriodicStructureBondGenerator) ==
284-
typeid(*m_nibnds));
286+
typeid(r_nibnds));
285287
}
286288

287289

src/tests/TestScatteringFactorTable.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,17 @@ class TestScatteringFactorTable : public CxxTest::TestSuite
5757
TS_ASSERT(sfx0.get());
5858
TS_ASSERT(sfx1.get());
5959
TS_ASSERT_EQUALS(sfx0->type(), sfx1->type());
60-
TS_ASSERT(typeid(*sfx0) == typeid(*sfx1));
60+
ScatteringFactorTable& r_sfx0 = *sfx0;
61+
ScatteringFactorTable& r_sfx1 = *sfx1;
62+
TS_ASSERT(typeid(r_sfx0) == typeid(r_sfx1));
6163
sfn0 = ScatteringFactorTable::createByType("neutron");
6264
sfn1 = ScatteringFactorTable::createByType("N");
6365
TS_ASSERT(sfn0.get());
6466
TS_ASSERT(sfn1.get());
6567
TS_ASSERT_EQUALS(sfn0->type(), sfn1->type());
66-
TS_ASSERT(typeid(*sfn0) == typeid(*sfn1));
68+
ScatteringFactorTable& r_sfn0 = *sfn0;
69+
ScatteringFactorTable& r_sfn1 = *sfn1;
70+
TS_ASSERT(typeid(r_sfn0) == typeid(r_sfn1));
6771
}
6872

6973

0 commit comments

Comments
 (0)