diff options
author | Patrick Palka <ppalka@redhat.com> | 2025-09-03 10:10:00 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2025-09-03 10:10:00 -0400 |
commit | 3e2077d8c7a0acba2d54bd0666ae578fe114cd72 (patch) | |
tree | 8841fa0451b0230281ea1c46491da38bc1174a10 /gcc/testsuite/gcc.dg/torture/movlfle.c | |
parent | df64893e7082d7fae5d6863fd02371b37c78557f (diff) | |
download | gcc-master.zip gcc-master.tar.gz gcc-master.tar.bz2 |
Here although the local templated variables x and y have the same
reduced constant value, only x's initializer {a.get()} is well-formed
as written since A::m has private access. We correctly reject y's
initializer {&a.m} (at instantiation time), but we also reject x's
initializer because we happen to constant fold it ahead of time, which
means at instantiation time it's already represented as a COMPONENT_REF
to a FIELD_DECL, and so when substituting this COMPONENT_REF we naively
double check that the given FIELD_DECL is accessible, which fails.
This patch sidesteps around this particular issue by not checking access
when substituting a COMPONENT_REF to a FIELD_DECL. If the target of a
COMPONENT_REF is already a FIELD_DECL (i.e. before substitution), then I
think we can assume access has been already checked appropriately.
PR c++/97740
gcc/cp/ChangeLog:
* pt.cc (tsubst_expr) <case COMPONENT_REF>: Don't check access
when the given member is already a FIELD_DECL.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/constexpr-97740a.C: New test.
* g++.dg/cpp0x/constexpr-97740b.C: New test.
Reviewed-by: Jason Merrill <jason@redhat.com>
Diffstat (limited to 'gcc/testsuite/gcc.dg/torture/movlfle.c')
0 files changed, 0 insertions, 0 deletions