* [Bug libgomp/107041] [13 Regression] C '-Wenum-int-mismatch' diagnostic for OpenACC 'acc_on_device'
2022-09-26 13:42 [Bug libgomp/107041] New: [13 Regression] C '-Wenum-int-mismatch' diagnostic for OpenACC 'acc_on_device' tschwinge at gcc dot gnu.org
@ 2022-09-27 8:50 ` rguenth at gcc dot gnu.org
2022-12-22 14:35 ` rguenth at gcc dot gnu.org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-09-27 8:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107041
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |13.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libgomp/107041] [13 Regression] C '-Wenum-int-mismatch' diagnostic for OpenACC 'acc_on_device'
2022-09-26 13:42 [Bug libgomp/107041] New: [13 Regression] C '-Wenum-int-mismatch' diagnostic for OpenACC 'acc_on_device' tschwinge at gcc dot gnu.org
2022-09-27 8:50 ` [Bug libgomp/107041] " rguenth at gcc dot gnu.org
@ 2022-12-22 14:35 ` rguenth at gcc dot gnu.org
2023-03-27 13:55 ` rguenth at gcc dot gnu.org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-12-22 14:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107041
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Using a specific builtin enum type in builtins is indeed difficult.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libgomp/107041] [13 Regression] C '-Wenum-int-mismatch' diagnostic for OpenACC 'acc_on_device'
2022-09-26 13:42 [Bug libgomp/107041] New: [13 Regression] C '-Wenum-int-mismatch' diagnostic for OpenACC 'acc_on_device' tschwinge at gcc dot gnu.org
2022-09-27 8:50 ` [Bug libgomp/107041] " rguenth at gcc dot gnu.org
2022-12-22 14:35 ` rguenth at gcc dot gnu.org
@ 2023-03-27 13:55 ` rguenth at gcc dot gnu.org
2023-04-17 15:23 ` [Bug libgomp/107041] [13/14 " jakub at gcc dot gnu.org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-03-27 13:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107041
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Note you can have a custom type instead of BT_FN_INT_INT, you could use
a DEF_PRIMITIVE_TYPE and have a global variable initialized where we
initialize builtins for it.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libgomp/107041] [13/14 Regression] C '-Wenum-int-mismatch' diagnostic for OpenACC 'acc_on_device'
2022-09-26 13:42 [Bug libgomp/107041] New: [13 Regression] C '-Wenum-int-mismatch' diagnostic for OpenACC 'acc_on_device' tschwinge at gcc dot gnu.org
` (2 preceding siblings ...)
2023-03-27 13:55 ` rguenth at gcc dot gnu.org
@ 2023-04-17 15:23 ` jakub at gcc dot gnu.org
2023-04-17 17:36 ` jakub at gcc dot gnu.org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-04-17 15:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107041
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
If this is really just because it is a builtin, I think another possibility
would be
make it BT_FN_INT_VAR instead of BT_FN_INT_INT and verify it has just one
argument which
is either int or the particularly named enum say in builtins.cc folding or so.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libgomp/107041] [13/14 Regression] C '-Wenum-int-mismatch' diagnostic for OpenACC 'acc_on_device'
2022-09-26 13:42 [Bug libgomp/107041] New: [13 Regression] C '-Wenum-int-mismatch' diagnostic for OpenACC 'acc_on_device' tschwinge at gcc dot gnu.org
` (3 preceding siblings ...)
2023-04-17 15:23 ` [Bug libgomp/107041] [13/14 " jakub at gcc dot gnu.org
@ 2023-04-17 17:36 ` jakub at gcc dot gnu.org
2023-04-18 8:39 ` jakub at gcc dot gnu.org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-04-17 17:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107041
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I think this is less important as it normally should trigger only with -Wall
-Wsystem-headers.
Anyway, one fix could be e.g.
--- gcc/omp-builtins.def.jj 2023-04-17 19:11:55.065865863 +0200
+++ gcc/omp-builtins.def 2023-04-17 19:14:45.433406545 +0200
@@ -52,7 +52,7 @@ DEF_GOACC_BUILTIN (BUILT_IN_GOACC_DECLAR
BT_FN_VOID_INT_SIZE_PTR_PTR_PTR, ATTR_NOTHROW_LIST)
DEF_GOACC_BUILTIN_COMPILER (BUILT_IN_ACC_ON_DEVICE, "acc_on_device",
- BT_FN_INT_INT, ATTR_CONST_NOTHROW_LEAF_LIST)
+ BT_FN_INT_VAR, ATTR_CONST_NOTHROW_LEAF_LIST)
DEF_GOACC_BUILTIN_ONLY (BUILT_IN_GOACC_PARLEVEL_ID, "goacc_parlevel_id",
BT_FN_INT_INT, ATTR_NOTHROW_LEAF_LIST)
--- gcc/c-family/c-common.cc.jj 2023-03-28 17:47:46.769970692 +0200
+++ gcc/c-family/c-common.cc 2023-04-17 19:28:31.037488778 +0200
@@ -6493,6 +6493,25 @@ check_builtin_function_arguments (locati
}
return false;
+ case BUILT_IN_ACC_ON_DEVICE:
+ if (builtin_function_validate_nargs (loc, fndecl, nargs, 1))
+ {
+ if (TREE_CODE (TREE_TYPE (args[0])) != INTEGER_TYPE
+ && (TREE_CODE (TREE_TYPE (args[0])) != ENUMERAL_TYPE
+ || (TREE_CODE (TREE_TYPE (TREE_TYPE (args[0])))
+ != INTEGER_TYPE)
+ || (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (args[0])))
+ != integer_type_node)))
+ {
+ error_at (ARG_LOCATION (0), "argument %u in call to function "
+ "%qE does not have integer or enumerated type",
+ 1, fndecl);
+ return false;
+ }
+ return true;
+ }
+ return false;
+
default:
return true;
}
--- gcc/fortran/types.def.jj 2023-04-17 19:11:55.065865863 +0200
+++ gcc/fortran/types.def 2023-04-17 19:14:45.433406545 +0200
@@ -264,6 +264,7 @@ DEF_FUNCTION_TYPE_11 (BT_FN_VOID_OMPFN_P
BT_ULONGLONG, BT_ULONGLONG, BT_ULONGLONG)
DEF_FUNCTION_TYPE_VAR_0 (BT_FN_VOID_VAR, BT_VOID)
+DEF_FUNCTION_TYPE_VAR_0 (BT_FN_INT_VAR, BT_INT)
DEF_FUNCTION_TYPE_VAR_1 (BT_FN_VOID_LONG_VAR,
BT_VOID, BT_LONG)
plus testsuite changes.
But that would break
#include <openacc.h>
struct S { operator acc_device_t () { return acc_device_none; } };
int
foo ()
{
S s;
return acc_on_device (s);
}
Another option would be just disable the warning for this particular builtin
where the warning is reported.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libgomp/107041] [13/14 Regression] C '-Wenum-int-mismatch' diagnostic for OpenACC 'acc_on_device'
2022-09-26 13:42 [Bug libgomp/107041] New: [13 Regression] C '-Wenum-int-mismatch' diagnostic for OpenACC 'acc_on_device' tschwinge at gcc dot gnu.org
` (4 preceding siblings ...)
2023-04-17 17:36 ` jakub at gcc dot gnu.org
@ 2023-04-18 8:39 ` jakub at gcc dot gnu.org
2023-04-20 17:30 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-04-18 8:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107041
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Last reconfirmed| |2023-04-18
Status|UNCONFIRMED |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 54879
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54879&action=edit
gcc14-pr107041.patch
Untested fix.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libgomp/107041] [13/14 Regression] C '-Wenum-int-mismatch' diagnostic for OpenACC 'acc_on_device'
2022-09-26 13:42 [Bug libgomp/107041] New: [13 Regression] C '-Wenum-int-mismatch' diagnostic for OpenACC 'acc_on_device' tschwinge at gcc dot gnu.org
` (5 preceding siblings ...)
2023-04-18 8:39 ` jakub at gcc dot gnu.org
@ 2023-04-20 17:30 ` cvs-commit at gcc dot gnu.org
2023-04-26 6:56 ` rguenth at gcc dot gnu.org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-04-20 17:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107041
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:3d7ab53d6c59499624aa41c8dea0664976820b3b
commit r14-120-g3d7ab53d6c59499624aa41c8dea0664976820b3b
Author: Jakub Jelinek <jakub@redhat.com>
Date: Thu Apr 20 19:26:17 2023 +0200
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.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libgomp/107041] [13/14 Regression] C '-Wenum-int-mismatch' diagnostic for OpenACC 'acc_on_device'
2022-09-26 13:42 [Bug libgomp/107041] New: [13 Regression] C '-Wenum-int-mismatch' diagnostic for OpenACC 'acc_on_device' tschwinge at gcc dot gnu.org
` (6 preceding siblings ...)
2023-04-20 17:30 ` cvs-commit at gcc dot gnu.org
@ 2023-04-26 6:56 ` rguenth at gcc dot gnu.org
2023-04-26 8:37 ` cvs-commit at gcc dot gnu.org
2023-04-26 8:38 ` jakub at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-04-26 6:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107041
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|13.0 |13.2
--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 13.1 is being released, retargeting bugs to GCC 13.2.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libgomp/107041] [13/14 Regression] C '-Wenum-int-mismatch' diagnostic for OpenACC 'acc_on_device'
2022-09-26 13:42 [Bug libgomp/107041] New: [13 Regression] C '-Wenum-int-mismatch' diagnostic for OpenACC 'acc_on_device' tschwinge at gcc dot gnu.org
` (7 preceding siblings ...)
2023-04-26 6:56 ` rguenth at gcc dot gnu.org
@ 2023-04-26 8:37 ` cvs-commit at gcc dot gnu.org
2023-04-26 8:38 ` jakub at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-04-26 8:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107041
--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:f8646b8dcb18721e776c39117f62aee7ee571f21
commit r13-7246-gf8646b8dcb18721e776c39117f62aee7ee571f21
Author: Jakub Jelinek <jakub@redhat.com>
Date: Thu Apr 20 19:26:17 2023 +0200
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.
(cherry picked from commit 3d7ab53d6c59499624aa41c8dea0664976820b3b)
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libgomp/107041] [13/14 Regression] C '-Wenum-int-mismatch' diagnostic for OpenACC 'acc_on_device'
2022-09-26 13:42 [Bug libgomp/107041] New: [13 Regression] C '-Wenum-int-mismatch' diagnostic for OpenACC 'acc_on_device' tschwinge at gcc dot gnu.org
` (8 preceding siblings ...)
2023-04-26 8:37 ` cvs-commit at gcc dot gnu.org
@ 2023-04-26 8:38 ` jakub at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-04-26 8:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107041
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 11+ messages in thread