Skip to content

Commit e65443d

Browse files
committed
fix issue with cppcheck and macro
1 parent 64c9f9d commit e65443d

File tree

4 files changed

+47
-26
lines changed

4 files changed

+47
-26
lines changed

src/common/macros.hpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,38 @@
2727
_Pragma("clang diagnostic ignored \"-Wmissing-braces\"") \
2828
__VA_ARGS__ \
2929
_Pragma("clang diagnostic pop")
30+
31+
#define HPCREACT_NO_MISSING_BRACES_OPEN \
32+
_Pragma("clang diagnostic push") \
33+
_Pragma("clang diagnostic ignored \"-Wmissing-braces\"")
34+
#define HPCREACT_NO_MISSING_BRACES_CLOSE \
35+
_Pragma("clang diagnostic pop")
36+
3037
#elif defined(__GNUC__)
3138
#define HPCREACT_NO_MISSING_BRACES( ... ) \
3239
_Pragma("GCC diagnostic push") \
3340
_Pragma("GCC diagnostic ignored \"-Wmissing-braces\"") \
3441
__VA_ARGS__ \
3542
_Pragma("GCC diagnostic pop")
43+
44+
#define HPCREACT_NO_MISSING_BRACES_OPEN \
45+
_Pragma("GCC diagnostic push") \
46+
_Pragma("GCC diagnostic ignored \"-Wmissing-braces\"")
47+
#define HPCREACT_NO_MISSING_BRACES_CLOSE \
48+
_Pragma("GCC diagnostic pop")
49+
3650
#elif defined(_MSC_VER)
3751
#define HPCREACT_NO_MISSING_BRACES( ... ) \
3852
__pragma(warning(push)) \
3953
__pragma(warning(disable : 4351)) \
4054
__VA_ARGS__ \
4155
__pragma(warning(pop))
56+
57+
#define HPCREACT_NO_MISSING_BRACES_OPEN \
58+
__pragma(warning(push)) \
59+
__pragma(warning(disable : 4351))
60+
#define HPCREACT_NO_MISSING_BRACES_CLOSE \
61+
__pragma(warning(pop))
4262
#else
4363
#define HPCREACT_NO_MISSING_BRACES( ... ) __VA_ARGS__ // No-op for unknown compilers
4464
#endif

src/reactions/bulkGeneric/Parameters.hpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@ struct EquilibriumReactionsParameters
4545
RealType m_equilibriumConstant[numReactions];
4646

4747
private:
48-
HPCREACT_NO_MISSING_BRACES (
49-
template< std::size_t ... R, std::size_t ... RxS >
50-
constexpr
51-
EquilibriumReactionsParameters( RealType const (&stoichiometricMatrix)[numReactions][numSpecies],
52-
RealType const (&equilibriumConstant)[numReactions],
53-
std::index_sequence< R... >,
54-
std::index_sequence< RxS... > ) :
55-
m_stoichiometricMatrix{ stoichiometricMatrix[RxS/numSpecies][RxS%numSpecies] ... },
48+
HPCREACT_NO_MISSING_BRACES_OPEN
49+
template< std::size_t ... R, std::size_t ... RxS >
50+
constexpr
51+
EquilibriumReactionsParameters( RealType const (&stoichiometricMatrix)[numReactions][numSpecies],
52+
RealType const (&equilibriumConstant)[numReactions],
53+
std::index_sequence< R... >,
54+
std::index_sequence< RxS... > ):
55+
m_stoichiometricMatrix{ stoichiometricMatrix[RxS/numSpecies][RxS%numSpecies] ... },
5656
m_equilibriumConstant{ equilibriumConstant[R] ... }
57-
{}
58-
)
57+
{}
58+
HPCREACT_NO_MISSING_BRACES_CLOSE
5959
};
6060

6161

src/reactions/bulkGeneric/unitTests/testEquilibriumReactions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ TEST( testEquilibriumReactions, testCarbonateSystem2 )
260260
2.491372274738741e-03, // SO4-2
261261
1.858609094598949e+00, // Cl-
262262
9.881874292035110e-03, // Mg+2
263-
1.072307827865370e+00 // Na+1
263+
1.072307827865370e+00 // Na+1
264264
};
265265

266266
for( int r=0; r<numPrimarySpecies; ++r )

src/reactions/bulkGeneric/unitTests/testKineticReactions.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -129,26 +129,27 @@ TEST( testKineticReactions, computeReactionRatesTest_carbonateSystem )
129129
3.76e-1, // HCO3-
130130
3.87e-2, // Ca+2
131131
3.21e-2, // SO4-2
132-
1.89, // Cl-
132+
1.89, // Cl-
133133
1.65e-2, // Mg+2
134-
1.09 // Na+1
134+
1.09 // Na+1
135135
};
136136

137-
double const expectedReactionRates[11] = { -0.001424736,-12610.7392,-0.175591624,-473.6096,-269197.19999999984,-0.00012441275624000003,-18012.914999999986,-1.56526019999999e6,-346983.07769999903,-14247.58499999999,-2.316271799999999e6 };
137+
double const expectedReactionRates[11] = { -0.001424736, -12610.7392, -0.175591624, -473.6096, -269197.19999999984, -0.00012441275624000003, -18012.914999999986, -1.56526019999999e6,
138+
-346983.07769999903, -14247.58499999999, -2.316271799999999e6 };
138139
double const expectedReactionRatesDerivatives[11][18] =
139140
{
140-
{ 5.264e10,0,0,0,0,0,0,0,0,0,0,0.000014,0,0,0,0,0,0 },
141-
{ 0,0.039,0,0,0,0,0,0,0,0,0,-33539.2,-33539.2,0,0,0,0,0 },
142-
{ 0,0,3.76e9,0,0,0,0,0,0,0,0,1.e-6,-0.467,0,0,0,0,0 },
143-
{ 0,0,0,0.57,0,0,0,0,0,0,0,-1259.6,-1259.6,0,0,0,0,0 },
144-
{ 0,0,0,0,1.5e6,0,0,0,0,0,0,0,-715950.,-6.956e6,0,0,0,0 },
145-
{ 0,0,0,0,0,37600.,0,0,0,0,0,1.e-11,-0.000330885,-0.0032148000000000003,0,0,0,0 },
146-
{ 0,0,0,0,0,0,100000.,0,0,0,0,0,0,-465449.99999999994,-561150.,0,0,0 },
147-
{ 0,0,0,0,0,0,0,1.e8,0,0,0,0,0,-4.0446e7,0,-828180.,0,0 },
148-
{ 0,0,0,0,0,0,0,0,1.e7,0,0,0,0,-8.965971e6,0,-367177.86,0,0 },
149-
{ 0,0,0,0,0,0,0,0,0,100000.,0,0,0,0,-443850.,0,-863489.9999999999,0 },
150-
{ 0,0,0,0,0,0,0,0,0,0,1.e7,0,0,0,-7.2158e7,0,0,-2.12502e6 }
151-
} ;
141+
{ 5.264e10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.000014, 0, 0, 0, 0, 0, 0 },
142+
{ 0, 0.039, 0, 0, 0, 0, 0, 0, 0, 0, 0, -33539.2, -33539.2, 0, 0, 0, 0, 0 },
143+
{ 0, 0, 3.76e9, 0, 0, 0, 0, 0, 0, 0, 0, 1.e-6, -0.467, 0, 0, 0, 0, 0 },
144+
{ 0, 0, 0, 0.57, 0, 0, 0, 0, 0, 0, 0, -1259.6, -1259.6, 0, 0, 0, 0, 0 },
145+
{ 0, 0, 0, 0, 1.5e6, 0, 0, 0, 0, 0, 0, 0, -715950., -6.956e6, 0, 0, 0, 0 },
146+
{ 0, 0, 0, 0, 0, 37600., 0, 0, 0, 0, 0, 1.e-11, -0.000330885, -0.0032148000000000003, 0, 0, 0, 0 },
147+
{ 0, 0, 0, 0, 0, 0, 100000., 0, 0, 0, 0, 0, 0, -465449.99999999994, -561150., 0, 0, 0 },
148+
{ 0, 0, 0, 0, 0, 0, 0, 1.e8, 0, 0, 0, 0, 0, -4.0446e7, 0, -828180., 0, 0 },
149+
{ 0, 0, 0, 0, 0, 0, 0, 0, 1.e7, 0, 0, 0, 0, -8.965971e6, 0, -367177.86, 0, 0 },
150+
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 100000., 0, 0, 0, 0, -443850., 0, -863489.9999999999, 0 },
151+
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.e7, 0, 0, 0, -7.2158e7, 0, 0, -2.12502e6 }
152+
};
152153

153154
computeReactionRatesTest< double, false >( carbonateSystem,
154155
initialSpeciesConcentration,

0 commit comments

Comments
 (0)