Skip to content

atf-c/macros/use: fails with clang -Wunused on FreeBSD head #8

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

Closed
ngie-eign opened this issue Jun 13, 2014 · 2 comments
Closed

atf-c/macros/use: fails with clang -Wunused on FreeBSD head #8

ngie-eign opened this issue Jun 13, 2014 · 2 comments
Labels

Comments

@ngie-eign
Copy link
Contributor

Both the base and port testcases for atf appear to be failing on FreeBSD CURRENT because of clang -Wunused ( http://kyua3.nyi.freebsd.org/head/data/0-LATEST/results/local_atf_atf-c_macros_test_use.html ):

/usr/tests/local/atf/atf-c/macros_h_test.c:86:1: error: unused variable 'atfu_TEST_MACRO_1_tc_pack' [-Werror,-Wunused-const-variable]
ATF_TC(TEST_MACRO_1);
^
/usr/local/include/atf-c/macros.h:61:26: note: expanded from macro 'ATF_TC'
    static atf_tc_pack_t atfu_ ## tc ## _tc_pack = { \
                         ^
:41:1: note: expanded from here
atfu_TEST_MACRO_1_tc_pack
^
/usr/tests/local/atf/atf-c/macros_h_test.c:92:1: error: unused variable 'atfu_TEST_MACRO_2_tc_pack' [-Werror,-Wunused-const-variable]
ATF_TC_WITH_CLEANUP(TEST_MACRO_2);
^
/usr/local/include/atf-c/macros.h:73:26: note: expanded from macro 'ATF_TC_WITH_CLEANUP'
    static atf_tc_pack_t atfu_ ## tc ## _tc_pack = { \
                         ^
:66:1: note: expanded from here
atfu_TEST_MACRO_2_tc_pack
^
/usr/tests/local/atf/atf-c/macros_h_test.c:100:1: error: unused variable 'atfu_TEST_MACRO_3_tc_pack' [-Werror,-Wunused-const-variable]
ATF_TC_WITHOUT_HEAD(TEST_MACRO_3);
^
/usr/local/include/atf-c/macros.h:50:26: note: expanded from macro 'ATF_TC_WITHOUT_HEAD'
    static atf_tc_pack_t atfu_ ## tc ## _tc_pack = { \
                         ^
:93:1: note: expanded from here
atfu_TEST_MACRO_3_tc_pack
^
3 errors generated.
cc failed with exit code 1

The code will probably need to be modified to use the variable, or to just add __attribute__((__unused__)) around the declaration.

@ngie-eign
Copy link
Contributor Author

Confirmed that it's still occurring with handrolled copy of atf via bd96595.

@jmmv jmmv added the bug label Jul 24, 2014
@jmmv
Copy link
Member

jmmv commented Jul 24, 2014

Oh wow, I wonder how this went unnoticed for so long. Seems a legitimate problem with the tests but I haven't tried to reproduce yet. Bleh, different warning diagnostics across different compilers.

Adding __attribute__((__unused__)) is going to be tricky because the code triggering the problem comes from within macros.

The easiest way out, I think, would be to actually put the unused variables to use by referencing them. Doing something like:

atf_tc_pack_t *test_pack_1 = ATF_TC_PACK_NAME(TEST_MACRO_1)

should do the trick. The trick is to not make pack1 static so that the compiler can't tell it's not being used (just as we do with test_name_1).

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

No branches or pull requests

2 participants