approvals / ApprovalTests.cpp

Native ApprovalTests for C++ on Linux, Mac and Windows
https://approvaltestscpp.readthedocs.io/en/latest/
Apache License 2.0
316 stars 51 forks source link

With C++14 and above, CombinationApprovals does not compile if deprecation warnings enabled #132

Closed claremacrae closed 4 years ago

claremacrae commented 4 years ago

In the v.8.7.0 release, if deprecation warnings are enabled, for C++14 and above, we get a compilation error because [[deprecated]] is put in the wrong place:

In file included from ...ApprovalTests.cpp/examples/doctest_existing_main/DeprecatedCombinationApprovalsTests.cpp:7:
...ApprovalTests.cpp/ApprovalTests/../ApprovalTests/CombinationApprovals.h:85:16:
error: an attribute list cannot appear here
        static APPROVAL_TESTS_DEPRECATED_USE_OPTIONS void
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...ApprovalTests.cpp/ApprovalTests/../ApprovalTests/utilities/Macros.h:35:5:
note: expanded from macro 'APPROVAL_TESTS_DEPRECATED_USE_OPTIONS'
    APPROVAL_TESTS_DEPRECATED(                                                           \
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...ApprovalTests.cpp/ApprovalTests/../ApprovalTests/utilities/Macros.h:22:41:
note: expanded from macro 'APPROVAL_TESTS_DEPRECATED'
#define APPROVAL_TESTS_DEPRECATED(text) [[deprecated(text)]]
                                        ^~~~~~~~~~~~~~~~~~~~

Steps to reproduce:

  1. Edit examples/doctest_existing_main/DeprecationDefines.h and change APPROVAL_TESTS_SHOW_DEPRECATION_WARNINGS to 1
  2. Edit examples/doctest_existing_main/CMakeLists.txt and change CMAKE_CXX_STANDARD to 14
  3. Make sure CMake re-ran
  4. Build doctest_existing_main

The above compilation failure will then happen.