Require target lra in gcc.dg/pr108095.c
[official-gcc.git] / gcc / testsuite / gcc.dg / attr-copy-4.c
blob01fae3f78d4fd019eb9ccd540b72b1d14a0a591f
1 /* PR middle-end/81824 - Warn for missing attributes with function aliases
2 Exercise attribute copy for types.
3 { dg-do compile }
4 { dg-options "-O2 -Wall -ftrack-macro-expansion=0" } */
6 #define Assert(expr) typedef char AssertExpr[2 * !!(expr) - 1]
8 #define ATTR(list) __attribute__ (list)
10 /* Use attribute packed to verify that type attributes are copied
11 from one type to another. */
13 struct ATTR ((packed)) PackedA { int i; char c; };
15 Assert (__alignof (struct PackedA) == 1);
17 struct ATTR ((copy ((struct PackedA*)0))) PackedB { long i; char c; };
19 Assert (__alignof (struct PackedA) == __alignof (struct PackedB));
21 struct PackedMember
23 char c;
24 ATTR ((copy ((struct PackedB*)0))) double packed_mem;
25 /* { dg-warning "attribute ignored" "" { target default_packed } .-1 } */
28 Assert (__alignof (struct PackedMember) == 1);
31 extern const struct PackedA packed;
33 struct Unpacked { int i; char c; };
34 Assert (__alignof (struct Unpacked) > 1);
35 /* { dg-error "size of array .* is negative" "" { target default_packed } .-1 } */
37 /* Verify that copying the packed attribute to the declaration
38 of an object is ignored with a warning. (There should be
39 a way to copy just the subset of attributes from a type that
40 aren't ignored and won't cause a warning, maybe via attribute
41 copy_except or something like that.) */
42 extern ATTR ((copy ((struct PackedA*)0))) const struct Unpacked
43 unpacked; /* { dg-warning ".packed. attribute ignored" } */
45 Assert (__alignof (packed) == 1);
46 Assert (__alignof (unpacked) == __alignof (struct Unpacked));
50 /* Verify that attribute deprecated isn't copied (but referencing
51 the deprecated type in the copy attribute still triggers a warning). */
53 struct ATTR ((aligned (8), deprecated))
54 AlignedDeprecated { char c; };
56 struct ATTR ((copy ((struct AlignedDeprecated *)0))) /* { dg-warning "\\\[-Wdeprecated-declarations]" } */
57 AlignedCopy { short s; };
59 Assert (__alignof (struct AlignedCopy) == 8);
61 struct AlignedCopy aligned_copy;
63 Assert (__alignof (aligned_copy) == 8);