diff mbox series

arm: Don't ICE on arm_mve.h pragma without MVE types [PR117408]

Message ID 20241101210617.1037923-1-torbjorn.svensson@foss.st.com
State New
Headers show
Series arm: Don't ICE on arm_mve.h pragma without MVE types [PR117408] | expand

Commit Message

Torbjorn SVENSSON Nov. 1, 2024, 9:06 p.m. UTC
There is one more problem, that this patch does not address, and that is
that there are warnings like below, but I do not know what's causing them.

.../gcc/testsuite/gcc.target/arm/pr117408-1.c:8:9: warning: 'pure' attribute on function returning 'void' [-Wattributes]
.../gcc/testsuite/gcc.target/arm/pr117408-2.c:8:9: warning: 'pure' attribute on function returning 'void' [-Wattributes]

Both warnignss are repeted several times and generated by the #pragma-line.
Should I dg-prune-output warning lines or is this ok as-is for trunk and
releases/gcc-14?

--

Starting with r14-435-g00d97bf3b5a, doing `#pragma arm "arm_mve.h"
false` or `#pragma arm "arm_mve.h" true` without first doing
`#pragma arm "arm_mve_types.h"` causes GCC to ICE.

gcc/ChangeLog:

      PR target/117408
      * config/arm/arm-mve-builtins.cc(handle_arm_mve_h): Detect if MVE
      types is missing and if so, return error.

gcc/testsuite/ChangeLog:

      PR target/117408
      * gcc.target/arm/mve/pr117408-1.c: New test.
      * gcc.target/arm/mve/pr117408-2.c: Likewise.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
---
 gcc/config/arm/arm-mve-builtins.cc            | 6 ++++++
 gcc/testsuite/gcc.target/arm/mve/pr117408-1.c | 7 +++++++
 gcc/testsuite/gcc.target/arm/mve/pr117408-2.c | 7 +++++++
 3 files changed, 20 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/arm/mve/pr117408-1.c
 create mode 100644 gcc/testsuite/gcc.target/arm/mve/pr117408-2.c
diff mbox series

Patch

diff --git a/gcc/config/arm/arm-mve-builtins.cc b/gcc/config/arm/arm-mve-builtins.cc
index af1908691b6..c730fe1f0b9 100644
--- a/gcc/config/arm/arm-mve-builtins.cc
+++ b/gcc/config/arm/arm-mve-builtins.cc
@@ -535,6 +535,12 @@  handle_arm_mve_h (bool preserve_user_namespace)
       return;
     }
 
+  if (!handle_arm_mve_types_p)
+    {
+      error ("this definition requires MVE types")
+      return;
+    }
+
   /* Define MVE functions.  */
   function_table = new hash_table<registered_function_hasher> (1023);
   function_builder builder;
diff --git a/gcc/testsuite/gcc.target/arm/mve/pr117408-1.c b/gcc/testsuite/gcc.target/arm/mve/pr117408-1.c
new file mode 100644
index 00000000000..5dddf86efa0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/mve/pr117408-1.c
@@ -0,0 +1,7 @@ 
+/* { dg-do compile } */
+/* { dg-require-effective-target arm_v8_1m_mve_ok } */
+/* { dg-add-options arm_v8_1m_mve } */
+
+/* It doesn't really matter if this produces errors missing types,
+      but it mustn't trigger an ICE.  */
+#pragma GCC arm "arm_mve.h" false /* { dg-error "this definition requires MVE types" } */
diff --git a/gcc/testsuite/gcc.target/arm/mve/pr117408-2.c b/gcc/testsuite/gcc.target/arm/mve/pr117408-2.c
new file mode 100644
index 00000000000..6451ee3577e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/mve/pr117408-2.c
@@ -0,0 +1,7 @@ 
+/* { dg-do compile } */
+/* { dg-require-effective-target arm_v8_1m_mve_ok } */
+/* { dg-add-options arm_v8_1m_mve } */
+
+/* It doesn't really matter if this produces errors missing types,
+      but it mustn't trigger an ICE.  */
+#pragma GCC arm "arm_mve.h" true /* { dg-error "this definition requires MVE types" } */