aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamar Christina <tamar.christina@arm.com>2024-01-09 11:19:24 +0000
committerTamar Christina <tamar.christina@arm.com>2024-01-09 11:19:24 +0000
commit109f2316725bd74d85279fa749e5ea59686ad320 (patch)
treed85f218f442d3a8748e3e08c0a0f46664d24b096
parentcbf569486b2decbde0308f9f4d0f0837e4cfefd9 (diff)
downloadgcc-109f2316725bd74d85279fa749e5ea59686ad320.zip
gcc-109f2316725bd74d85279fa749e5ea59686ad320.tar.gz
gcc-109f2316725bd74d85279fa749e5ea59686ad320.tar.bz2
frontend: don't ice with pragma NOVECTOR if loop has no condition [PR113267]
In C you can have loops without a condition, the original version of the patch was rejecting the use of #pragma GCC novector, however during review it was changed to not due this with the reason that we didn't want to give a compile error with such cases. However because annotations seem to be only be allowed on conditions (unless I'm mistaken?) the attached example ICEs because there's no condition. This will have it ignore the pragma instead of ICEing. I don't know if this is the best solution, but as far as I can tell we can't attach the annotation to anything else. gcc/c/ChangeLog: PR c/113267 * c-parser.cc (c_parser_for_statement): Skip the pragma is no cond. gcc/testsuite/ChangeLog: PR c/113267 * gcc.dg/pr113267.c: New test.
-rw-r--r--gcc/c/c-parser.cc2
-rw-r--r--gcc/testsuite/gcc.dg/pr113267.c8
2 files changed, 9 insertions, 1 deletions
diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc
index e7b74fb..878f323 100644
--- a/gcc/c/c-parser.cc
+++ b/gcc/c/c-parser.cc
@@ -8445,7 +8445,7 @@ c_parser_for_statement (c_parser *parser, bool ivdep, unsigned short unroll,
build_int_cst (integer_type_node,
annot_expr_unroll_kind),
build_int_cst (integer_type_node, unroll));
- if (novector && cond != error_mark_node)
+ if (novector && cond && cond != error_mark_node)
cond = build3 (ANNOTATE_EXPR, TREE_TYPE (cond), cond,
build_int_cst (integer_type_node,
annot_expr_no_vector_kind),
diff --git a/gcc/testsuite/gcc.dg/pr113267.c b/gcc/testsuite/gcc.dg/pr113267.c
new file mode 100644
index 0000000..8b6fa08
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr113267.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+
+void f (char *a, int i)
+{
+#pragma GCC novector
+ for (;;i++)
+ a[i] *= 2;
+}