Catch2 icon indicating copy to clipboard operation
Catch2 copied to clipboard

silence clang's `-Wcomma`

Open timblechmann opened this issue 3 years ago • 5 comments

timblechmann avatar Oct 06 '22 02:10 timblechmann

Codecov Report

Merging #2543 (289d254) into devel (728de35) will decrease coverage by 0.01%. The diff coverage is n/a.

@@            Coverage Diff             @@
##            devel    #2543      +/-   ##
==========================================
- Coverage   91.58%   91.57%   -0.01%     
==========================================
  Files         183      183              
  Lines        7564     7564              
==========================================
- Hits         6927     6926       -1     
- Misses        637      638       +1     

codecov[bot] avatar Oct 06 '22 03:10 codecov[bot]

Can you provide an example of when this warning triggers?

horenmar avatar Oct 08 '22 16:10 horenmar

my code looks like this:

#include <catch2/catch_template_test_macros.hpp>

namespace a::b::c {

struct foo {};

using tests = std::tuple< foo >;

TEMPLATE_LIST_TEST_CASE( "test", "", tests )
{}

} // namespace a::b::c

(it seems to be triggered by putting the TEMPLATE_LIST_TEST_CASE macro into the namespace)

timblechmann avatar Oct 09 '22 00:10 timblechmann

I tried to quickly reproduce this on godbolt, but can't.

Given that this PR would silence -Wcomma for the entire test case code, including user's code, I do not want to merge it without a reproducer to see what the issue actually is, and that it is part of our code (as opposed to user code, whose warnings we should not touch.).

horenmar avatar Oct 17 '22 15:10 horenmar

i've tried to reproduce it again. it seems to be triggered by using a clang icecc toolchain with local proprocessing. so probably the namespace was a red herring.

fwiw, the offending comma is this one

Catch::NameAndTags{ "test" " - " + std::string("tests") + " - " + std::to_string(index), "" } ), index++)... }; } }
                                                                                               ^

timblechmann avatar Oct 17 '22 16:10 timblechmann

Hi, sorry for not getting to this earlier. I thought the changes would silence -Wcomma in the test code as well, so I put it in my backlog to return to later.

Today I did, and turns out that suppression is already limited to the registration only.

horenmar avatar Nov 14 '22 12:11 horenmar