Commit 31b1892a authored by David C. Lonie's avatar David C. Lonie

Compiler warning/error cleanup.

parent 8ee043b7
Pipeline #8770 passed with stage
......@@ -187,7 +187,7 @@ list(APPEND temp
"\n"
"namespace vtkArrayDispatch {\n"
"\n"
"typedef typename vtkTypeList::Unique<\n"
"typedef vtkTypeList::Unique<\n"
" vtkTypeList_Create_${vtkAD_numArrays}(\n"
)
......
......@@ -252,6 +252,10 @@ private:
UseLog(useLog)
{}
// Silence warning C4512 on MSVC2015: "assignment operator could not be
// generated.". This class is never copied, so no need for assignment.
CopyToPoints& operator=(const CopyToPoints &) { return *this; }
// Use input array:
template <class ArrayT>
void operator()(ArrayT *array)
......
......@@ -144,8 +144,7 @@ typedef vtkTypeList_Create_5(vtkSoADataArrayTemplate<double>,
vtkSoADataArrayTemplate<unsigned char>,
vtkSoADataArrayTemplate<vtkIdType>) SoAArrayList;
typedef typename vtkTypeList::Append<AoSArrayList, SoAArrayList>::Result
AllArrayList;
typedef vtkTypeList::Append<AoSArrayList, SoAArrayList>::Result AllArrayList;
//------------------------------------------------------------------------------
// Return true if the VTK type tag is an integral type.
......@@ -452,7 +451,7 @@ int TestDispatch2BySameValueType()
{
vtkDataArray *array2 = *it2;
bool array2Valid = vtkDataTypesCompare(array1->GetDataType(),
array2->GetDataType());
array2->GetDataType()) != 0;
if (array1Valid && array2Valid)
{
......@@ -571,7 +570,7 @@ int TestDispatch3ByValueType()
{
vtkDataArray *array3 = *it3;
bool array3Valid = vtkDataTypesCompare(array3->GetDataType(),
VTK_UNSIGNED_CHAR);
VTK_UNSIGNED_CHAR) != 0;
if (array1Valid && array2Valid && array3Valid)
{
......@@ -634,8 +633,8 @@ int TestDispatch3ByArrayWithSameValueType()
itEnd3 = Arrays::allArrays.end(); it3 != itEnd3; ++it3)
{
vtkDataArray *array3 = *it3;
bool array3Valid =
vtkDataTypesCompare(array1->GetDataType(), array3->GetDataType());
bool array3Valid = vtkDataTypesCompare(array1->GetDataType(),
array3->GetDataType()) != 0;
if (array1Valid && array2Valid && array3Valid)
{
......@@ -688,14 +687,14 @@ int TestDispatch3BySameValueType()
{
vtkDataArray *array2 = *it2;
bool array2Valid = vtkDataTypesCompare(array1->GetDataType(),
array2->GetDataType());
array2->GetDataType()) != 0;
for (ArrayIter it3 = Arrays::allArrays.begin(),
itEnd3 = Arrays::allArrays.end(); it3 != itEnd3; ++it3)
{
vtkDataArray *array3 = *it3;
bool array3Valid = vtkDataTypesCompare(array1->GetDataType(),
array3->GetDataType());
array3->GetDataType()) != 0;
if (array1Valid && array2Valid && array3Valid)
{
......
......@@ -53,6 +53,9 @@
#include "vtkUnsignedLongLongArray.h"
#include "vtkUnsignedShortArray.h"
// Needed for portable setenv on MSVC...
#include "vtksys/SystemTools.hxx"
// About this test:
//
// This test runs a battery of unit tests that exercise the vtkDataArray API
......@@ -965,19 +968,22 @@ int Test_voidPtr_GetVoidPointer()
for (vtkIdType t = 0; t < tuples; ++t)
{
// Silence the void pointer warnings for these calls
const char *oldWarning = getenv("VTK_SILENCE_GET_VOID_POINTER_WARNINGS");
setenv("VTK_SILENCE_GET_VOID_POINTER_WARNINGS", "1", 1);
const char *oldWarning =
vtksys::SystemTools::GetEnv("VTK_SILENCE_GET_VOID_POINTER_WARNINGS");
vtksys::SystemTools::PutEnv("VTK_SILENCE_GET_VOID_POINTER_WARNINGS=1");
ScalarT *ptr = static_cast<ScalarT*>(source->GetVoidPointer(t * comps));
// Restore state:
if (oldWarning)
{
setenv("VTK_SILENCE_GET_VOID_POINTER_WARNINGS", oldWarning, 1);
std::ostringstream envArg;
envArg << "VTK_SILENCE_GET_VOID_POINTER_WARNINGS=" << oldWarning;
vtksys::SystemTools::PutEnv(envArg.str());
}
else
{
unsetenv("VTK_SILENCE_GET_VOID_POINTER_WARNINGS");
vtksys::SystemTools::UnPutEnv("VTK_SILENCE_GET_VOID_POINTER_WARNINGS");
}
DataArrayAPIAssert(ptr != NULL, "GetVoidPointer returned NULL!");
......@@ -1487,22 +1493,24 @@ int Test_vtkArrayIteratorPtr_NewIterator()
// Silence the void pointer warnings for these calls. The
// vtkArrayIteratorTemplate implementation relies on GetVoidPointer.
const char *oldWarning = getenv("VTK_SILENCE_GET_VOID_POINTER_WARNINGS");
setenv("VTK_SILENCE_GET_VOID_POINTER_WARNINGS", "1", 1);
const char *oldWarning =
vtksys::SystemTools::GetEnv("VTK_SILENCE_GET_VOID_POINTER_WARNINGS");
vtksys::SystemTools::PutEnv("VTK_SILENCE_GET_VOID_POINTER_WARNINGS=1");
vtkArrayIterator *iter = source->NewIterator();
// Restore state:
if (oldWarning)
{
setenv("VTK_SILENCE_GET_VOID_POINTER_WARNINGS", oldWarning, 1);
std::ostringstream envArg;
envArg << "VTK_SILENCE_GET_VOID_POINTER_WARNINGS=" << oldWarning;
vtksys::SystemTools::PutEnv(envArg.str());
}
else
{
unsetenv("VTK_SILENCE_GET_VOID_POINTER_WARNINGS");
vtksys::SystemTools::UnPutEnv("VTK_SILENCE_GET_VOID_POINTER_WARNINGS");
}
DataArrayAPIAssert(iter != NULL,
"NewIterator() returns NULL.");
......
......@@ -53,7 +53,7 @@ void Test()
array->Delete();
}
int TestGenericDataArray(int, char**)
int TestGenericDataArray(int, char*[])
{
Test<vtkSoADataArrayTemplate<float> >();
Test<vtkAoSDataArrayTemplate<float> >();
......
......@@ -9,6 +9,7 @@ vtk_module(vtkCommonCore
vtkTestingCore
vtkCommonSystem
vtkCommonTransforms
vtksys
KIT
vtkCommon
)
......@@ -196,7 +196,9 @@ private:
#include "vtkAoSDataArrayTemplate.txx"
// Ported over from vtkDataArrayTemplate:
#endif // header guard
// TODO clean this up, more or less copy/pasted from vtkDataArrayTemplate.h:
#if !defined(VTK_NO_EXPLICIT_TEMPLATE_INSTANTIATION)
# define VTK_AOS_DATA_ARRAY_TEMPLATE_INSTANTIATE(T) \
......@@ -204,13 +206,9 @@ private:
#else
// TODO Not sure what this does, need to dig some:
//# include "vtkDataArrayTemplateImplicit.txx"
//# define VTK_DATA_ARRAY_TEMPLATE_INSTANTIATE(T)
//# define VTK_AOS_DATA_ARRAY_TEMPLATE_INSTANTIATE(T)
#endif
#endif // header guard
// TODO clean this up, more or less copy/pasted from vtkDataArrayTemplate.h:
// This portion must be OUTSIDE the include blockers. Each
// vtkDataArray subclass uses this to give its instantiation of this
// template a DLL interface.
......
......@@ -49,7 +49,7 @@ vtkAoSDataArrayTemplate<ValueType>::~vtkAoSDataArrayTemplate()
vtkAoSDataArrayTemplateT(void)::SetArray(
ValueType* array, vtkIdType size, int save, int deleteMethod)
{
this->Buffer.SetBuffer(array, size, save, deleteMethod);
this->Buffer.SetBuffer(array, size, save != 0, deleteMethod);
this->Size = size;
this->MaxId = this->Size - 1;
this->DataChanged();
......@@ -80,10 +80,7 @@ vtkAoSDataArrayTemplate<ValueTypeT>::WritePointer(vtkIdType id,
}
// For extending the in-use ids but not the size:
if ((newSize - 1) > this->MaxId)
{
this->MaxId = newSize - 1;
}
this->MaxId = std::max(this->MaxId, newSize - 1);
this->DataChanged();
return this->GetPointer(id);
......
......@@ -140,7 +140,7 @@ typedef vtkTypeList_Create_2(double, float) Reals;
// Description:
// A Typelist containing all integral ValueTypes.
typedef typename vtkTypeList::Unique<
typedef vtkTypeList::Unique<
vtkTypeList_Create_12(char, int, long, long long, short, signed char,
unsigned char, unsigned int, unsigned long,
unsigned long long, unsigned short, vtkIdType)
......@@ -148,7 +148,7 @@ typedef typename vtkTypeList::Unique<
// Description:
// A Typelist containing all standard VTK array ValueTypes.
typedef typename vtkTypeList::Append<Reals, Integrals>::Result AllTypes;
typedef vtkTypeList::Append<Reals, Integrals>::Result AllTypes;
//------------------------------------------------------------------------------
// Description:
......
......@@ -143,3 +143,4 @@ protected:
};
#endif
// VTK-HeaderTest-Exclude: vtkBuffer.h
......@@ -166,7 +166,7 @@ bool DoComputeScalarRange(ArrayT *array, double *ranges)
}
//compute the range for each component of the data array at the same time
for (vtkIdType tupleIdx; tupleIdx < numTuples; ++tupleIdx)
for (vtkIdType tupleIdx = 0; tupleIdx < numTuples; ++tupleIdx)
{
for(int compIdx = 0, j = 0; compIdx < numComp; ++compIdx, j+=2)
{
......@@ -208,7 +208,7 @@ bool DoComputeVectorRange(ArrayT *array, double range[2])
}
//iterate over all the tuples
for (vtkIdType tupleIdx; tupleIdx < numTuples; ++tupleIdx)
for (vtkIdType tupleIdx = 0; tupleIdx < numTuples; ++tupleIdx)
{
double squaredSum = 0.0;
for (int compIdx = 0; compIdx < numComps; ++compIdx)
......
......@@ -453,9 +453,9 @@ public:
protected:
vtkGenericDataArray()
: Lookup(*this)
{
// Initialize internal data structures:
this->Lookup.SetArray(this);
this->SetNumberOfComponents(this->NumberOfComponents);
}
......@@ -497,3 +497,4 @@ private:
#include "vtkGenericDataArray.txx"
#endif
// VTK-HeaderTest-Exclude: vtkGenericDataArray.h
......@@ -37,8 +37,8 @@ public:
typedef typename ArrayType::ValueType ValueType;
// Constructor.
vtkGenericDataArrayLookupHelper(ArrayType& associatedArray)
: AssociatedArray(associatedArray),
vtkGenericDataArrayLookupHelper()
: AssociatedArray(NULL),
SortedArray(NULL)
{
}
......@@ -47,6 +47,15 @@ public:
this->ClearLookup();
}
void SetArray(ArrayTypeT *array)
{
if (this->AssociatedArray != array)
{
this->ClearLookup();
this->AssociatedArray = array;
}
}
vtkIdType LookupValue(ValueType elem)
{
this->UpdateLookup();
......@@ -107,29 +116,36 @@ private:
void UpdateLookup()
{
if (this->SortedArray) { return; }
if (!this->AssociatedArray || this->SortedArray)
{
return;
}
int numComps = this->AssociatedArray.GetNumberOfComponents();
int numComps = this->AssociatedArray->GetNumberOfComponents();
this->SortedArraySize =
this->AssociatedArray.GetNumberOfTuples() * numComps;
this->AssociatedArray->GetNumberOfTuples() * numComps;
if (this->SortedArraySize == 0) { return; }
if (this->SortedArraySize == 0)
{
return;
}
this->SortedArray = reinterpret_cast<ValueWithIndex*>(
malloc(this->SortedArraySize * sizeof(ValueWithIndex)));
for (vtkIdType cc=0, max=this->AssociatedArray.GetNumberOfValues();
for (vtkIdType cc = 0, max = this->AssociatedArray->GetNumberOfValues();
cc < max; ++cc)
{
ValueWithIndex& item = this->SortedArray[cc];
item.Value = this->AssociatedArray.GetValue(cc);
item.Value = this->AssociatedArray->GetValue(cc);
item.Index = cc;
}
std::sort(this->SortedArray, this->SortedArray + this->SortedArraySize);
}
ArrayTypeT& AssociatedArray;
ArrayTypeT *AssociatedArray;
ValueWithIndex* SortedArray;
vtkIdType SortedArraySize;
};
#endif
// VTK-HeaderTest-Exclude: vtkGenericDataArrayLookupHelper.h
......@@ -191,3 +191,4 @@ private:
#include "vtkSoADataArrayTemplate.txx"
#endif
// VTK-HeaderTest-Exclude: vtkSoADataArrayTemplate.h
......@@ -43,7 +43,7 @@ vtkSoADataArrayTemplate<ValueType>::vtkSoADataArrayTemplate()
template<class ValueType>
vtkSoADataArrayTemplate<ValueType>::~vtkSoADataArrayTemplate()
{
for (size_t cc=0; cc < this->Data.size(); ++cc)
for (size_t cc = 0; cc < this->Data.size(); ++cc)
{
this->Data[cc].SetBuffer(NULL, 0);
}
......@@ -120,7 +120,7 @@ bool vtkSoADataArrayTemplate<ValueType>::AllocateTuples(vtkIdType numTuples)
if (!this->Resizeable)
{
vtkIdType minTuples = VTK_ID_MAX;
for (int cc=0, max=this->Data.size(); cc < max; cc++)
for (size_t cc = 0, max = this->Data.size(); cc < max; cc++)
{
minTuples = std::min(minTuples, this->Data[cc].GetSize());
}
......@@ -136,7 +136,7 @@ bool vtkSoADataArrayTemplate<ValueType>::AllocateTuples(vtkIdType numTuples)
}
}
for (int cc=0, max=this->Data.size(); cc < max; ++cc)
for (size_t cc = 0, max = this->Data.size(); cc < max; ++cc)
{
if (!this->Data[cc].Allocate(numTuples))
{
......@@ -153,7 +153,7 @@ bool vtkSoADataArrayTemplate<ValueType>::ReallocateTuples(vtkIdType numTuples)
if (!this->Resizeable)
{
vtkIdType minTuples = VTK_ID_MAX;
for (int cc=0, max=this->Data.size(); cc < max; cc++)
for (size_t cc = 0, max = this->Data.size(); cc < max; cc++)
{
minTuples = std::min(minTuples, this->Data[cc].GetSize());
}
......@@ -165,7 +165,7 @@ bool vtkSoADataArrayTemplate<ValueType>::ReallocateTuples(vtkIdType numTuples)
return false;
}
for (int cc=0, max=this->Data.size(); cc < max; ++cc)
for (size_t cc = 0, max = this->Data.size(); cc < max; ++cc)
{
if (!this->Data[cc].Reallocate(numTuples))
{
......
......@@ -37,7 +37,6 @@ bool vtkTypedDataArray<Scalar>::AllocateTuples(vtkIdType)
vtkErrorMacro(<<"This method is not preferred for vtkTypedDataArray "
"implementations. Either add an appropriate implementation, or "
"use Allocate instead.");
abort();
return false;
}
......@@ -48,7 +47,6 @@ bool vtkTypedDataArray<Scalar>::ReallocateTuples(vtkIdType)
vtkErrorMacro(<<"This method is not preferred for vtkTypedDataArray "
"implementations. Either add an appropriate implementation, or "
"use Resize instead.");
abort();
return false;
}
......
......@@ -114,7 +114,7 @@ struct WarpVectorDispatch2Points
for (vtkIdType t = 0; t < numTuples; ++t)
{
if (!(t && 0xfff))
if (!(t & 0xfff))
{
this->Self->UpdateProgress(t / static_cast<double>(numTuples));
if (this->Self->GetAbortExecute())
......
......@@ -24,6 +24,11 @@
vtkStandardNewMacro(vtkPlatonicSolidSource);
// Wrapping this in namespaces because the short names (a, b, c, etc) are
// throwing warnings on MSVC when inlined methods in vtkGenericDataArray are
// being used ('warning C4459: declaration of 'c' hides global declaration')
namespace {
namespace vtkPlatonicSolidSourceDetail {
// The geometry and topology of each solid. Solids are centered at
// the origin with radius 1.0.
// The golden ration phi = (1+sqrt(5))/2=1.61803398875 enters into many
......@@ -77,6 +82,8 @@ static vtkIdType IcosaVerts[] = {
4,10,9, 5,11,8, 6,8,11, 1,9,3, 1,5,8, 0,3,10, 0,11,5, 7,10,4, 7,6,11,
2,4,9, 2,8,6
};
} // end namespace detail
} // end anon namespace
vtkPlatonicSolidSource::vtkPlatonicSolidSource()
{
......@@ -111,8 +118,8 @@ int vtkPlatonicSolidSource::RequestData(
numPts = 4;
cellSize = 3;
numCells = 4;
solidPoints = TetraPoints;
solidVerts = TetraVerts;
solidPoints = vtkPlatonicSolidSourceDetail::TetraPoints;
solidVerts = vtkPlatonicSolidSourceDetail::TetraVerts;
solidScale = 1.0/sqrt(3.0);
break;
......@@ -120,8 +127,8 @@ int vtkPlatonicSolidSource::RequestData(
numPts = 8;
cellSize = 4;
numCells = 6;
solidPoints = CubePoints;
solidVerts = CubeVerts;
solidPoints = vtkPlatonicSolidSourceDetail::CubePoints;
solidVerts = vtkPlatonicSolidSourceDetail::CubeVerts;
solidScale = 1.0/sqrt(3.0);
break;
......@@ -129,8 +136,8 @@ int vtkPlatonicSolidSource::RequestData(
numPts = 6;
cellSize = 3;
numCells = 8;
solidPoints = OctPoints;
solidVerts = OctVerts;
solidPoints = vtkPlatonicSolidSourceDetail::OctPoints;
solidVerts = vtkPlatonicSolidSourceDetail::OctVerts;
solidScale = 1.0/sqrt(2.0);
break;
......@@ -138,8 +145,8 @@ int vtkPlatonicSolidSource::RequestData(
numPts = 12;
cellSize = 3;
numCells = 20;
solidPoints = IcosaPoints;
solidVerts = IcosaVerts;
solidPoints = vtkPlatonicSolidSourceDetail::IcosaPoints;
solidVerts = vtkPlatonicSolidSourceDetail::IcosaVerts;
solidScale = 1.0/0.58778524999243;
break;
......@@ -147,8 +154,8 @@ int vtkPlatonicSolidSource::RequestData(
numPts = 20;
cellSize = 5;
numCells = 12;
solidPoints = DodePoints;
solidVerts = DodeVerts;
solidPoints = vtkPlatonicSolidSourceDetail::DodePoints;
solidVerts = vtkPlatonicSolidSourceDetail::DodeVerts;
solidScale = 1.0/1.070466269319;
break;
}
......
......@@ -8,10 +8,17 @@ if(NOT CMAKE_GENERATOR MATCHES "Visual Studio 6")
)
endif()
# We need typed arrays to be supported by the dispatcher to run the insitu test:
if(VTK_DISPATCH_TYPED_ARRAYS)
set(extra_tests ${extra_tests}
TestInSituExodus.cxx,NO_VALID
)
endif()
vtk_add_test_cxx(${vtk-module}CxxTests tests
TestExodusAttributes.cxx,NO_VALID,NO_OUTPUT
TestExodusSideSets.cxx,NO_VALID,NO_OUTPUT
TestInSituExodus.cxx,NO_VALID
${extra_tests}
)
vtk_test_cxx_executable(${vtk-module}CxxTests tests
RENDERING_FACTORY)
......@@ -110,7 +110,7 @@ struct WriteBinaryDataBlockWorker
//----------------------------------------------------------------------------
// Specialize for AoS arrays.
template <class ValueType>
int operator()(vtkAoSDataArrayTemplate<ValueType>* array)
void operator()(vtkAoSDataArrayTemplate<ValueType>* array)
{
// Get the raw pointer to the array data:
ValueType *iter = array->GetPointer(0);
......@@ -1305,6 +1305,7 @@ int vtkXMLWriter::WriteBinaryDataInternal(vtkAbstractArray* a)
{
vtkWarningMacro("Not writing array '" << a->GetName() << "': Unsupported "
"array type: " << a->GetClassName());
ret = 0;
}
// Free the byte swap buffer if it was allocated.
......
......@@ -80,6 +80,13 @@ struct TemplateCastRayWorker
NumIntersections(0)
{}
// Silence warning C4512 on MSVC2015: "assignment operator could not be
// generated.". This class is never copied, so no need for assignment.
TemplateCastRayWorker& operator=(const TemplateCastRayWorker &)
{
return *this;
}
// Execute the algorithm with all arrays set to NULL.
void operator()()
{
......
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