diff options
author | Jakub Jelinek <jakub@redhat.com> | 2020-12-05 01:30:08 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2020-12-05 01:30:08 +0100 |
commit | 43e84ce7d62be121445e17cc0ee009a81fb285d7 (patch) | |
tree | 4c30da1fb62d47cc0934531732b7335b6eb9b3ce /gcc/fortran/resolve.c | |
parent | c5fd8a9157c440c2039e7c7015f012800d1e524d (diff) | |
download | gcc-43e84ce7d62be121445e17cc0ee009a81fb285d7.zip gcc-43e84ce7d62be121445e17cc0ee009a81fb285d7.tar.gz gcc-43e84ce7d62be121445e17cc0ee009a81fb285d7.tar.bz2 |
c++: Fix constexpr access to union member through pointer-to-member [PR98122]
We currently incorrectly reject the first testcase, because
cxx_fold_indirect_ref_1 doesn't attempt to handle UNION_TYPEs.
As the second testcase shows, it isn't that easy, because I believe we need
to take into account the active member and prefer that active member over
other members, because if we pick a non-active one, we might reject valid
programs.
2020-12-05 Jakub Jelinek <jakub@redhat.com>
PR c++/98122
* constexpr.c (cxx_union_active_member): New function.
(cxx_fold_indirect_ref_1): Add ctx argument, pass it through to
recursive call. Handle UNION_TYPE.
(cxx_fold_indirect_ref): Add ctx argument, pass it to recursive calls
and cxx_fold_indirect_ref_1.
(cxx_eval_indirect_ref): Adjust cxx_fold_indirect_ref calls.
* g++.dg/cpp1y/constexpr-98122.C: New test.
* g++.dg/cpp2a/constexpr-98122.C: New test.
Diffstat (limited to 'gcc/fortran/resolve.c')
0 files changed, 0 insertions, 0 deletions