diff options
author | Tamar Christina <tamar.christina@arm.com> | 2024-07-04 11:01:55 +0100 |
---|---|---|
committer | Tamar Christina <tamar.christina@arm.com> | 2024-07-04 11:01:55 +0100 |
commit | 84acbfbecbdbc3fb2a395bd97e338b2b26fad374 (patch) | |
tree | 9ab84890ffda1017ac737d24ca84a22dbc3739ed /gcc | |
parent | 236d6fef2479654b3011f8208e1bd7f078700109 (diff) | |
download | gcc-84acbfbecbdbc3fb2a395bd97e338b2b26fad374.zip gcc-84acbfbecbdbc3fb2a395bd97e338b2b26fad374.tar.gz gcc-84acbfbecbdbc3fb2a395bd97e338b2b26fad374.tar.bz2 |
c++ frontend: check for missing condition for novector [PR115623]
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.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/semantics.cc | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/vect/vect-novector-pragma_2.cc | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index 12d79bd..cd3df13 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -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 index 0000000..d2a8eee --- /dev/null +++ b/gcc/testsuite/g++.dg/vect/vect-novector-pragma_2.cc @@ -0,0 +1,10 @@ +/* { dg-do compile } */ + +void f (char *a, int i) +{ +#pragma GCC novector + for (;;i++) + a[i] *= 2; +} + + |