Hi,
When compiling GCC (with JIT enabled) by clang, it produces a series
of warning s like this for all uses of DEF_GOACC_BUILTIN_COMPILER and
DEF_GOMP_BUILTIN_COMPILER in omp-builtins.def:
----------------------------------------------------------------------
In file included from
/home/worker/buildworker/tiber-gcc-clang/build/gcc/jit/jit-builtins.cc:61:
In file included from
/home/worker/buildworker/tiber-gcc-clang/build/gcc/builtins.def:1276:
/home/worker/buildworker/tiber-gcc-clang/build/gcc/omp-builtins.def:55:1:
warning: non-constant-expression cannot be narrowed from type 'int' to 'bool'
in initializer list [-Wc++11-narrowing]
55 | DEF_GOACC_BUILTIN_COMPILER (BUILT_IN_ACC_ON_DEVICE, "acc_on_device",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
56 | BT_FN_INT_INT,
ATTR_CONST_NOTHROW_LEAF_LIST)
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/worker/buildworker/tiber-gcc-clang/build/gcc/builtins.def:225:9: note:
expanded from macro 'DEF_GOACC_BUILTIN_COMPILER'
225 | flag_openacc, true, true, ATTRS, false, true)
| ^~~~~~~~~~~~
./options.h:7049:22: note: expanded from macro 'flag_openacc'
7049 | #define flag_openacc global_options.x_flag_openacc
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/worker/buildworker/tiber-gcc-clang/build/gcc/jit/jit-builtins.cc:58:23:
note: expanded from macro 'DEF_BUILTIN'
58 | {NAME, CLASS, TYPE, BOTH_P, FALLBACK_P, ATTRS, IMPLICIT},
| ^~~~~~
/home/worker/buildworker/tiber-gcc-clang/build/gcc/omp-builtins.def:55:1:
note: insert an explicit cast to silence this issue
----------------------------------------------------------------------
I'm not sure to what extent this is an actual problem or not, but
flag_openacc is an int and we do store it in a bool, so I this patch
does add the explicit cast clang asks for.
Bootstrapped and tested on x86_64-linx. OK for master?
Alternatively, as with all of these clang warning issues, I'm
perfectly happy to add an entry to contrib/filter-clang-warnings.py to
ignore the warnings instead.
Thanks,
Martin
gcc/jit/ChangeLog:
2025-06-23 Martin Jambor <[email protected]>
* jit-builtins.cc (DEF_BUILTIN): Add explicit cast to bool of BOTH_P.
---
gcc/jit/jit-builtins.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gcc/jit/jit-builtins.cc b/gcc/jit/jit-builtins.cc
index 84e0bd5347f..ddbba55d3f3 100644
--- a/gcc/jit/jit-builtins.cc
+++ b/gcc/jit/jit-builtins.cc
@@ -55,7 +55,7 @@ struct builtin_data
#define DEF_BUILTIN(X, NAME, CLASS, TYPE, LT, BOTH_P, FALLBACK_P, \
NONANSI_P, ATTRS, IMPLICIT, COND) \
- {NAME, CLASS, TYPE, BOTH_P, FALLBACK_P, ATTRS, IMPLICIT},
+ {NAME, CLASS, TYPE, (bool) BOTH_P, FALLBACK_P, ATTRS, IMPLICIT},
static const struct builtin_data builtin_data[] =
{
#include "builtins.def"
--
2.49.0