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

TEST_CASE_TEMPLATE causes "-Wunused-local-typedef" warning on Clang #577

Closed
helmesjo opened this issue Jan 7, 2022 · 1 comment
Closed

Comments

@helmesjo
Copy link

helmesjo commented Jan 7, 2022

Description

Building with -Wall on Clang (tested on 13.0) causes warning -Wunused-local-typedef to trigger when a TEST_CASE_TEMPLATE_INVOKE is placed inside a SCENARIO scope:

TEST_CASE_TEMPLATE_DEFINE("test", type_t, test_template)
{
}

SCENARIO("scenario")
{
    TEST_CASE_TEMPLATE_INVOKE(test_template, int); // Warning: `-Wunused-local-typedef`
}
TEST_CASE_TEMPLATE_INVOKE(test_template, int); // No warning
<source>:10:5: error: unused typedef 'DOCTEST_ANON_FOR_SEMICOLON_12' [-Werror,-Wunused-local-typedef]
    TEST_CASE_TEMPLATE_INVOKE(test_template, int);
    ^
/opt/compiler-explorer/libs/doctest/trunk/doctest/doctest.h:2647:44: note: expanded from macro 'TEST_CASE_TEMPLATE_INVOKE'
#define TEST_CASE_TEMPLATE_INVOKE(id, ...) DOCTEST_TEST_CASE_TEMPLATE_INVOKE(id, __VA_ARGS__)
                                           ^
/opt/compiler-explorer/libs/doctest/trunk/doctest/doctest.h:2052:17: note: expanded from macro 'DOCTEST_TEST_CASE_TEMPLATE_INVOKE'
    typedef int DOCTEST_ANONYMOUS(DOCTEST_ANON_FOR_SEMICOLON_)
                ^
/opt/compiler-explorer/libs/doctest/trunk/doctest/doctest.h:347:30: note: expanded from macro 'DOCTEST_ANONYMOUS'
#define DOCTEST_ANONYMOUS(x) DOCTEST_CAT(x, __COUNTER__)
                             ^
/opt/compiler-explorer/libs/doctest/trunk/doctest/doctest.h:345:29: note: expanded from macro 'DOCTEST_CAT'
#define DOCTEST_CAT(s1, s2) DOCTEST_CAT_IMPL(s1, s2)
                            ^
/opt/compiler-explorer/libs/doctest/trunk/doctest/doctest.h:344:34: note: expanded from macro 'DOCTEST_CAT_IMPL'
#define DOCTEST_CAT_IMPL(s1, s2) s1##s2
                                 ^
<scratch space>:392:1: note: expanded from here
DOCTEST_ANON_FOR_SEMICOLON_12
^

Reason I put it inside the SCENARIO scope is just to keep things organized.

Steps to reproduce

Repo-case

Extra information

Locally it triggers on GCC (11.2) as well, but not on godbolt for whatever reason.

  • doctest version: v2.4.7
  • Operating System: Ubuntu
  • Compiler+version: Clang 13.0
@onqtam
Copy link
Member

onqtam commented Jan 10, 2022

fixed in dev!

@onqtam onqtam closed this as completed Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants