[gcc(refs/vendors/riscv/heads/gcc-15-with-riscv-opts)] RISC-V: Ignore non-types in builtin function hash.
Jeff Law
law@gcc.gnu.org
Sat Jan 17 07:04:51 GMT 2026
https://gcc.gnu.org/g:aa43dac15a1ba81cb8b97e2d494efda5bef21eb6
commit aa43dac15a1ba81cb8b97e2d494efda5bef21eb6
Author: Robin Dapp <rdapp@ventanamicro.com>
Date: Tue Jul 8 11:17:41 2025 +0200
RISC-V: Ignore non-types in builtin function hash.
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.
(cherry picked from commit 6968656d631c6666081889f30c2247bf255e0831)
Diff:
---
gcc/config/riscv/riscv-vector-builtins.cc | 6 ++++++
gcc/testsuite/gcc.target/riscv/rvv/base/pr113829.c | 10 ++++++++++
2 files changed, 16 insertions(+)
diff --git a/gcc/config/riscv/riscv-vector-builtins.cc b/gcc/config/riscv/riscv-vector-builtins.cc
index 13e951c9527f..14ba27f6506c 100644
--- a/gcc/config/riscv/riscv-vector-builtins.cc
+++ b/gcc/config/riscv/riscv-vector-builtins.cc
@@ -5012,6 +5012,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
index 000000000000..48c291a92026
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/base/pr113829.c
@@ -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 } */
+}
More information about the Gcc-cvs
mailing list