Skip to content

Commit 9bd67c2

Browse files
jplehrillsilin
andauthored
[CK-TILE] Guard against compiler lexer diagnostic (#3444)
* [CK-TILE] Guard against compiler lexer diagnostic A recent change to Clang added a lexer-level diagnostic about that C2y language feature. Since that is lexer level, the `__extension__` compiler built-in does not work as it is only respected *after* the lexer when parsing. This change adds guarding pragmas to disable the diagnostic in the lexer and not lead to warnings being treated as errors. * Fixing still existing build issue Once the one warning was removed, another one poppoed up. Both are related to the same c2y feature. Thus, ignoring both. * clang-format handling --------- Co-authored-by: Illia Silin <98187287+illsilin@users.noreply.github.com>
1 parent cbc8335 commit 9bd67c2

2 files changed

Lines changed: 32 additions & 11 deletions

File tree

include/ck_tile/core/utility/static_counter.hpp

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,30 @@ template <int I>
101101
struct static_counter_uniq_;
102102
}
103103

104-
#define MAKE_SC() \
105-
__extension__ ck_tile::static_counter<ck_tile::impl::static_counter_uniq_<__COUNTER__>> {}
104+
// clang-format off
105+
#define MAKE_SC() \
106+
_Pragma("clang diagnostic push") \
107+
_Pragma("clang diagnostic ignored \"-Wpre-c2y-compat\"") \
108+
_Pragma("clang diagnostic ignored \"-Wc2y-extensions\"") \
109+
ck_tile::static_counter<ck_tile::impl::static_counter_uniq_<__COUNTER__>>{} \
110+
_Pragma("clang diagnostic pop")
106111
#define MAKE_SC_WITH(start_, step_) \
107-
__extension__ ck_tile:: \
108-
static_counter<ck_tile::impl::static_counter_uniq_<__COUNTER__>, start_, step_> \
109-
{ \
110-
}
111-
#define NEXT_SC(c_) __extension__ c_.next<__COUNTER__>()
112-
#define NEXT_SCI(c_, static_i_) __extension__ c_.next<__COUNTER__ + static_i_>()
112+
_Pragma("clang diagnostic push") \
113+
_Pragma("clang diagnostic ignored \"-Wpre-c2y-compat\"") \
114+
_Pragma("clang diagnostic ignored \"-Wc2y-extensions\"") ck_tile:: \
115+
static_counter<ck_tile::impl::static_counter_uniq_<__COUNTER__>, start_, step_>{} \
116+
_Pragma("clang diagnostic pop")
117+
#define NEXT_SC(c_) \
118+
_Pragma("clang diagnostic push") \
119+
_Pragma("clang diagnostic ignored \"-Wpre-c2y-compat\"") \
120+
_Pragma("clang diagnostic ignored \"-Wc2y-extensions\"") c_.next<__COUNTER__>() \
121+
_Pragma("clang diagnostic pop")
122+
#define NEXT_SCI(c_, static_i_) \
123+
_Pragma("clang diagnostic push") \
124+
_Pragma("clang diagnostic ignored \"-Wpre-c2y-compat\"") \
125+
_Pragma("clang diagnostic ignored \"-Wc2y-extensions\"") \
126+
c_.next<__COUNTER__ + static_i_>() _Pragma("clang diagnostic pop")
127+
// clang-format on
113128

114129
// Usage:
115130
// constexpr auto c = MAKE_SC()

profiler/src/profiler_operation_registry.hpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ class ProfilerOperationRegistry final
7474
#define PP_CONCAT(x, y) PP_CONCAT_IMPL(x, y)
7575
#define PP_CONCAT_IMPL(x, y) x##y
7676

77-
#define REGISTER_PROFILER_OPERATION(name, description, operation) \
78-
__extension__ static const bool PP_CONCAT(operation_registration_result_, __COUNTER__) = \
79-
::ProfilerOperationRegistry::GetInstance().Add(name, description, operation)
77+
// clang-format off
78+
#define REGISTER_PROFILER_OPERATION(name, description, operation) \
79+
_Pragma("clang diagnostic push") \
80+
_Pragma("clang diagnostic ignored \"-Wpre-c2y-compat\"") \
81+
_Pragma("clang diagnostic ignored \"-Wc2y-extensions\"") static const bool \
82+
PP_CONCAT(operation_registration_result_, __COUNTER__) = \
83+
::ProfilerOperationRegistry::GetInstance().Add(name, description, operation) \
84+
_Pragma("clang diagnostic pop")
85+
// clang-format on

0 commit comments

Comments
 (0)