]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: #pragma GCC unroll C++ fixes [PR112795]
authorJakub Jelinek <jakub@redhat.com>
Mon, 4 Dec 2023 07:59:15 +0000 (08:59 +0100)
committerJakub Jelinek <jakub@redhat.com>
Sat, 16 Dec 2023 00:37:11 +0000 (01:37 +0100)
commitf1761303c77219281c22ab50b4a9ce65920c4023
tree42748b4e34e22ec05a779972c947d64d0c341b56
parent9cb9cecdb582b44b04e9c49532ddf0065b5c3612
c++: #pragma GCC unroll C++ fixes [PR112795]

foo in the unroll-5.C testcase ICEs because cp_parser_pragma_unroll
during parsing calls maybe_constant_value unconditionally, which is
fine if !processing_template_decl, but can ICE otherwise.

While just calling fold_non_dependent_expr there instead could be enough
to fix the ICE (and I guess the right thing to do for backports if any),
I don't see a reason why we couldn't handle a dependent #pragma GCC unroll
argument as well, the unrolling isn't done in the FE and all the middle-end
cares about is that ANNOTATE_EXPR has a 1..65534 last operand when it is
annot_expr_unroll_kind.

So, the following patch changes all the unsigned short unroll arguments
to tree unroll (and thus avoids the tree -> unsigned short -> tree
conversions), does the type and value checking during parsing only if
the argument isn't dependent and repeats it during instantiation.

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

PR c++/112795
gcc/cp/
* parser.cc (cp_parser_pragma_unroll): Use fold_non_dependent_expr
instead of maybe_constant_value.
gcc/testsuite/
* g++.dg/ext/unroll-5.C: New test.

(cherry picked from commit b6c78feea08c36e5754818c6a3d7536b3f8913dc)
gcc/cp/parser.cc
gcc/testsuite/g++.dg/ext/unroll-5.C [new file with mode: 0644]