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. (cherry picked from commit 84acbfbecbdbc3fb2a395bd97e338b2b26fad374)
This commit is contained in:
parent
0f71e52717
commit
1742b699c3
2 changed files with 11 additions and 1 deletions
|
@ -1501,7 +1501,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),
|
||||
|
|
10
gcc/testsuite/g++.dg/vect/vect-novector-pragma_2.cc
Normal file
10
gcc/testsuite/g++.dg/vect/vect-novector-pragma_2.cc
Normal file
|
@ -0,0 +1,10 @@
|
|||
/* { dg-do compile } */
|
||||
|
||||
void f (char *a, int i)
|
||||
{
|
||||
#pragma GCC novector
|
||||
for (;;i++)
|
||||
a[i] *= 2;
|
||||
}
|
||||
|
||||
|
Loading…
Add table
Reference in a new issue