Commit 20c5aad2 authored by Lynn Garren's avatar Lynn Garren

add clhep_enable_asserts()

parent 65bf9e32
2015-06-10 Lynn Garren <garren@fnal.gov>
* __attribute__((unused)) is not recognized by Visual C++
* Make sure asserts are enabled for tests by removing -DNDEBUG
from the compiler flags
This solves the unused variable problem.
==============================
27.05.15 Release CLHEP-2.2.0.6
==============================
......
clhep_enable_asserts()
clhep_test( testGenericFunctions )
......@@ -3,21 +3,10 @@
#include "CLHEP/GenericFunctions/Cos.hh"
#include "CLHEP/GenericFunctions/defs.h"
#include <float.h>
#include <assert.h>
#include <cassert>
#include <cmath>
// don't generate warnings about unused variables inside assert
#if defined __GNUC__
#if __GNUC__ > 3 && __GNUC_MINOR__ > 6
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#endif
#endif
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
int main(int, char **) {
using namespace Genfun;
......
remove_definitions(-DNDEBUG)
clhep_enable_asserts()
clhep_test( testBasicVector3D )
clhep_test( testBug6740 SIMPLE )
......@@ -38,7 +38,7 @@ using namespace HepGeom;
\
/* Check conversion to array */ \
const point p05(1,2,3); \
const type * a __attribute__((unused)) = p05; \
const type * a = p05; \
assert(a[0] == 1 && a[1] == 2 && a[2] == 3); \
point p06(4,5,6); \
a = p06; \
......
remove_definitions(-DNDEBUG)
clhep_enable_asserts()
set( Utility_simple_tests testNoncopyable
testPrimaryTraits
......
......@@ -387,12 +387,12 @@ int
assert(evaluate<char const >() == cat_int);
assert(evaluate<char volatile >() == cat_int);
assert(evaluate<char const volatile >() == cat_int);
typedef signed char schar __attribute__((unused));
typedef signed char schar ;
assert(evaluate<schar >() == cat_int);
assert(evaluate<schar const >() == cat_int);
assert(evaluate<schar volatile >() == cat_int);
assert(evaluate<schar const volatile >() == cat_int);
typedef unsigned char uchar __attribute__((unused));
typedef unsigned char uchar ;
assert(evaluate<uchar >() == cat_int);
assert(evaluate<uchar const >() == cat_int);
assert(evaluate<uchar volatile >() == cat_int);
......@@ -401,7 +401,7 @@ int
assert(evaluate<short const >() == cat_int);
assert(evaluate<short volatile >() == cat_int);
assert(evaluate<short const volatile >() == cat_int);
typedef unsigned short ushort_local __attribute__((unused));
typedef unsigned short ushort_local ;
assert(evaluate<ushort_local >() == cat_int);
assert(evaluate<ushort_local const >() == cat_int);
assert(evaluate<ushort_local volatile >() == cat_int);
......@@ -410,7 +410,7 @@ int
assert(evaluate<int const >() == cat_int);
assert(evaluate<int volatile >() == cat_int);
assert(evaluate<int const volatile >() == cat_int);
typedef unsigned int uint_local __attribute__((unused));
typedef unsigned int uint_local ;
assert(evaluate<uint_local >() == cat_int);
assert(evaluate<uint_local const >() == cat_int);
assert(evaluate<uint_local volatile >() == cat_int);
......@@ -419,7 +419,7 @@ int
assert(evaluate<long const >() == cat_int);
assert(evaluate<long volatile >() == cat_int);
assert(evaluate<long const volatile >() == cat_int);
typedef unsigned long ulong_local __attribute__((unused));
typedef unsigned long ulong_local ;
assert(evaluate<ulong_local >() == cat_int);
assert(evaluate<ulong_local const >() == cat_int);
assert(evaluate<ulong_local volatile >() == cat_int);
......@@ -434,7 +434,7 @@ int
assert(evaluate<double const >() == cat_flt);
assert(evaluate<double volatile >() == cat_flt);
assert(evaluate<double const volatile >() == cat_flt);
typedef long double ldouble __attribute__((unused));
typedef long double ldouble ;
assert(evaluate<ldouble >() == cat_flt);
assert(evaluate<ldouble const >() == cat_flt);
assert(evaluate<ldouble volatile >() == cat_flt);
......
......@@ -377,7 +377,7 @@ void
}
void
deleter2(int * p __attribute__((unused)))
deleter2(int * p )
{
assert(p == &m);
++*p;
......@@ -386,7 +386,7 @@ void
// don't generate warnings about unused parameter inside assert
struct deleter3
{
void operator()(incomplete * p __attribute__((unused)))
void operator()(incomplete * p )
{
assert(p == 0);
}
......@@ -962,7 +962,7 @@ void
// don't generate warnings about unused variable q
{
std::auto_ptr<int> p(new int(7));
int * q __attribute__((unused))= p.get();
int * q = p.get();
shared_ptr<int> pi(p);
assert(pi? true: false);
assert(!!pi);
......@@ -976,7 +976,7 @@ void
{
std::auto_ptr<int> p(new int(7));
int * q __attribute__((unused))= p.get();
int * q = p.get();
shared_ptr<int const> pi(p);
assert(pi? true: false);
assert(!!pi);
......@@ -990,7 +990,7 @@ void
{
std::auto_ptr<int> p(new int(7));
int * q __attribute__((unused))= p.get();
int * q = p.get();
shared_ptr<void> pv(p);
assert(pv? true: false);
assert(!!pv);
......@@ -1003,7 +1003,7 @@ void
{
std::auto_ptr<int> p(new int(7));
int * q __attribute__((unused))= p.get();
int * q = p.get();
shared_ptr<void const> pv(p);
assert(pv? true: false);
assert(!!pv);
......@@ -1018,7 +1018,7 @@ void
{
std::auto_ptr<X> p(new X);
X * q __attribute__((unused)) = p.get();
X * q = p.get();
shared_ptr<X> px(p);
assert(px? true: false);
assert(!!px);
......@@ -1034,7 +1034,7 @@ void
{
std::auto_ptr<X> p(new X);
X * q __attribute__((unused)) = p.get();
X * q = p.get();
shared_ptr<X const> px(p);
assert(px? true: false);
assert(!!px);
......@@ -1050,7 +1050,7 @@ void
{
std::auto_ptr<X> p(new X);
X * q __attribute__((unused)) = p.get();
X * q = p.get();
shared_ptr<void> pv(p);
assert(pv? true: false);
assert(!!pv);
......@@ -1066,7 +1066,7 @@ void
{
std::auto_ptr<X> p(new X);
X * q __attribute__((unused)) = p.get();
X * q = p.get();
shared_ptr<void const> pv(p);
assert(pv? true: false);
assert(!!pv);
......@@ -1083,7 +1083,7 @@ void
{
std::auto_ptr<Y> p(new Y);
Y * q __attribute__((unused)) = p.get();
Y * q = p.get();
shared_ptr<X> px(p);
assert(px? true: false);
assert(!!px);
......@@ -1101,7 +1101,7 @@ void
{
std::auto_ptr<Y> p(new Y);
Y * q __attribute__((unused)) = p.get();
Y * q = p.get();
shared_ptr<X const> px(p);
assert(px? true: false);
assert(!!px);
......
......@@ -245,8 +245,8 @@ int main()
weak_ptr<X> wp5;
bool b1 __attribute__((unused)) = wp1 < wp5;
bool b2 __attribute__((unused)) = wp5 < wp1;
bool b1 = wp1 < wp5;
bool b2 = wp5 < wp1;
p5.reset();
......
......@@ -1018,8 +1018,8 @@ void
assert(wp < wp2 || wp2 < wp);
assert(!(wp < wp2 && wp2 < wp));
bool b1 __attribute__((unused)) = wp < wp2;
bool b2 __attribute__((unused)) = wp2 < wp;
bool b1 = wp < wp2;
bool b2 = wp2 < wp;
{
weak_ptr<X> wp3(wp);
......@@ -1067,8 +1067,8 @@ void
assert(wp < wp2 || wp2 < wp);
assert(!(wp < wp2 && wp2 < wp));
bool b1 __attribute__((unused)) = wp < wp2;
bool b2 __attribute__((unused)) = wp2 < wp;
bool b1 = wp < wp2;
bool b2 = wp2 < wp;
{
weak_ptr<X> wp3(wp);
......@@ -1136,8 +1136,8 @@ void
assert(!(wp < wp2 || wp2 < wp));
assert(!(wp < wp2 && wp2 < wp));
bool b1 __attribute__((unused)) = wp < wp2;
bool b2 __attribute__((unused)) = wp2 < wp;
bool b1 = wp < wp2;
bool b2 = wp2 < wp;
{
weak_ptr<X> wp3(wp);
......
remove_definitions(-DNDEBUG)
clhep_enable_asserts()
set( Vector_tests testThreeVector
testLorentzVector )
......
......@@ -10,7 +10,7 @@
#include "CLHEP/Units/GlobalPhysicalConstants.h"
#include "CLHEP/Vector/Rotation.h"
#include "CLHEP/Vector/ThreeVector.h"
#include <assert.h>
#include <cassert>
#include <cmath>
#include <stdlib.h>
......@@ -25,9 +25,9 @@ typedef Hep3Vector Vector;
int main() {
int i,k;
double angA=CLHEP::pi/3, angB=CLHEP::pi/4, angC=CLHEP::pi/6;
double cosA __attribute__((unused))=std::cos(angA), sinA __attribute__((unused))=std::sin(angA);
double cosB __attribute__((unused))=std::cos(angB), sinB __attribute__((unused))=std::sin(angB);
double cosC __attribute__((unused))=std::cos(angC), sinC __attribute__((unused))=std::sin(angC);
double cosA =std::cos(angA), sinA =std::sin(angA);
double cosB =std::cos(angB), sinB =std::sin(angB);
double cosC =std::cos(angC), sinC =std::sin(angC);
Rotation R; // default constructor
assert ( R.xx() == 1 );
......
......@@ -18,6 +18,7 @@
#
# clhep_lib_suffix();
# check for -DLIB_SUFFIX=xxx and process intelligently
#
macro( clhep_autoconf_variables )
......@@ -190,7 +191,7 @@ macro( _clhep_check_cxxstd )
endmacro( _clhep_check_cxxstd )
macro( _clhep_check_for_pthread )
message(STATUS "_clhep_check_for_pthread debug: CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
##message(STATUS "_clhep_check_for_pthread debug: CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
set( HAVE_STDCXX )
if( NOT "${CMAKE_CXX_FLAGS}" STREQUAL "" )
string(REGEX REPLACE " " ";" flag_list ${CMAKE_CXX_FLAGS})
......@@ -398,3 +399,9 @@ macro( clhep_lib_suffix )
endif()
message(STATUS "libraries will be installed in $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
endmacro( clhep_lib_suffix )
macro( clhep_enable_asserts )
string(REGEX REPLACE "-DNDEBUG" " " CXXFLAGS "${CXXFLAGS}" )
string(TOUPPER ${CMAKE_BUILD_TYPE} BTYPE_UC )
string(REGEX REPLACE "-DNDEBUG" " " CMAKE_CXX_FLAGS_${BTYPE_UC} "${CMAKE_CXX_FLAGS_${BTYPE_UC}}" )
endmacro( clhep_enable_asserts )
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