Hi,

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.

Regtested on rv64gcv_zvl512b.


Regards
Robin

        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          |  6 ++++++
gcc/testsuite/gcc.target/riscv/rvv/base/pr113829.c | 10 ++++++++++
2 files changed, 16 insertions(+)
create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/pr113829.c

diff --git a/gcc/config/riscv/riscv-vector-builtins.cc 
b/gcc/config/riscv/riscv-vector-builtins.cc
index 4e0dbdfb1aa..0ad497c9beb 100644
--- a/gcc/config/riscv/riscv-vector-builtins.cc
+++ b/gcc/config/riscv/riscv-vector-builtins.cc
@@ -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
index 00000000000..48c291a9202
--- /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 } */
+}
--
2.50.0

Reply via email to