1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0030448: Coding - add typo detection to derivation creation methods using Standard_NODISCARD attribute

Added macro Standard_NODISCARD equivalent to C++17 attribute [[nodiscard]] for compilers that support this.
Using Standard_NODISCARD macro for methods that create new object in gp, math, Geom, Bnd packages.
Marked equivalent operators with Standard_NODISCARD, if they are defined close to relevant methods.

Corrected code where warnings on unused result of calls to methods creating new objects are generated.
In most cases it looks like spelling errors (e.g. Normalised() instead of Normalise())
This commit is contained in:
Benjamin Bihler
2019-02-25 12:52:01 +03:00
committed by apn
parent 1c8fc6bee2
commit 0be7dbe183
70 changed files with 454 additions and 431 deletions

View File

@@ -57,6 +57,28 @@
#define Standard_FALLTHROUGH
#endif
//! @def Standard_NODISCARD
//! This attribute may appear in a function declaration,
//! enumeration declaration or class declaration. It tells the compiler to
//! issue a warning, if a return value marked by that attribute is discarded.
//!
//! Expands to C++17 attribute statement "[[nodiscard]]" on compilers that
//! declare support of this attribute, or equivalent attribute on GCC.
#if defined(__has_cpp_attribute)
#if __has_cpp_attribute(nodiscard)
#define Standard_NODISCARD [[nodiscard]]
#else
#define Standard_NODISCARD
#endif
#elif defined(__GNUC__) && ! defined(INTEL_COMPILER)
// According to available documentation, GCC-style __attribute__ ((warn_unused_result))
// should be available in GCC since version 3.4, and in CLang since 3.9;
// Intel compiler does not seem to support this
#define Standard_NODISCARD __attribute__ ((warn_unused_result))
#else
#define Standard_NODISCARD
#endif
//! @def Standard_UNUSED
//! Macro for marking variables / functions as possibly unused
//! so that compiler will not emit redundant "unused" warnings.