Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warning: function 'DeepState_Run_TestCaseName_TestName' could be declared with attribute 'noreturn' #357

Open
disconnect3d opened this issue Jul 23, 2020 · 0 comments

Comments

@disconnect3d
Copy link
Member

Tl;dr: building a simple DeepState testcase as shown below, gives the -Wmissing-noreturn warning. This might be an issue if DeepState is incorporated into a codebase that uses -Werror.

Example code

#include <deepstate/DeepState.hpp>

using namespace deepstate;

TEST(TestCaseName, TestName) {
        ASSERT(1);
}

Related build log

[1/2] Building CXX object tests/deepstate/initial/CMakeFiles/tests.deepstate.initial.dir/InitialTests.cpp.o
../tests/deepstate/initial/InitialTests.cpp:5:1: warning: function 'DeepState_Run_TestCaseName_TestName' could be declared with attribute 'noreturn' [-Wmissing-noreturn]
TEST(TestCaseName, TestName) {
^
/usr/local/include/deepstate/DeepState.hpp:679:5: note: expanded from macro 'TEST'
    DeepState_EntryPoint(category ## _ ## name)
    ^
/usr/local/include/deepstate/DeepState.h:522:5: note: expanded from macro 'DeepState_EntryPoint'
    _DeepState_EntryPoint(test_name, __FILE__, __LINE__)
    ^
/usr/local/include/deepstate/DeepState.h:553:52: note: expanded from macro '_DeepState_EntryPoint'
    static void DeepState_Run_ ## test_name (void) { \
                                                   ^
1 warning generated.

Notes

It could somehow be related to my build system, but it would be worth investigating if a bare/example project that uses DeepState gives this warning when built with -Wmissing-noreturn.

The related code seems to be here:

#define _DeepState_EntryPoint(test_name, file, line) \
static void DeepState_Test_ ## test_name (void); \
static void DeepState_Run_ ## test_name (void) { \
DeepState_Test_ ## test_name(); \
DeepState_Pass(); \
} \
static struct DeepState_TestInfo DeepState_Info_ ## test_name = { \
NULL, \
DeepState_Run_ ## test_name, \
DEEPSTATE_TO_STR(test_name), \
file, \
line, \
}; \
DEEPSTATE_INITIALIZER(DeepState_Register_ ## test_name) { \
DeepState_Info_ ## test_name.prev = DeepState_LastTestInfo; \
DeepState_LastTestInfo = &(DeepState_Info_ ## test_name); \
} \
void DeepState_Test_ ## test_name(void)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant