1 /* PR c++/94346 - ICE due to handle_copy_attribute
3 { dg-options "-Wall" } */
5 #define ATTR(...) __attribute__ ((__VA_ARGS__))
7 #if __cplusplus > 199711L
8 # define SA(expr) static_assert (expr, #expr)
11 typedef __attribute__ ((unused)) char Assert[!(expr) ? -1 : 1]
13 # define SA(expr) _Static_assert (expr, #expr)
16 typedef struct ATTR (packed
) A
{ ATTR (packed
) unsigned bf
: 1; } A
;
23 ATTR (copy ((bar (), ((struct A
*)(0))[0]))) int i
;
24 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
27 /* Verify the attribute has been copied. */
28 SA (__builtin_offsetof (struct C
, i
) == 1);
32 /* Verify attribute copy can copy from the type a comma expression. */
33 ATTR (alloc_size (1)) void* alloc1 (int);
35 ATTR (copy ((bar (), alloc1
))) void* alloc2 (int, int);
37 ATTR (copy ((bar (), alloc1
))) void alloc3 (int); /* { dg-warning "'alloc_size' attribute ignored on a function returning 'void'" } */
40 typedef ATTR (alloc_size (1)) void* F (int);
42 ATTR (copy ((bar (), (F
*)0))) void* alloc4 (int, int);
44 ATTR (copy ((bar (), (F
*)0))) void alloc5 (int, int); /* { dg-warning "'alloc_size' attribute ignored on a function returning 'void'" } */