Require target lra in gcc.dg/pr108095.c
[official-gcc.git] / gcc / testsuite / c-c++-common / attr-copy.c
blobf0db0fd1a274f0d29ec555def7339ef083a67136
1 /* PR c++/94346 - ICE due to handle_copy_attribute
2 { dg-do compile }
3 { dg-options "-Wall" } */
5 #define ATTR(...) __attribute__ ((__VA_ARGS__))
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
16 typedef struct ATTR (packed) A { ATTR (packed) unsigned bf: 1; } A;
18 int bar (void);
20 struct C
22 char c;
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'" } */