]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
RISC-V: Ignore non-types in builtin function hash.
authorRobin Dapp <rdapp@ventanamicro.com>
Tue, 8 Jul 2025 09:17:41 +0000 (11:17 +0200)
committerRobin Dapp <rdapp@ventanamicro.com>
Tue, 8 Jul 2025 13:42:27 +0000 (15:42 +0200)
If a user passes a string that doesn't represent a variable we still try
to compute a hash for its type.  Its tree does not represent a type but
just an exceptional, though.  This patch just ignores it, leaving the
error to the checking code later.

PR target/113829

gcc/ChangeLog:

* config/riscv/riscv-vector-builtins.cc (registered_function::overloaded_hash):
Skip non-type arguments.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/pr113829.c: New test.

gcc/config/riscv/riscv-vector-builtins.cc
gcc/testsuite/gcc.target/riscv/rvv/base/pr113829.c [new file with mode: 0644]

index f652a125dc3590533a7bd6761edf6d740d317988..8810af0d9ccb89b3ca8b0f6a2a1480638136c99e 100644 (file)
@@ -4977,6 +4977,12 @@ registered_function::overloaded_hash () const
   for (unsigned int i = 0; i < argument_types.length (); i++)
     {
       type = argument_types[i];
+
+      /* If we're passed something entirely unreasonable, just ignore here.
+        We'll warn later anyway.  */
+      if (TREE_CODE_CLASS (TREE_CODE (type)) != tcc_type)
+       continue;
+
       unsigned_p = POINTER_TYPE_P (type) ? TYPE_UNSIGNED (TREE_TYPE (type))
                                         : TYPE_UNSIGNED (type);
       mode_p = POINTER_TYPE_P (type) ? TYPE_MODE (TREE_TYPE (type))
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/pr113829.c b/gcc/testsuite/gcc.target/riscv/rvv/base/pr113829.c
new file mode 100644 (file)
index 0000000..48c291a
--- /dev/null
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=rv64gcv -mabi=lp64d" } */
+
+#pragma riscv intrinsic "vector"
+void
+foo (void)
+{
+  __riscv_vfredosum_tu (X); /* { dg-error "undeclared" } */
+  /* { dg-error "too many arguments" "" { target *-*-* } .-1 } */
+}