1 /* Verify that defining a type in __builtin_has_attribute triggers
2 the expected -Wc++-compat warning and evaluates as expected.
3 Also verify that the expression in __builtin_has_attribute is
7 { dg-options "-O2 -Wall -Wc++-compat -fdump-tree-optimized -ftrack-macro-expansion=0" } */
9 #define ATTR(list) __attribute__ (list)
11 #define A(expect, sym, attr) \
12 typedef int Assert [1 - 2 * !(__builtin_has_attribute (sym, attr) == expect)]
14 #define assert(expr) \
17 : (__builtin_printf ("Assertion failed on line %i: %s\n", \
21 A (0, struct A
{ int i
; }, aligned
); /* { dg-warning "expression is invalid in C\\\+\\\+" } */
22 A (1, struct ATTR ((aligned
)) B
{ int i
; }, aligned
); /* { dg-warning "expression is invalid in C\\\+\\\+" } */
32 int n
= 0, nfails
= 0;
34 assert (0 == __builtin_has_attribute (int[n
++], aligned
));
35 assert (1 == __builtin_has_attribute (ATTR ((aligned
)) int[n
++], aligned
));
36 assert (1 == __builtin_has_attribute (ATTR ((aligned
)) int[f ()], aligned
));
48 /* { dg-final { scan-tree-dump-times "abort" 0 "optimized" } } */