]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Further #pragma GCC unroll C++ fix [PR112795]
authorJakub Jelinek <jakub@redhat.com>
Tue, 5 Dec 2023 21:54:08 +0000 (22:54 +0100)
committerJakub Jelinek <jakub@redhat.com>
Tue, 5 Dec 2023 21:54:08 +0000 (22:54 +0100)
commit59be79fd596ec8f8fbdf1479bc99e6aba9c52778
treedbab4a24af431c3bab3574e24691ee00bf83234c
parent58d5546af901364f85588fe668559d76f09e6df9
c++: Further #pragma GCC unroll C++ fix [PR112795]

When committing the #pragma GCC unroll patch, I found I forgot one spot
for diagnosting the invalid unrolls - if #pragma GCC unroll argument is
dependent and the pragma is before a range for loop, the unroll tree (now,
before one converted form ushort) is saved into RANGE_FOR_UNROLL and
tsubst_stmt was RECURing on it, but didn't diagnose if it was invalid and
so we ICEd later in the middle-end when  ANNOTATE_EXPR had unexpected
argument.

The following patch fixes that.  So that the diagnostics isn't done in 3
different places, the patch introduces a new function that both
cp_parser_pragma_unroll and instantiation of ANNOTATE_EXPR and RANGE_FOR_STMT
can use.

2023-12-05  Jakub Jelinek  <jakub@redhat.com>

PR c++/112795
* cp-tree.h (cp_check_pragma_unroll): Declare.
* semantics.cc (cp_check_pragma_unroll): New function.
* parser.cc (cp_parser_pragma_unroll): Use cp_check_pragma_unroll.
* pt.cc (tsubst_expr) <case ANNOTATE_EXPR>: Likewise.
(tsubst_stmt) <case RANGE_FOR_STMT>: Likwsie.

* g++.dg/ext/unroll-2.C: Use { target c++11 } instead of dg-skip-if for
-std=gnu++98.
* g++.dg/ext/unroll-3.C: Likewise.
* g++.dg/ext/unroll-7.C: New test.
* g++.dg/ext/unroll-8.C: New test.
gcc/cp/cp-tree.h
gcc/cp/parser.cc
gcc/cp/pt.cc
gcc/cp/semantics.cc
gcc/testsuite/g++.dg/ext/unroll-2.C
gcc/testsuite/g++.dg/ext/unroll-3.C
gcc/testsuite/g++.dg/ext/unroll-7.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/unroll-8.C [new file with mode: 0644]