Skip to content

deprecated attribute location

Summary

Location of FOAM_DEPRECATED and FOAM_DEPRECATED_FOR macros invocations is incorrect. It is placed between type and method name, while according to [1] it should be before type.

  1. https://en.cppreference.com/w/cpp/language/attributes/deprecated

Steps to reproduce

Build OpenFOAM v1912 with std=c++14. Yes, currently code should be built with std=c++11 but eventually it will be upgraded to newer standard.

Example case

This change resolve the issue (example from dictionary.H):

-        ITstream& FOAM_DEPRECATED_FOR(2018-07, "lookup() method")
-        operator[](const word& keyword) const
+        FOAM_DEPRECATED_FOR(2018-07, "lookup() method")
+        ITstream& operator[](const word& keyword) const

What is the current bug behaviour?

If code is compiled with std=c++14 current location of macros invocation produces the error:

~/OpenFOAM/OpenFOAM-v1912/src/OpenFOAM/lnInclude/SLListBase.H:223:18: error: 'deprecated' attribute cannot be applied to
      types
            bool FOAM_DEPRECATED_FOR(2019-01, "good() method") found() const
                 ^
~/OpenFOAM/OpenFOAM-v1912/src/OpenFOAM/lnInclude/stdFoam.H:59:52: note: expanded from macro 'FOAM_DEPRECATED_FOR'
# define FOAM_DEPRECATED_FOR(since, replacement) [[deprecated("Since " #since "; use " #replacement)]]

What is the expected correct behavior?

Compilation with correct location of the attribute does not produce error.

Environment information

  • OpenFOAM version : v1912
  • Operating system : macOS (10.15.4)
  • Hardware info : N/A
  • Compiler : Apple clang version 11.0.3 (clang-1103.0.32.29)

Possible fixes

Move macros invocation to correct location. See: deprecated-attribute.patch.