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.

Reply via email to