Skip to content

Commit

Permalink
Fix clang warning
Browse files Browse the repository at this point in the history
  • Loading branch information
Ravindu-Hirimuthugoda committed Jul 15, 2023
1 parent 8d69a25 commit 0ad07fa
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
17 changes: 15 additions & 2 deletions include/nomp-log.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,21 @@ int nomp_log_set_verbose(const int verbose);
int nomp_log_(const char *desc, int logno, nomp_log_type type,
const char *fname, unsigned line_no, ...);

#define nomp_log(logno, type, desc, ...) \
nomp_log_(desc, logno, type, __FILE__, __LINE__, ##__VA_ARGS__)
#define NOMP_CASE_IMPL(_1, _2, _3, _4, _5, _6, _7, _8, N, ...) N
#define NOMP_CASE(...) NOMP_CASE_IMPL(__VA_ARGS__, 2, 2, 2, 2, 2, 2, 2, 1, 0)

#define NOMP_FIRST_IMPL(first, ...) first
#define NOMP_FIRST(...) NOMP_FIRST_IMPL(__VA_ARGS__, throwaway)

#define NOMP_REST_IMPL_WITH_2(first, ...) , __VA_ARGS__
#define NOMP_REST_IMPL_WITH_1(first)
#define NOMP_REST_IMPL_(num, ...) NOMP_REST_IMPL_WITH_##num(__VA_ARGS__)
#define NOMP_REST_IMPL(num, ...) NOMP_REST_IMPL_(num, __VA_ARGS__)
#define NOMP_REST(...) NOMP_REST_IMPL(NOMP_CASE(__VA_ARGS__), __VA_ARGS__)

#define nomp_log(logno, type, ...) \
nomp_log_(NOMP_FIRST(__VA_ARGS__), logno, type, __FILE__, \
__LINE__ NOMP_REST(__VA_ARGS__))

/**
* @ingroup nomp_log_utils
Expand Down
4 changes: 2 additions & 2 deletions tests/nomp-api-105.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
// Calling nomp_jit() with valid functions should not return an error.
static int test_valid_clauses(void) {
int err = 0;
TEST_BUILTIN_TYPES(105_valid);
TEST_BUILTIN_TYPES(105_valid, );
return err;
}

// Calling nomp_jit() with invalid functions should return an error.
static int test_invalid_clauses(void) {
int err = 0;
TEST_BUILTIN_TYPES(105_invalid);
TEST_BUILTIN_TYPES(105_invalid, );
return err;
}

Expand Down
11 changes: 10 additions & 1 deletion tests/nomp-test.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,16 @@ inline static int subtest_(int err, const char *test_name) {
printf("\t%s: %s\033[0m\n", test_name, result);
return err;
}
#define SUBTEST(subtest, ...) subtest_(subtest(__VA_ARGS__), TOSTRING(subtest))
#define TEST_ARGS_CASE_IMPL(_1, _2, _3, _4, _5, _6, _7, _8, N, ...) N
#define TEST_ARGS_CASE(...) \
TEST_ARGS_CASE_IMPL(__VA_ARGS__, 2, 2, 2, 2, 2, 2, 2, 1, 0)

#define SUBTEST_IMPL_WITH_2(subtest, ...) \
subtest_(subtest(__VA_ARGS__), TOSTRING(subtest))
#define SUBTEST_IMPL_WITH_1(subtest) subtest_(subtest(), TOSTRING(subtest))
#define SUBTEST_IMPL_(num, ...) SUBTEST_IMPL_WITH_##num(__VA_ARGS__)
#define SUBTEST_IMPL(num, ...) SUBTEST_IMPL_(num, __VA_ARGS__)
#define SUBTEST(...) SUBTEST_IMPL(TEST_ARGS_CASE(__VA_ARGS__), __VA_ARGS__)

#define nomp_test_assert(cond) \
{ \
Expand Down

0 comments on commit 0ad07fa

Please sign in to comment.