compiler/clc: Fix const correctness in libclc_add_generic_variants

Fix compiler error:

../src/compiler/clc/nir_load_libclc.c:266:13: error: initializing
'char *' with an expression of type 'const char *' discards qualifiers
[-Werror,-Wincompatible-pointer-types-discards-qualifiers]
  266 |       char *U3AS1 = strstr(func->name, "U3AS1");
      |             ^       ~~~~~~~~~~~~~~~~~~~~~~~~~~~

glibc now provides C23-style type-generic string functions. strstr
returns const char * when passed a const char * argument. Update U3AS1
declaration to const since it's only used for offset calculation.

Fixes: 4a08ee7ecf ("spirv/libclc: Add generic versions of arithmetic functions")
Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Karol Herbst <kherbst@redhat.com>
(cherry picked from commit 85fd63068e)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39828>
This commit is contained in:
Vinson Lee 2026-02-07 22:02:23 -08:00 committed by Marge Bot
parent cf20e1610c
commit a871c42e39
2 changed files with 2 additions and 2 deletions

View file

@ -1334,7 +1334,7 @@
"description": "compiler/clc: Fix const correctness in libclc_add_generic_variants",
"nominated": true,
"nomination_type": 2,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "4a08ee7ecf07b1d0cdfec4f61bdca08bf6551247",
"notes": null

View file

@ -263,7 +263,7 @@ libclc_add_generic_variants(nir_shader *shader)
if (strstr(func->name, "async_work_group_strided_copy"))
continue;
char *U3AS1 = strstr(func->name, "U3AS1");
const char *U3AS1 = strstr(func->name, "U3AS1");
if (U3AS1 == NULL)
continue;