Suppress Gcc-8 warnings and List copy. Danial Khazaei.

This commit is contained in:
Hrvoje Jasak 2019-07-18 15:11:40 +01:00
commit 8d9c6a9c79
23 changed files with 202 additions and 163 deletions

View file

@ -1,3 +1,3 @@
RichardsFoam.C
EXE = $(FOAM_USER_APPBIN)/RichardsFoam
EXE = $(FOAM_APPBIN)/RichardsFoam

View file

@ -1,3 +1,3 @@
spatialMeanValueRichardsonFoam.C
EXE = $(FOAM_USER_APPBIN)/spatialMeanValueRichardsonFoam
EXE = $(FOAM_APPBIN)/spatialMeanValueRichardsonFoam

View file

@ -50,15 +50,12 @@ Foam::List<T>::List(const label s)
{
if (this->size_ < 0)
{
FatalErrorIn("List<T>::List(const label size)")
FatalErrorInFunction
<< "bad size " << this->size_
<< abort(FatalError);
}
if (this->size_)
{
this->v_ = new T[this->size_];
}
alloc();
}
@ -70,15 +67,15 @@ Foam::List<T>::List(const label s, const T& a)
{
if (this->size_ < 0)
{
FatalErrorIn("List<T>::List(const label size, const T&)")
FatalErrorInFunction
<< "bad size " << this->size_
<< abort(FatalError);
}
alloc();
if (this->size_)
{
this->v_ = new T[this->size_];
List_ACCESS(T, (*this), vp);
List_FOR_ALL((*this), i)
List_ELEM((*this), vp, i) = a;
@ -95,15 +92,15 @@ Foam::List<T>::List(const List<T>& a)
{
if (this->size_)
{
this->v_ = new T[this->size_];
alloc();
# ifdef USEMEMCPY
#ifdef USEMEMCPY
if (contiguous<T>())
{
memcpy(this->v_, a.v_, this->byteSize());
}
else
# endif
#endif
{
List_ACCESS(T, (*this), vp);
List_CONST_ACCESS(T, a, ap);
@ -125,11 +122,11 @@ Foam::List<T>::List(const Xfer< List<T> >& lst)
// Construct as copy or re-use as specified.
template<class T>
Foam::List<T>::List(List<T>& a, bool reUse)
Foam::List<T>::List(List<T>& a, bool reuse)
:
UList<T>(nullptr, a.size_)
{
if (reUse)
if (reuse)
{
this->v_ = a.v_;
a.v_ = 0;
@ -137,15 +134,15 @@ Foam::List<T>::List(List<T>& a, bool reUse)
}
else if (this->size_)
{
this->v_ = new T[this->size_];
alloc();
# ifdef USEMEMCPY
#ifdef USEMEMCPY
if (contiguous<T>())
{
memcpy(this->v_, a.v_, this->byteSize());
}
else
# endif
#endif
{
List_ACCESS(T, (*this), vp);
List_CONST_ACCESS(T, a, ap);
@ -167,11 +164,11 @@ Foam::List<T>::List(const UList<T>& a, const unallocLabelList& map)
{
// Note:cannot use List_ELEM since third argument has to be index.
this->v_ = new T[this->size_];
alloc();
forAll(*this, i)
{
this->v_[i] = a[map[i]];
this->operator[](i) = a[map[i]];
}
}
}
@ -181,32 +178,9 @@ Foam::List<T>::List(const UList<T>& a, const unallocLabelList& map)
template<class T>
template<class InputIterator>
Foam::List<T>::List(InputIterator first, InputIterator last)
{
label s = 0;
for
(
InputIterator iter = first;
iter != last;
++iter
)
{
s++;
}
setSize(s);
s = 0;
for
(
InputIterator iter = first;
iter != last;
++iter
)
{
this->operator[](s++) = iter();
}
}
:
List<T>(first, last, std::distance(first, last))
{}
// Construct as copy of FixedList<T, Size>
@ -216,15 +190,7 @@ Foam::List<T>::List(const FixedList<T, Size>& lst)
:
UList<T>(nullptr, Size)
{
if (this->size_)
{
this->v_ = new T[this->size_];
forAll(*this, i)
{
this->operator[](i) = lst[i];
}
}
allocCopyList(lst);
}
@ -234,15 +200,7 @@ Foam::List<T>::List(const PtrList<T>& lst)
:
UList<T>(nullptr, lst.size())
{
if (this->size_)
{
this->v_ = new T[this->size_];
forAll(*this, i)
{
this->operator[](i) = lst[i];
}
}
allocCopyList(lst);
}
@ -254,7 +212,7 @@ Foam::List<T>::List(const SLList<T>& lst)
{
if (this->size_)
{
this->v_ = new T[this->size_];
alloc();
label i = 0;
for
@ -276,15 +234,7 @@ Foam::List<T>::List(const IndirectList<T>& lst)
:
UList<T>(nullptr, lst.size())
{
if (this->size_)
{
this->v_ = new T[this->size_];
forAll(*this, i)
{
this->operator[](i) = lst[i];
}
}
allocCopyList(lst);
}
@ -294,15 +244,7 @@ Foam::List<T>::List(const UIndirectList<T>& lst)
:
UList<T>(nullptr, lst.size())
{
if (this->size_)
{
this->v_ = new T[this->size_];
forAll(*this, i)
{
this->operator[](i) = lst[i];
}
}
allocCopyList(lst);
}
@ -312,15 +254,7 @@ Foam::List<T>::List(const BiIndirectList<T>& lst)
:
UList<T>(nullptr, lst.size())
{
if (this->size_)
{
this->v_ = new T[this->size_];
forAll(*this, i)
{
this->operator[](i) = lst[i];
}
}
allocCopyList(lst);
}
@ -330,7 +264,10 @@ Foam::List<T>::List(const BiIndirectList<T>& lst)
template<class T>
Foam::List<T>::~List()
{
if (this->v_) delete[] this->v_;
if (this->v_)
{
delete[] this->v_;
}
}
@ -341,7 +278,7 @@ void Foam::List<T>::setSize(const label newSize)
{
if (newSize < 0)
{
FatalErrorIn("List<T>::setSize(const label)")
FatalErrorInFunction
<< "bad set size " << newSize
<< abort(FatalError);
}
@ -369,8 +306,8 @@ void Foam::List<T>::setSize(const label newSize)
while (i--) *--av = *--vv;
}
}
if (this->v_) delete[] this->v_;
clear();
this->size_ = newSize;
this->v_ = nv;
}
@ -397,21 +334,12 @@ void Foam::List<T>::setSize(const label newSize, const T& a)
}
template<class T>
void Foam::List<T>::clear()
{
if (this->v_) delete[] this->v_;
this->size_ = 0;
this->v_ = 0;
}
// Transfer the contents of the argument List into this List
// and anull the argument list
template<class T>
void Foam::List<T>::transfer(List<T>& a)
{
if (this->v_) delete[] this->v_;
clear();
this->size_ = a.size_;
this->v_ = a.v_;
@ -450,13 +378,7 @@ void Foam::List<T>::transfer(SortableList<T>& a)
template<class T>
void Foam::List<T>::operator=(const UList<T>& a)
{
if (a.size_ != this->size_)
{
if (this->v_) delete[] this->v_;
this->v_ = 0;
this->size_ = a.size_;
if (this->size_) this->v_ = new T[this->size_];
}
reAlloc(a.size_);
if (this->size_)
{
@ -484,7 +406,7 @@ void Foam::List<T>::operator=(const List<T>& a)
{
if (this == &a)
{
FatalErrorIn("List<T>::operator=(const List<T>&)")
FatalErrorInFunction
<< "attempted assignment to self"
<< abort(FatalError);
}
@ -497,13 +419,7 @@ void Foam::List<T>::operator=(const List<T>& a)
template<class T>
void Foam::List<T>::operator=(const SLList<T>& lst)
{
if (lst.size() != this->size_)
{
if (this->v_) delete[] this->v_;
this->v_ = 0;
this->size_ = lst.size();
if (this->size_) this->v_ = new T[this->size_];
}
reAlloc(lst.size());
if (this->size_)
{
@ -525,18 +441,8 @@ void Foam::List<T>::operator=(const SLList<T>& lst)
template<class T>
void Foam::List<T>::operator=(const IndirectList<T>& lst)
{
if (lst.size() != this->size_)
{
if (this->v_) delete[] this->v_;
this->v_ = 0;
this->size_ = lst.size();
if (this->size_) this->v_ = new T[this->size_];
}
forAll(*this, i)
{
this->operator[](i) = lst[i];
}
reAlloc(lst.size());
copyList(lst);
}
@ -544,18 +450,8 @@ void Foam::List<T>::operator=(const IndirectList<T>& lst)
template<class T>
void Foam::List<T>::operator=(const UIndirectList<T>& lst)
{
if (lst.size() != this->size_)
{
if (this->v_) delete[] this->v_;
this->v_ = 0;
this->size_ = lst.size();
if (this->size_) this->v_ = new T[this->size_];
}
forAll(*this, i)
{
this->operator[](i) = lst[i];
}
reAlloc(lst.size());
copyList(lst);
}
@ -563,18 +459,8 @@ void Foam::List<T>::operator=(const UIndirectList<T>& lst)
template<class T>
void Foam::List<T>::operator=(const BiIndirectList<T>& lst)
{
if (lst.size() != this->size_)
{
if (this->v_) delete[] this->v_;
this->v_ = 0;
this->size_ = lst.size();
if (this->size_) this->v_ = new T[this->size_];
}
forAll(*this, i)
{
this->operator[](i) = lst[i];
}
reAlloc(lst.size());
copyList(lst);
}
// * * * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * //

View file

@ -80,6 +80,27 @@ class List
public UList<T>
{
// Private member functions
//- Allocate list storage
inline void alloc();
//- Reallocate list storage to the given size
inline void reAlloc(const label s);
//- Copy list of given type
template<class List2>
inline void copyList(const List2&);
//- Allocate storage and copy list of given type
template<class List2>
inline void allocCopyList(const List2&);
//- Construct given start and end iterators and number of elements
template<class InputIterator>
inline List(InputIterator first, InputIterator last, const label s);
protected:
//- Override size to be inconsistent with allocated storage.
@ -118,7 +139,7 @@ public:
List(const Xfer< List<T> >&);
//- Construct as copy or re-use as specified.
List(List<T>&, bool reUse);
List(List<T>&, bool reuse);
//- Construct as subset.
List(const UList<T>&, const unallocLabelList& mapAddressing);
@ -184,8 +205,8 @@ public:
//- Reset size of List and value for new elements.
void setSize(const label, const T&);
//- Clear the list, i.e. set size to zero.
void clear();
//- Clear the list, i.e. set size to zero
inline void clear();
//- Append an element at the end of the list
inline void append(const T&);

View file

@ -23,6 +23,80 @@ License
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class T>
inline void Foam::List<T>::alloc()
{
if (this->size_ > 0)
{
this->v_ = new T[this->size_];
}
}
template<class T>
inline void Foam::List<T>::reAlloc(const label s)
{
if (this->size_ != s)
{
clear();
this->size_ = s;
alloc();
}
}
template<class T>
template<class List2>
inline void Foam::List<T>::copyList(const List2& lst)
{
if (this->size_)
{
forAll(*this, i)
{
this->operator[](i) = lst[i];
}
}
}
template<class T>
template<class List2>
inline void Foam::List<T>::allocCopyList(const List2& lst)
{
if (this->size_)
{
alloc();
copyList(lst);
}
}
template<class T>
template<class InputIterator>
inline Foam::List<T>::List
(
InputIterator first,
InputIterator last,
const label s
)
:
UList<T>(nullptr, s)
{
if (this->size_)
{
alloc();
InputIterator iter = first;
forAll(*this, i)
{
this->operator[](i) = *iter++;
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class T>
@ -46,6 +120,19 @@ inline const Foam::List<T>& Foam::List<T>::null()
}
template<class T>
inline void Foam::List<T>::clear()
{
if (this->v_)
{
delete[] this->v_;
this->v_ = 0;
}
this->size_ = 0;
}
template<class T>
inline void Foam::List<T>::resize(const label newSize)
{

View file

@ -170,7 +170,7 @@ receivePointField
outstandingSendRequest_ = -1;
outstandingRecvRequest_ = -1;
memcpy(tf().begin(), receiveBuf_.begin(), tf().byteSize());
memcpy(static_cast<void*>(tf().begin()), receiveBuf_.begin(), tf().byteSize());
}
else
{

View file

@ -107,7 +107,7 @@ void Foam::processorLduInterface::receive
}
else if (commsType == Pstream::nonBlocking)
{
memcpy(f.begin(), receiveBuf_.begin(), f.byteSize());
memcpy(static_cast<void*>(f.begin()), receiveBuf_.begin(), f.byteSize());
}
else
{

View file

@ -2,8 +2,8 @@
# For older versions of flex, the option --c++ is not avaliable
# Switching to flex++ is an alternative
#Ltoo = flex++ -f $$SOURCE ; mv lex.yy.cc $*.C ; $(CC) $(c++FLAGS) -c $*.C -o $@
Ltoo = flex -+ -f $$SOURCE ; mv lex.yy.cc $*.C ; $(CC) $(c++FLAGS) -c $*.C -o $@
#Ltoo = flex++ -f $$SOURCE ; mv lex.yy.cc $*.C ; $(CC) $(c++FLAGS) $(c++LESSWARN) -c $*.C -o $@
Ltoo = flex -+ -f $$SOURCE ; mv lex.yy.cc $*.C ; $(CC) $(c++FLAGS) $(c++LESSWARN) -c $*.C -o $@
.L.dep:
$(MAKE_DEP)

View file

@ -2,6 +2,9 @@
c++WARN = -Wall -Wextra -Wno-unused-parameter -Wold-style-cast
# Suppress some warnings for flex++ and CGAL
c++LESSWARN = -Wno-old-style-cast -Wno-unused-local-typedefs -Wno-array-bounds
CC = g++ -mabi=64
#CC = scg++ -mabi=64

View file

@ -2,6 +2,9 @@
c++WARN = -Wall -Wextra -Wno-unused-parameter -Wold-style-cast
# Suppress some warnings for flex++ and CGAL
c++LESSWARN = -Wno-old-style-cast -Wno-unused-local-typedefs -Wno-array-bounds
CC = g++ -m64
include $(RULES)/c++$(WM_COMPILE_OPTION)

View file

@ -2,6 +2,9 @@
c++WARN = -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor
# Suppress some warnings for flex++ and CGAL
c++LESSWARN = -Wno-old-style-cast -Wno-unused-local-typedefs -Wno-array-bounds
CC = g++ -std=c++11 -m64
include $(RULES)/c++$(WM_COMPILE_OPTION)

View file

@ -2,6 +2,9 @@
c++WARN = -wd327,584,654,819,1125,1476,1505,1572
# Suppress some warnings for flex++ and CGAL
c++LESSWARN = -diag-disable 1224,2026,2305
CC = icpc -DIntel
include $(RULES)/c++$(WM_COMPILE_OPTION)

View file

@ -2,6 +2,9 @@
c++WARN = -Wall -Wextra -Wno-unused-parameter -Wold-style-cast
# Suppress some warnings for flex++ and CGAL
c++LESSWARN = -Wno-old-style-cast -Wno-unused-local-typedefs -Wno-array-bounds
CC = g++ -std=c++11
include $(RULES)/c++$(WM_COMPILE_OPTION)

View file

@ -2,6 +2,9 @@
c++WARN = -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wno-undefined-var-template -Wno-deprecated-register -Wno-overloaded-virtual -Wno-null-dereference
# Suppress some warnings for flex++ and CGAL
c++LESSWARN = -Wno-old-style-cast -Wno-unused-local-typedefs -Wno-array-bounds
CC = armclang++ -std=c++11 -DARM_CLANG
include $(RULES)/c++$(WM_COMPILE_OPTION)

View file

@ -2,6 +2,9 @@
c++WARN = -Wall -Wextra -Wno-unused-parameter -Wold-style-cast
# Suppress some warnings for flex++ and CGAL
c++LESSWARN = -Wno-old-style-cast -Wno-unused-local-typedefs -Wno-array-bounds
CC = g++ -std=c++11
include $(RULES)/c++$(WM_COMPILE_OPTION)

View file

@ -2,6 +2,9 @@
c++WARN = -Wall -Wextra -Wno-unused-parameter -Wold-style-cast
# Suppress some warnings for flex++ and CGAL
c++LESSWARN = -Wno-old-style-cast -Wno-unused-local-typedefs -Wno-array-bounds
CC = g++ -std=c++11 -m32
include $(RULES)/c++$(WM_COMPILE_OPTION)

View file

@ -2,6 +2,9 @@
c++WARN = -Wall -Wextra -Wno-unused-parameter -Wold-style-cast
# Suppress some warnings for flex++ and CGAL
c++LESSWARN = -Wno-old-style-cast -Wno-unused-local-typedefs -Wno-array-bounds
CC = g++ -std=c++11
include $(RULES)/c++$(WM_COMPILE_OPTION)

View file

@ -2,6 +2,9 @@
c++WARN = -wd654,819,1125,1476,1505,1572
# Suppress some warnings for flex++ and CGAL
c++LESSWARN = -diag-disable 1224,2026,2305
CC = icpc -DIntel
include $(RULES)/c++$(WM_COMPILE_OPTION)

View file

@ -2,6 +2,9 @@
c++WARN = -wd327,654,819,1125,1476,1505,1572
# Suppress some warnings for flex++ and CGAL
c++LESSWARN = -diag-disable 1224,2026,2305
CC = icpc
include $(RULES)/c++$(WM_COMPILE_OPTION)

View file

@ -2,6 +2,9 @@
c++WARN = -wd654 -wd1125 -vec-report0
# Suppress some warnings for flex++ and CGAL
c++LESSWARN = -diag-disable 1224,2026,2305
CC = icpc -DIntel
include $(RULES)/c++$(WM_COMPILE_OPTION)

View file

@ -2,6 +2,9 @@
c++WARN = -Wall -Wextra -Wno-unused-parameter -Wold-style-cast
# Suppress some warnings for flex++ and CGAL
c++LESSWARN = -Wno-old-style-cast -Wno-unused-local-typedefs -Wno-array-bounds
CC = g++ -std=c++11 -m64 -mcpu=power5+
include $(RULES)/c++$(WM_COMPILE_OPTION)

View file

@ -2,6 +2,9 @@
c++WARN = -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor
# Suppress some warnings for flex++ and CGAL
c++LESSWARN = -Wno-old-style-cast -Wno-unused-local-typedefs -Wno-array-bounds
CC = g++ -std=c++11
include $(RULES)/c++$(WM_COMPILE_OPTION)

View file

@ -2,6 +2,9 @@
c++WARN = -Wall -Wextra -Wno-unused-parameter
# Suppress some warnings for flex++ and CGAL
c++LESSWARN =
CC = g++ -std=c++11
include $(RULES)/c++$(WM_COMPILE_OPTION)