mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
COMP: suppress false positives from -Wdangling-reference (gcc)
- the number of false positives has reduced, but in a few remaining
cases, the compiler cannot possibly "know" that the pointer stored
on the registry will outlive the scope of the method (for example)
gcc-13: suppressing these spurious warnings needs to be done at each
caller, which is simply not worth it, since later compiler versions
provide a cleaner solution.
gcc-14: the [[gnu::no_dangling]] attribute on the declaration
lets the compiler know the intent.
- additional FOAM_REAL_GNUC macro (defined in stdFoam.H) to define
the "real" gcc version and ignoring other compilers masquerading
as gcc.
COMP: rename MeshObject code to {cxx,txx}
- avoids issues on case-insensitive filesystems (#3316)
This commit is contained in:
@ -210,6 +210,7 @@ autoPtr<labelIOList> faProcAddressing
|
||||
|
||||
|
||||
// Return cached or read proc addressing from facesInstance
|
||||
FOAM_NO_DANGLING_REFERENCE
|
||||
const labelIOList& procAddressing
|
||||
(
|
||||
const PtrList<fvMesh>& procMeshList,
|
||||
|
||||
@ -587,7 +587,7 @@ meshes/Identifiers/surface/geometricSurfacePatch.C
|
||||
meshes/Identifiers/surface/surfZoneIdentifier.C
|
||||
meshes/Identifiers/zone/zoneIdentifier.C
|
||||
|
||||
meshes/MeshObject/meshObject.C
|
||||
meshes/MeshObject/meshObject.cxx
|
||||
|
||||
polyMesh = meshes/polyMesh
|
||||
|
||||
|
||||
@ -71,6 +71,21 @@ Description
|
||||
# define FOAM_LIKELY(cond) (cond)
|
||||
#endif
|
||||
|
||||
// Shadow macro for __GNUC__, excluding compilers masquerading as gcc
|
||||
#undef FOAM_REAL_GNUC
|
||||
#if defined(__GNUC__) && !defined(__llvm__)
|
||||
# define FOAM_REAL_GNUC __GNUC__
|
||||
#endif
|
||||
|
||||
// Suppress false positives from -Wdangling-reference (gcc >= 14)
|
||||
#if (FOAM_REAL_GNUC >= 14)
|
||||
# define FOAM_NO_DANGLING_REFERENCE [[gnu::no_dangling]]
|
||||
#endif
|
||||
|
||||
#ifndef FOAM_NO_DANGLING_REFERENCE
|
||||
#define FOAM_NO_DANGLING_REFERENCE
|
||||
#endif
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2024 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2025 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -168,10 +168,12 @@ public:
|
||||
|
||||
//- Get existing or create MeshObject registered with typeName
|
||||
template<class... Args>
|
||||
FOAM_NO_DANGLING_REFERENCE //< Reference stored in registry
|
||||
static const Type& New(const Mesh& mesh, Args&&... args);
|
||||
|
||||
//- Get existing or create MeshObject with given registration name
|
||||
template<class... Args>
|
||||
FOAM_NO_DANGLING_REFERENCE //< Reference stored in registry
|
||||
static const Type& New
|
||||
(
|
||||
const word& objName,
|
||||
@ -320,7 +322,7 @@ public:
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "MeshObject.C"
|
||||
#include "MeshObject.txx"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -1927,6 +1927,7 @@ public:
|
||||
);
|
||||
|
||||
//- Wrapper around dictionary::subDict which does not exit
|
||||
FOAM_NO_DANGLING_REFERENCE
|
||||
static const dictionary& subDict
|
||||
(
|
||||
const dictionary& dict,
|
||||
|
||||
@ -88,8 +88,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef mappedPatchBase_H
|
||||
#define mappedPatchBase_H
|
||||
#ifndef Foam_mappedPatchBase_H
|
||||
#define Foam_mappedPatchBase_H
|
||||
|
||||
#include "pointField.H"
|
||||
#include "Tuple2.H"
|
||||
@ -103,6 +103,7 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward Declarations
|
||||
class polyPatch;
|
||||
class polyMesh;
|
||||
class mapDistribute;
|
||||
@ -405,6 +406,7 @@ protected:
|
||||
|
||||
//- Lookup (sub)objectRegistry by following names of sub registries.
|
||||
//- Creates non-existing intermediate ones.
|
||||
FOAM_NO_DANGLING_REFERENCE
|
||||
static const objectRegistry& subRegistry
|
||||
(
|
||||
const objectRegistry& obr,
|
||||
@ -603,12 +605,12 @@ public:
|
||||
|
||||
// For database storage
|
||||
|
||||
inline const fileName& sampleDatabasePath() const
|
||||
const fileName& sampleDatabasePath() const
|
||||
{
|
||||
return *sampleDatabasePtr_;
|
||||
}
|
||||
|
||||
inline bool sampleDatabase() const
|
||||
bool sampleDatabase() const noexcept
|
||||
{
|
||||
return bool(sampleDatabasePtr_);
|
||||
}
|
||||
@ -630,6 +632,7 @@ public:
|
||||
|
||||
//- Lookup (sub)objectRegistry from '/' separated path (relative to
|
||||
//- objectRegistry). Creates non-existing intermediate ones.
|
||||
FOAM_NO_DANGLING_REFERENCE
|
||||
static const objectRegistry& subRegistry
|
||||
(
|
||||
const objectRegistry& obr,
|
||||
|
||||
@ -105,6 +105,7 @@ protected:
|
||||
// \return the coefficients dictionary found. If nothing was found,
|
||||
// return the enclosing dictionary or
|
||||
// dictionary::null (depending on the select parameter).
|
||||
FOAM_NO_DANGLING_REFERENCE
|
||||
static const dictionary& findCoeffsDict
|
||||
(
|
||||
const dictionary& dict,
|
||||
@ -124,6 +125,7 @@ protected:
|
||||
// \return the coefficients dictionary found. If nothing was found,
|
||||
// return the top-level (non-region) dictionary or
|
||||
// dictionary::null (depending on the select parameter).
|
||||
FOAM_NO_DANGLING_REFERENCE
|
||||
const dictionary& findCoeffsDict
|
||||
(
|
||||
const word& coeffsName,
|
||||
|
||||
Reference in New Issue
Block a user