On 3/14/19 7:47 PM, Martin Sebor wrote:
To copy type attributes from struct A, the copy attribute (new
in GCC 9) accepts a pointer argument such as (struct A*)0, but
it isn't prepared for anything much more complicated than that.
So for example when it's passed something like (struct A*)(0, 1)
as the test case in PR 89685 does (a P1 regression), it fails
with an ICE.
The attached patch makes this handling more robust by letting
it accept all forms of type and member references.
Tested on x86_64-linux.
Martin
gcc-89685.diff
PR c/89685 - ICE on attribute copy with a compound expression
gcc/c-family/ChangeLog:
PR c/89685
* c-attribs.c (handle_copy_attribute): Handle references and
non-constant expressions.
gcc/testsuite/ChangeLog:
PR c/89685
* gcc.dg/attr-copy-8.c: New test.
* g++.dg/ext/attr-copy-2.C: New test.I think this is in the same state as the __builtin_has_attribute bits --
you're trying to support attributes on expressions. We should reject
those as syntax errors right now.