]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++ frontend: check for missing condition for novector [PR115623]
authorTamar Christina <tamar.christina@arm.com>
Thu, 4 Jul 2024 10:01:55 +0000 (11:01 +0100)
committerTamar Christina <tamar.christina@arm.com>
Thu, 4 Jul 2024 10:01:55 +0000 (11:01 +0100)
It looks like I forgot to check in the C++ frontend if a condition exist for the
loop being adorned with novector.  This causes a segfault because cond isn't
expected to be null.

This fixes it by issuing ignoring the pragma when there's no loop condition
the same way we do in the C frontend.

gcc/cp/ChangeLog:

PR c++/115623
* semantics.cc (finish_for_cond): Add check for C++ cond.

gcc/testsuite/ChangeLog:

PR c++/115623
* g++.dg/vect/vect-novector-pragma_2.cc: New test.

gcc/cp/semantics.cc
gcc/testsuite/g++.dg/vect/vect-novector-pragma_2.cc [new file with mode: 0644]

index 12d79bdbb3fae36fe63544decb8ae34c3a99ff00..cd3df13772db1c64620c15070ce2268476c5cbfa 100644 (file)
@@ -1510,7 +1510,7 @@ finish_for_cond (tree cond, tree for_stmt, bool ivdep, tree unroll,
                                  build_int_cst (integer_type_node,
                                                 annot_expr_unroll_kind),
                                  unroll);
-  if (novector && cond != error_mark_node)
+  if (novector && cond && cond != error_mark_node)
     FOR_COND (for_stmt) = build3 (ANNOTATE_EXPR,
                                  TREE_TYPE (FOR_COND (for_stmt)),
                                  FOR_COND (for_stmt),
diff --git a/gcc/testsuite/g++.dg/vect/vect-novector-pragma_2.cc b/gcc/testsuite/g++.dg/vect/vect-novector-pragma_2.cc
new file mode 100644 (file)
index 0000000..d2a8eee
--- /dev/null
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+
+void f (char *a, int i)
+{
+#pragma GCC novector
+  for (;;i++)
+    a[i] *= 2;
+}
+
+