[Openmp-commits] [PATCH] D90756: [OpenMP] avoid warning: equality comparison with extraneous parentheses
Joachim Protze via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Wed Nov 4 03:33:26 PST 2020
protze.joachim created this revision.
protze.joachim added reviewers: jlpeyton, AndreyChurbanov.
protze.joachim added a project: OpenMP.
Herald added subscribers: guansong, yaxunl.
protze.joachim requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.
The macros are used in several places with an `if(macro)` pattern. This results in several warnings like:
llvm-project/openmp/runtime/src/kmp_wait_release.h:336:49: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]
if ((((task_team)->tt.tt_found_tasks) == (!0)))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
llvm-project/openmp/runtime/src/kmp_wait_release.h:801:16: note: in instantiation of function template specialization '__kmp_wait_template<kmp_flag_64, 0, true, false>' requested here
retval = __kmp_wait_template<kmp_flag_64, 0, true, false>(
^
llvm-project/openmp/runtime/src/kmp_wait_release.h:336:49: note: remove extraneous parentheses around the comparison to silence this warning
if ((((task_team)->tt.tt_found_tasks) == (!0)))
~ ^ ~
llvm-project/openmp/runtime/src/kmp_wait_release.h:336:49: note: use '=' to turn this equality comparison into an assignment
if ((((task_team)->tt.tt_found_tasks) == (!0)))
^~
=
Having the constant at the lhs of the comparison, avoids this warning.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D90756
Files:
openmp/runtime/src/kmp.h
Index: openmp/runtime/src/kmp.h
===================================================================
--- openmp/runtime/src/kmp.h
+++ openmp/runtime/src/kmp.h
@@ -1099,12 +1099,12 @@
#define KMP_TLS_GTID_MIN INT_MAX
#endif
-#define KMP_MASTER_TID(tid) ((tid) == 0)
-#define KMP_WORKER_TID(tid) ((tid) != 0)
+#define KMP_MASTER_TID(tid) (0 == (tid))
+#define KMP_WORKER_TID(tid) (0 != (tid))
-#define KMP_MASTER_GTID(gtid) (__kmp_tid_from_gtid((gtid)) == 0)
-#define KMP_WORKER_GTID(gtid) (__kmp_tid_from_gtid((gtid)) != 0)
-#define KMP_INITIAL_GTID(gtid) ((gtid) == 0)
+#define KMP_MASTER_GTID(gtid) (0 == __kmp_tid_from_gtid((gtid)))
+#define KMP_WORKER_GTID(gtid) (0 != __kmp_tid_from_gtid((gtid)))
+#define KMP_INITIAL_GTID(gtid) (0 == (gtid))
#ifndef TRUE
#define FALSE 0
@@ -2074,7 +2074,7 @@
// The tt_found_tasks flag is a signal to all threads in the team that tasks
// were spawned and queued since the previous barrier release.
#define KMP_TASKING_ENABLED(task_team) \
- (TCR_SYNC_4((task_team)->tt.tt_found_tasks) == TRUE)
+ (TRUE == TCR_SYNC_4((task_team)->tt.tt_found_tasks))
/*!
@ingroup BASIC_TYPES
@{
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90756.302801.patch
Type: text/x-patch
Size: 1174 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20201104/4bedb24f/attachment.bin>
More information about the Openmp-commits
mailing list