aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2023-04-20 19:26:17 +0200
committerJakub Jelinek <jakub@redhat.com>2023-04-20 19:29:57 +0200
commit3d7ab53d6c59499624aa41c8dea0664976820b3b (patch)
tree54699a7583004ec4aee9a6b240f09306623654ab /gcc/c
parent1d2aa9a8cb8fd078af930347392cfdfc14e1551c (diff)
downloadgcc-3d7ab53d6c59499624aa41c8dea0664976820b3b.zip
gcc-3d7ab53d6c59499624aa41c8dea0664976820b3b.tar.gz
gcc-3d7ab53d6c59499624aa41c8dea0664976820b3b.tar.bz2
c: Avoid -Wenum-int-mismatch warning for redeclaration of builtin acc_on_device [PR107041]
The new -Wenum-int-mismatch warning triggers with -Wsystem-headers in <openacc.h>, for obvious reasons the builtin acc_on_device uses int type argument rather than enum which isn't defined yet when the builtin is created, while the OpenACC spec requires it to have acc_device_t enum argument. The header makes sure it has int underlying type by using negative and __INT_MAX__ enumerators. I've tried to make the builtin typegeneric or just varargs, but that changes behavior e.g. when one calls it with some C++ class which has cast operator to acc_device_t, so the following patch instead disables the warning for this builtin. 2023-04-20 Jakub Jelinek <jakub@redhat.com> PR c/107041 * c-decl.cc (diagnose_mismatched_decls): Avoid -Wenum-int-mismatch warning on acc_on_device declaration. * gcc.dg/goacc/pr107041.c: New test.
Diffstat (limited to 'gcc/c')
-rw-r--r--gcc/c/c-decl.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc
index e537d33..1b53f2d 100644
--- a/gcc/c/c-decl.cc
+++ b/gcc/c/c-decl.cc
@@ -2219,7 +2219,14 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl,
}
/* Warn about enum/integer type mismatches. They are compatible types
(C2X 6.7.2.2/5), but may pose portability problems. */
- else if (enum_and_int_p && TREE_CODE (newdecl) != TYPE_DECL)
+ else if (enum_and_int_p
+ && TREE_CODE (newdecl) != TYPE_DECL
+ /* Don't warn about about acc_on_device built-in redeclaration,
+ the built-in is declared with int rather than enum because
+ the enum isn't intrinsic. */
+ && !(TREE_CODE (olddecl) == FUNCTION_DECL
+ && fndecl_built_in_p (olddecl, BUILT_IN_ACC_ON_DEVICE)
+ && !C_DECL_DECLARED_BUILTIN (olddecl)))
warned = warning_at (DECL_SOURCE_LOCATION (newdecl),
OPT_Wenum_int_mismatch,
"conflicting types for %q+D due to enum/integer "