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

Clang 19 -Wc++20-extensions warning #2910

Open
ChrisThrasher opened this issue Sep 24, 2024 · 0 comments · May be fixed by #2934
Open

Clang 19 -Wc++20-extensions warning #2910

ChrisThrasher opened this issue Sep 24, 2024 · 0 comments · May be fixed by #2934

Comments

@ChrisThrasher
Copy link
Collaborator

ChrisThrasher commented Sep 24, 2024

Describe the bug
Clang reports a -Wc++20-extensions warning when expanding the TEMPLATE_TEST_CASE macro with the following message

/Users/thrasher/Projects/Catch2/tests/SelfTest/IntrospectiveTests/FloatingPoint.tests.cpp:27:1: error: passing no argument for the '...' parameter of a variadic macro is a C++20 extension [-Werror,-Wc++20-extensions]
   27 | TEMPLATE_TEST_CASE("type-shared ulpDistance tests", "[floating-point][ulp][approvals]", float, double) {
      | ^
/Users/thrasher/Projects/Catch2/src/catch2/../catch2/catch_template_test_macros.hpp:76:39: note: expanded from macro 'TEMPLATE_TEST_CASE'
   76 |     #define TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ )
      |                                       ^
/Users/thrasher/Projects/Catch2/src/catch2/../catch2/internal/catch_template_test_registry.hpp:104:9: note: expanded from macro 'INTERNAL_CATCH_TEMPLATE_TEST_CASE'
  104 |         INTERNAL_CATCH_TEMPLATE_TEST_CASE_2( INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEMPLATE_TEST_ ), INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEMPLATE_TEST_ ), Name, Tags, typename TestType, __VA_ARGS__ )
      |         ^
/Users/thrasher/Projects/Catch2/src/catch2/../catch2/internal/catch_template_test_registry.hpp:82:13: note: expanded from macro 'INTERNAL_CATCH_TEMPLATE_TEST_CASE_2'
   82 |             INTERNAL_CATCH_NTTP_GEN(INTERNAL_CATCH_REMOVE_PARENS(Signature))\
      |             ^
/Users/thrasher/Projects/Catch2/src/catch2/../catch2/internal/catch_preprocessor.hpp:217:465: note: expanded from macro 'INTERNAL_CATCH_NTTP_GEN'
  217 | #define INTERNAL_CATCH_NTTP_GEN(...) INTERNAL_CATCH_VA_NARGS_IMPL(__VA_ARGS__, INTERNAL_CATCH_NTTP_1(__VA_ARGS__), INTERNAL_CATCH_NTTP_1(__VA_ARGS__), INTERNAL_CATCH_NTTP_1(__VA_ARGS__), INTERNAL_CATCH_NTTP_1(__VA_ARGS__), INTERNAL_CATCH_NTTP_1(__VA_ARGS__), INTERNAL_CATCH_NTTP_1( __VA_ARGS__), INTERNAL_CATCH_NTTP_1( __VA_ARGS__), INTERNAL_CATCH_NTTP_1( __VA_ARGS__), INTERNAL_CATCH_NTTP_1( __VA_ARGS__),INTERNAL_CATCH_NTTP_1( __VA_ARGS__), INTERNAL_CATCH_NTTP_0)
      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 ^
/Users/thrasher/Projects/Catch2/src/catch2/../catch2/internal/catch_preprocessor.hpp:100:9: note: macro 'INTERNAL_CATCH_VA_NARGS_IMPL' defined here
  100 | #define INTERNAL_CATCH_VA_NARGS_IMPL(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N
      |         ^

Reproduction steps
I'm using the all-tests preset with Clang 19 as provided by Homebrew. I also encounter this issue when consuming Catch2 via FetchContent for use in various other projects.

Platform information:

  • OS: macOS 15
  • Compiler+version: Clang 19.1.0
  • Catch version: v3.7.1 fa43b77429ba76c462b1898d6cd2f2d7a9416b14
abhishekbelgaonkar23 added a commit to abhishekbelgaonkar23/Catch2 that referenced this issue Nov 16, 2024
-Added INTERNAL_CATCH_TEMPLATE_TEST_CASE_HANDLE_EMPTY macro for Clang 19+
- Modified template test case macro expansion path for Clang 19+
- Keeps original behavior for other compilers and older Clang versions
abhishekbelgaonkar23 added a commit to abhishekbelgaonkar23/Catch2 that referenced this issue Nov 16, 2024
…chorg#2910)

- Added INTERNAL_CATCH_TEMPLATE_TEST_CASE_HANDLE_EMPTY macro for Clang 19+
- Modified template test case macro expansion path for Clang 19+
- Keeps original behavior for other compilers and older Clang versions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants