Commit 6e15787c authored by Lynn Garren's avatar Lynn Garren

deal with more shadowing issues

parent 9821a48d
......@@ -5,6 +5,8 @@
affects Geometry, Random, Utility, and Vector
* Random/Random/Randomize.h: protect against unused variable warning
* Utility/Utility/memory.h: protect against non virtual destructor warning
* Random/Random/RandGaussZiggurat.h, Random/src/RandGaussZiggurat.cc: use std::abs
* deal with shadowing variables in GenericFunctions, Random/test, and Utility/test
==============================
10.02.15 Release CLHEP-2.2.0.5
......
......@@ -25,6 +25,10 @@ namespace Genfun {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
#endif
#if __GNUC__ > 4
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
#endif
#endif
#ifdef __clang__
#pragma clang diagnostic push
......@@ -56,6 +60,9 @@ namespace Genfun {
#if __GNUC__ > 3 && __GNUC_MINOR__ > 6
#pragma GCC diagnostic pop
#endif
#if __GNUC__ > 4
#pragma GCC diagnostic pop
#endif
#endif
#ifdef __clang__
#pragma clang diagnostic pop
......
......@@ -34,6 +34,10 @@ namespace Genfun {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
#endif
#if __GNUC__ > 4
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
#endif
#endif
#ifdef __clang__
#pragma clang diagnostic push
......@@ -65,6 +69,9 @@ namespace Genfun {
#if __GNUC__ > 3 && __GNUC_MINOR__ > 6
#pragma GCC diagnostic pop
#endif
#if __GNUC__ > 4
#pragma GCC diagnostic pop
#endif
#endif
#ifdef __clang__
#pragma clang diagnostic pop
......
......@@ -58,8 +58,8 @@ void testRandGauss(std::vector<double> const& reference, bool& result) {
// that the second thread is using a different cache when it
// does not use that cached value.
long seedL = 100;
CLHEP::HepJamesRandom engine(seedL);
long seedL1 = 100;
CLHEP::HepJamesRandom engine(seedL1);
CLHEP::RandGauss dist(engine);
result = true;
......@@ -75,7 +75,7 @@ void testRandGauss(std::vector<double> const& reference, bool& result) {
}
// check the shoot method where we pass in an engine
CLHEP::HepJamesRandom engine1(seedL);
CLHEP::HepJamesRandom engine1(seedL1);
if (reference[0] != CLHEP::RandGauss::shoot(&engine1) ||
reference[1] != CLHEP::RandGauss::shoot(&engine1) ||
reference[2] != CLHEP::RandGauss::shoot(&engine1) ||
......@@ -86,7 +86,7 @@ void testRandGauss(std::vector<double> const& reference, bool& result) {
// check the shoot method using the CLHEP thread local
// engine
CLHEP::HepJamesRandom engine2(seedL);
CLHEP::HepJamesRandom engine2(seedL1);
CLHEP::HepRandom::setTheEngine(&engine2);
// setFlag causes it to not use the cached value
// and generate a new pair of random numbers
......@@ -100,6 +100,21 @@ void testRandGauss(std::vector<double> const& reference, bool& result) {
}
}
#if defined __GNUC__
#if __GNUC__ > 3 && __GNUC_MINOR__ > 6
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
#endif
#if __GNUC__ > 4
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
#endif
#endif
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wshadow"
#endif
int main() {
std::ofstream output("testThreaded.cout");
......@@ -273,40 +288,40 @@ int main() {
// Test to reference values determined by running this code once
// Results should be reproducible so they should not change.
{
long seedL = 100;
CLHEP::HepJamesRandom engine(seedL);
long seedL2 = 100;
CLHEP::HepJamesRandom engine(seedL2);
if(CLHEP::RandBinomial::shoot(&engine, 50, 0.2) != 12) {
output << "Error, results changed for RandBinomial.\n";
return 1;
}
}
{
long seedL = 100;
CLHEP::HepJamesRandom engine(seedL);
long seedL3 = 100;
CLHEP::HepJamesRandom engine(seedL3);
if(std::fabs(CLHEP::RandChiSquare::shoot(&engine) - 0.031799) > epsilon) {
output << "Error, results changed for RandChiSquared.\n";
return 1;
}
}
{
long seedL = 100;
CLHEP::HepJamesRandom engine(seedL);
long seedL4 = 100;
CLHEP::HepJamesRandom engine(seedL4);
if(std::fabs(CLHEP::RandExpZiggurat::shoot(&engine) - 1.59601) > epsilon) {
output << "Error, results changed for RandExpZiggurat.\n";
return 1;
}
}
{
long seedL = 100;
CLHEP::HepJamesRandom engine(seedL);
long seedL5 = 100;
CLHEP::HepJamesRandom engine(seedL5);
if(std::fabs(CLHEP::RandGamma::shoot(&engine) - 1.25744) > epsilon) {
output << "Error, results changed for RandGamma.\n";
return 1;
}
}
{
long seedL = 100;
CLHEP::HepJamesRandom engine(seedL);
long seedL6 = 100;
CLHEP::HepJamesRandom engine(seedL6);
if(std::fabs(CLHEP::RandGaussZiggurat::shoot(&engine) - (-0.138855)) > epsilon) {
output << "Error, results changed for RandGaussZiggurat.\n";
return 1;
......@@ -315,3 +330,14 @@ int main() {
return 0;
#endif
}
#if defined __GNUC__
#if __GNUC__ > 3 && __GNUC_MINOR__ > 6
#pragma GCC diagnostic pop
#endif
#if __GNUC__ > 4
#pragma GCC diagnostic pop
#endif
#endif
#ifdef __clang__
#pragma clang diagnostic pop
#endif
......@@ -401,29 +401,29 @@ int
assert(evaluate<short const >() == cat_int);
assert(evaluate<short volatile >() == cat_int);
assert(evaluate<short const volatile >() == cat_int);
typedef unsigned short ushort __attribute__((unused));
assert(evaluate<ushort >() == cat_int);
assert(evaluate<ushort const >() == cat_int);
assert(evaluate<ushort volatile >() == cat_int);
assert(evaluate<ushort const volatile >() == cat_int);
typedef unsigned short ushort_local __attribute__((unused));
assert(evaluate<ushort_local >() == cat_int);
assert(evaluate<ushort_local const >() == cat_int);
assert(evaluate<ushort_local volatile >() == cat_int);
assert(evaluate<ushort_local const volatile >() == cat_int);
assert(evaluate<int >() == cat_int);
assert(evaluate<int const >() == cat_int);
assert(evaluate<int volatile >() == cat_int);
assert(evaluate<int const volatile >() == cat_int);
typedef unsigned int uint __attribute__((unused));
assert(evaluate<uint >() == cat_int);
assert(evaluate<uint const >() == cat_int);
assert(evaluate<uint volatile >() == cat_int);
assert(evaluate<uint const volatile >() == cat_int);
typedef unsigned int uint_local __attribute__((unused));
assert(evaluate<uint_local >() == cat_int);
assert(evaluate<uint_local const >() == cat_int);
assert(evaluate<uint_local volatile >() == cat_int);
assert(evaluate<uint_local const volatile >() == cat_int);
assert(evaluate<long >() == cat_int);
assert(evaluate<long const >() == cat_int);
assert(evaluate<long volatile >() == cat_int);
assert(evaluate<long const volatile >() == cat_int);
typedef unsigned long ulong __attribute__((unused));
assert(evaluate<ulong >() == cat_int);
assert(evaluate<ulong const >() == cat_int);
assert(evaluate<ulong volatile >() == cat_int);
assert(evaluate<ulong const volatile >() == cat_int);
typedef unsigned long ulong_local __attribute__((unused));
assert(evaluate<ulong_local >() == cat_int);
assert(evaluate<ulong_local const >() == cat_int);
assert(evaluate<ulong_local volatile >() == cat_int);
assert(evaluate<ulong_local const volatile >() == cat_int);
// floating-point types
assert(evaluate<float >() == cat_flt);
......@@ -457,7 +457,7 @@ int
assert(evaluate<int volatile * >() == cat_ptr);
assert(evaluate<int * * >() == cat_ptr);
assert(evaluate<int * * volatile >() == cat_ptr);
assert(evaluate<uint volatile * >() == cat_ptr);
assert(evaluate<uint_local volatile * >() == cat_ptr);
assert(evaluate<long volatile * const >() == cat_ptr);
assert(evaluate<double * const * >() == cat_ptr);
assert(evaluate<float * const * const >() == cat_ptr);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment