Skip to content
Snippets Groups Projects
Commit 77879685 authored by Mark OLESEN's avatar Mark OLESEN
Browse files

CONFIG: enable use of stricter deprecation warnings

- selected with '+strict' in WM_COMPILE_CONTROL or 'wmake -strict', it
  enables the FOAM_DEPRECATED_STRICT() macro, which can be used to
  mark methods that are implicitly deprecated, but are not yet marked
  as full deprecated (eg, API modification is too recent, generates
  too many warnings).  Can be considered a developer option.
parent 224c3199
No related branches found
No related tags found
No related merge requests found
......@@ -55,7 +55,7 @@ public:
i_(i)
{}
word& keyword() const noexcept { return keyword_; }
const word& keyword() const noexcept { return keyword_; }
friend Ostream& operator<<(Ostream& os, const ent& e)
{
......@@ -113,7 +113,7 @@ int main(int argc, char *argv[])
dict.swapDown(dict.first());
forAllConstIter(Dictionary<ent>, dict, iter)
forAllConstIters(dict, iter)
{
Info<< "element : " << *iter;
}
......@@ -153,9 +153,9 @@ int main(int argc, char *argv[])
}
Info<< nl << "scalarDict1: " << endl;
forAllConstIter(PtrDictionary<Scalar>, scalarDict, iter)
forAllConstIters(scalarDict, iter)
{
Info<< " = " << iter() << endl;
Info<< " = " << *iter << endl;
}
PtrDictionary<Scalar> scalarDict2;
......@@ -165,7 +165,7 @@ int main(int argc, char *argv[])
scalarDict2.insert(key, new Scalar(1.3*i));
}
Info<< nl << "scalarDict2: " << endl;
forAllConstIter(PtrDictionary<Scalar>, scalarDict2, iter)
forAllConstIters(scalarDict2, iter)
{
std::cout<< "iter: " << typeid(*iter).name() << '\n';
......
......@@ -51,10 +51,7 @@ public:
i_(i)
{}
const word& keyword() const
{
return keyword_;
}
const word& keyword() const noexcept { return keyword_; }
friend Ostream& operator<<(Ostream& os, const ent& e)
{
......@@ -83,7 +80,7 @@ int main(int argc, char *argv[])
dict.swapDown(dict.first());
forAllConstIter(UDictionary<ent>, dict, iter)
forAllConstIters(dict, iter)
{
Info<< "element : " << *iter;
}
......
......@@ -110,6 +110,13 @@ public:
//- Destructor
~IFstreamDelayed() = default;
// Testing deprecation warnings
FOAM_DEPRECATED_STRICT(2023-08, "direct calling")
Istream& operator()() const
{
return const_cast<IFstreamDelayed&>(*this);
}
};
......@@ -281,6 +288,9 @@ int main(int argc, char *argv[])
IFstreamDelayed is(args[argi]);
// Trigger strict warning?
Info<< "stream: " << is().name() << nl;
dictionary dict(is);
Info<< "read: " << dict << nl;
......
......@@ -92,6 +92,7 @@ export WM_COMPILE_OPTION=Opt
# ~openmp : without openmp
# +ccache : use ccache
# +xcrun : use xcrun and native compilers [MacOS]
# +strict : more deprecation warnings (may generate *many* warnings)
# ccache=... : ccache command (unquoted, single/double or <> quoted)
# version=... : compiler suffix (eg, "11" for gcc-11)
#export WM_COMPILE_CONTROL="+gold"
......
......@@ -284,6 +284,6 @@ _of_complete_cache_[XiEngineFoam]="-case -decomposeParDict -fileHandler -world |
_of_complete_cache_[XiFoam]="-case -decomposeParDict -fileHandler -world | -dry-run -dry-run-write -listFunctionObjects -listFvOptions -listRegisteredSwitches -listScalarBCs -listSwitches -listTurbulenceModels -listUnsetSwitches -listVectorBCs -mpi-threads -noFunctionObjects -parallel -postProcess -doc -help"
_of_complete_cache_[zipUpMesh]="-case -decomposeParDict -fileHandler -region -world | -mpi-threads -noFunctionObjects -parallel -doc -help"
_of_complete_cache_[paraFoam]="-case -region | -block -vtk -touch -touch-all -touch-proc -plugin-path= -help"
_of_complete_cache_[wmake]=" | -s -a -q -k -j -update -debug -debug-O[g0123] -build-root= -module-prefix= -module-prefix= -no-openfoam -openmp -no-openmp -no-scheduler -show-api -show-ext-so -show-c -show-cflags -show-cxx -show-cxxflags -show-cflags-arch -show-cxxflags-arch -show-compile-c -show-compile-cxx -show-path-c -show-path-cxx -show-mpi-compile -show-mpi-link -show-openmp-compile -show-openmp-link -pwd -version -help"
_of_complete_cache_[wmake]=" | -s -a -q -k -j -update -debug -debug-O[g0123] -strict -build-root= -module-prefix= -module-prefix= -no-openfoam -openmp -no-openmp -no-scheduler -show-api -show-ext-so -show-c -show-cflags -show-cxx -show-cxxflags -show-cflags-arch -show-cxxflags-arch -show-compile-c -show-compile-cxx -show-path-c -show-path-cxx -show-mpi-compile -show-mpi-link -show-openmp-compile -show-openmp-link -pwd -version -help"
#------------------------------------------------------------------------------
......@@ -92,6 +92,7 @@ setenv WM_COMPILE_OPTION Opt
# ~openmp : without openmp
# +ccache : use ccache
# +xcrun : use xcrun and native compilers [MacOS]
# +strict : more deprecation warnings (may generate *many* warnings)
# ccache=... : ccache command (unquoted, single/double or <> quoted)
# version=... : compiler suffix (eg, "11" for gcc-11)
#setenv WM_COMPILE_CONTROL "+gold"
......
......@@ -46,12 +46,19 @@ Description
#if (__cplusplus >= 201402L)
# define FOAM_DEPRECATED(since) [[deprecated("Since " #since)]]
# define FOAM_DEPRECATED_FOR(since, replacement) [[deprecated("Since " #since "; use " #replacement)]]
# define FOAM_DEPRECATED_STRICT(since, replacement) [[deprecated("Since " #since "; use " #replacement)]]
#elif defined(__GNUC__)
# define FOAM_DEPRECATED(since) __attribute__((__deprecated__("Since " #since)))
# define FOAM_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement)))
# define FOAM_DEPRECATED_STRICT(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement)))
#else
# define FOAM_DEPRECATED(since)
# define FOAM_DEPRECATED_FOR(since, replacement)
# define FOAM_DEPRECATED_STRICT(since, replacement)
#endif
#ifndef FOAM_COMPILE_STRICT
# undef FOAM_DEPRECATED_STRICT
# define FOAM_DEPRECATED_STRICT(since, replacement)
#endif
// Compile-time warning about unused result
......
......@@ -32,6 +32,11 @@ else
COMPILER_VERSION :=
endif
# Enable additional compile-time checks
ifneq (,$(findstring +strict,$(WM_COMPILE_CONTROL)))
GFLAGS += -DFOAM_COMPILE_STRICT
endif
# Default compilation is 'Opt' - never permit an empty value
ifeq (,$(strip $(WM_COMPILE_OPTION)))
WM_COMPILE_OPTION := Opt
......
......@@ -6,7 +6,7 @@
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2014-2017 OpenFOAM Foundation
# Copyright (C) 2019-2022 OpenCFD Ltd.
# Copyright (C) 2019-2023 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
......@@ -26,7 +26,8 @@
# -j | -jN | -j N
#
# Parsed options (wmake)
# -debug
# -debug | -debug-O[g0123]
# -strict
# -q | -queue
# -build-root=...
# Exports FOAM_BUILDROOT value.
......@@ -87,7 +88,7 @@ USAGE
#------------------------------------------------------------------------------
unset wmakeOpt_frontend wmakeOpt_nonRecursive
unset wmakeOpt_debug wmakeOpt_log wmakeOpt_queue
unset wmakeOpt_debug wmakeOpt_log wmakeOpt_strict wmakeOpt_queue
for arg in "$@"
do
......@@ -178,6 +179,11 @@ do
continue # Argument handled, remove it
;;
-strict)
wmakeOpt_strict="$arg"
continue # Argument handled, remove it
;;
-q | -queue)
wmakeOpt_queue="-queue"
continue # Argument handled, remove it
......@@ -203,13 +209,13 @@ then
if [ -z "$wmakeOpt_log" ]
then
exec wmake $wmakeOpt_frontend -all \
$wmakeOpt_debug $wmakeOpt_queue $wmakeOpt_openmp $*
$wmakeOpt_debug $wmakeOpt_strict $wmakeOpt_queue $wmakeOpt_openmp $*
exit $? # Unneeded, but just in case something went wrong
else
echo "Logging wmake -all output to '$wmakeOpt_log'" 1>&2
echo 1>&2
exec wmake $wmakeOpt_frontend -all \
$wmakeOpt_debug $wmakeOpt_queue $wmakeOpt_openmp $* 2>&1 | \
$wmakeOpt_debug $wmakeOpt_strict $wmakeOpt_queue $wmakeOpt_openmp $* 2>&1 | \
/usr/bin/tee $wmakeOpt_log
# Need to cleanup after the tee
rc=$? # Error code from tee (not wmake), but not entirely important
......@@ -234,7 +240,7 @@ fi
#------------------------------------------------------------------------------
unset wmakeOpt_frontend wmakeOpt_nonRecursive
unset wmakeOpt_debug wmakeOpt_log wmakeOpt_queue
unset wmakeOpt_debug wmakeOpt_log wmakeOpt_strict wmakeOpt_queue
unset -f usage
......
......@@ -7,7 +7,7 @@
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2017-2022 OpenCFD Ltd.
# Copyright (C) 2017-2023 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
......@@ -71,6 +71,7 @@ then
cat<<HELP_FULL
-debug Add '-g -DFULLDEBUG' flags
-debug-O[g0123] Add '-g -DFULLDEBUG' flags and optimization level
-strict More deprecation warnings ('+strict' WM_COMPILE_CONTROL)
-build-root=PATH Specify FOAM_BUILDROOT for compilation intermediates
-module-prefix=PATH Specify FOAM_MODULE_PREFIX as absolute/relative path
-module-prefix=TYPE Specify FOAM_MODULE_PREFIX as predefined type
......@@ -209,7 +210,7 @@ allCores()
# Default to compiling the local target only
unset opt_all opt_update opt_quiet opt_show opt_pwd
unset opt_debug opt_openmp opt_openfoam
unset opt_debug opt_openmp opt_openfoam opt_strict
# Consistency with inherited values
if [ "$WM_QUIET" = true ]
......@@ -267,6 +268,10 @@ do
opt_debug="-g -${1##*-}"
;;
-strict)
opt_strict="+strict"
;;
-build-root=*)
export FOAM_BUILDROOT="${1#*=}"
echo "Build-root = ${FOAM_BUILDROOT:-[]}" 1>&2
......@@ -520,6 +525,22 @@ case "$opt_openfoam" in
;;
esac
# Handle -strict flag(s)
if [ -n "$opt_strict" ]
then
# Add +strict into WM_COMPILE_CONTROL
opt_strict="${WM_COMPILE_CONTROL:+ }+strict"
case "$WM_COMPILE_CONTROL" in
(*+strict*)
# Appears to have already been added
;;
(*)
export WM_COMPILE_CONTROL="${WM_COMPILE_CONTROL}${opt_strict}"
;;
esac
fi
# Debug:
##echo "WM_COMPILE_CONTROL='$WM_COMPILE_CONTROL'" 1>&2
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment