1 /* PR c++/94346 - ICE due to handle_copy_attribute 2 { dg-do compile } 3 { dg-options "-Wall" } */ 4 5 #define ATTR(...) __attribute__ ((__VA_ARGS__)) 6 7 #if __cplusplus > 199711L 8 # define SA(expr) static_assert (expr, #expr) 9 #elif __cplusplus 10 # define SA(expr) \ 11 typedef __attribute__ ((unused)) char Assert[!(expr) ? -1 : 1] 12 #else 13 # define SA(expr) _Static_assert (expr, #expr) 14 #endif 15 16 typedef struct ATTR (packed) A { ATTR (packed) unsigned bf: 1; } A; 17 18 int bar (void); 19 20 struct C 21 { 22 char c; 23 ATTR (copy ((bar (), ((struct A *)(0))[0]))) int i; 24 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */ 25 }; 26 27 /* Verify the attribute has been copied. */ 28 SA (__builtin_offsetof (struct C, i) == 1); 29 30 31 32 /* Verify attribute copy can copy from the type a comma expression. */ 33 ATTR (alloc_size (1)) void* alloc1 (int); 34 35 ATTR (copy ((bar (), alloc1))) void* alloc2 (int, int); 36 37 ATTR (copy ((bar (), alloc1))) void alloc3 (int); /* { dg-warning "'alloc_size' attribute ignored on a function returning 'void'" } */ 38 39 40 typedef ATTR (alloc_size (1)) void* F (int); 41 42 ATTR (copy ((bar (), (F*)0))) void* alloc4 (int, int); 43 44 ATTR (copy ((bar (), (F*)0))) void alloc5 (int, int); /* { dg-warning "'alloc_size' attribute ignored on a function returning 'void'" } */ 45