[gcc r17-2784] OpenMP: Handle 'device_type(nohost)' on 'target': Simplify 'GOMP_error' call

Thomas Schwinge via Gcc-cvs <[email protected]> Wed, 29 Jul 2026 10:07:52 +0000 (GMT)
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:5fe8c017dbb0fe085f72a4308eb93082e124e3c2

commit r17-2784-g5fe8c017dbb0fe085f72a4308eb93082e124e3c2
Author: Thomas Schwinge <[email protected]>
Date:   Thu Jul 23 14:13:56 2026 +0200

    OpenMP: Handle 'device_type(nohost)' on 'target': Simplify 'GOMP_error' call
    
    Simplify commit 97a43fc4dbc5cfb1174a13313dda7637c838d110
    "OpenMP: Handle 'device_type(nohost)' on 'target'".
    
            gcc/
            * gimplify.cc (gimplify_omp_workshare)
            [OMP_TARGET && OMP_CLAUSE_DEVICE_TYPE_NOHOST]: Use
            'build_string_literal'.  Use 'build_int_cst'.
            libgomp/
            * testsuite/libgomp.c/target-device-type-1.c: Adjust.
            * testsuite/libgomp.c/target-device-type-2.c: Likewise.

Diff:
---
 gcc/gimplify.cc                                    | 11 ++---------
 libgomp/testsuite/libgomp.c/target-device-type-1.c |  2 +-
 libgomp/testsuite/libgomp.c/target-device-type-2.c |  2 +-
 3 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index ed637d2de467..333e0a3f3a9a 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -19018,15 +19018,8 @@ gimplify_omp_workshare (tree *expr_p, gimple_seq *pre_p)
 	    tree err = builtin_decl_explicit (BUILT_IN_GOMP_ERROR);
 	    const char *str = "Executing device-type 'nohost' target region "
 			      "on the host";
-	    const int len = strlen (str) + 1;
-	    tree msg = build_string (len, str);
-	    TREE_TYPE (msg) = build_array_type_nelts (char_type_node, len);
-	    TREE_READONLY (msg) = 1;
-	    TREE_STATIC (msg) = 1;
-	    msg = build_fold_addr_expr (msg);
-	    tree msglen = fold_build2 (MINUS_EXPR, size_type_node,
-				       build_all_ones_cst (size_type_node),
-				       size_one_node);
+	    tree msg = build_string_literal (strlen (str) + 1, str);
+	    tree msglen = build_int_cst (size_type_node, -2);
 	    err = build_call_expr_loc (loc, err, 2, msg, msglen);
 	    tree l1 = create_artificial_label (UNKNOWN_LOCATION);
 	    tree l2 = create_artificial_label (UNKNOWN_LOCATION);
diff --git a/libgomp/testsuite/libgomp.c/target-device-type-1.c b/libgomp/testsuite/libgomp.c/target-device-type-1.c
index d8d964e7fe5c..0a7f169193bc 100644
--- a/libgomp/testsuite/libgomp.c/target-device-type-1.c
+++ b/libgomp/testsuite/libgomp.c/target-device-type-1.c
@@ -18,4 +18,4 @@ main ()
 }
 
 /* { dg-final { scan-tree-dump "= __builtin_omp_is_initial_device \\(\\);" "gimple" } } */
-/* { dg-final { scan-tree-dump "__builtin_GOMP_error \\(\"Executing device-type ..nohost.. target region on the host\"," "gimple" } } */
+/* { dg-final { scan-tree-dump "__builtin_GOMP_error \\(&\"Executing device-type ..nohost.. target region on the host\"\\\[0\\\]," "gimple" } } */
diff --git a/libgomp/testsuite/libgomp.c/target-device-type-2.c b/libgomp/testsuite/libgomp.c/target-device-type-2.c
index 54550422032c..df6f39235cc0 100644
--- a/libgomp/testsuite/libgomp.c/target-device-type-2.c
+++ b/libgomp/testsuite/libgomp.c/target-device-type-2.c
@@ -21,7 +21,7 @@ main ()
 }
 
 /* { dg-final { scan-tree-dump "= __builtin_omp_is_initial_device \\(\\);" "gimple" } } */
-/* { dg-final { scan-tree-dump "__builtin_GOMP_error \\(\"Executing device-type ..nohost.. target region on the host\"," "gimple" } } */
+/* { dg-final { scan-tree-dump "__builtin_GOMP_error \\(&\"Executing device-type ..nohost.. target region on the host\"\\\[0\\\]," "gimple" } } */
 
 /* { dg-output "libgomp: fatal error: Executing device-type 'nohost' target region on the host" } */
 /* { dg-shouldfail "'nohost' target region on the host" } */