[PATCH] fix ice in attribute copy (PR 89685)

Martin Sebor msebor@gmail.com
Tue Mar 19 22:35:00 GMT 2019


On 3/19/19 12:42 PM, Jeff Law wrote:
> 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.

There is no way for attribute copy to refer to a type but by
mentioning an expression:

   struct __attribute__ ((aligned (8))) A { ... };
   struct __attribute__ ((copy ((struct S*)0))) struct B { };

Copying type attributes is one third of the feature's documented
purpose:

   copy
   copy (expression)

     The copy attribute applies the set of attributes with which
     the type of the expression has been declared to the declaration
     of the type to which the attribute is applied.

Why are you so determined to break these features?

Martin



More information about the Gcc-patches mailing list