On 6/2/21 11:25 AM, Jakub Jelinek wrote:
On Wed, Jun 02, 2021 at 11:09:45AM -0400, Jason Merrill wrote:
On 6/2/21 3:59 AM, Jakub Jelinek wrote:
if (!allows_reg && !cxx_mark_addressable (*op))
operand = error_mark_node;
+ else if (!allows_reg && bitfield_p (*op))
+ {
+ error_at (loc, "attempt to take address of bit-field");
Hmm, why aren't we already catching this in cxx_mark_addressable?
That is certainly possible, but it goes against Eric's patch
https://gcc.gnu.org/pipermail/gcc-patches/2015-June/421483.html
Hmm, I wonder what his rationale was?
So, do you want to keep the
if (bitfield_p (arg))
{
if (complain & tf_error)
error_at (loc, "attempt to take address of bit-field");
return error_mark_node;
}
in cp_build_addr_expr_1 and duplicate such check in cxx_mark_addressable
(though, that one doesn't have complain, will it be ok to do it
unconditionally for SFINAE)?
We would need to add complain; the existing diagnostics can't happen in
SFINAE context, but this one can.
Alternately, cxx_mark_addressable could abort on a bitfield to require
the caller to handle it, but that seems less useful.
Jason
Shall the C FE do the same (i.e. diagnose in both places)?