| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-std=gnu17 -fpermissive -O -Wall -ftrack-macro-expansion=0" } */ |
| 3 |
|
| 4 |
/* C99 6.2.7: Compatible type and composite type. */ |
| 5 |
|
| 6 |
#define DECIMAL_COMPOSITE_DECL(TYPE) \ |
| 7 |
_Decimal##TYPE g1_##TYPE(); \ |
| 8 |
_Decimal##TYPE g2_##TYPE(); \ |
| 9 |
_Decimal##TYPE (*h1_##TYPE)[2]; \ |
| 10 |
_Decimal##TYPE (*h2_##TYPE)[3]; \ |
| 11 |
_Decimal##TYPE (*h3_##TYPE)[4]; \ |
| 12 |
_Decimal##TYPE f1_##TYPE(_Decimal##TYPE(*)()); \ |
| 13 |
_Decimal##TYPE f1_##TYPE(_Decimal##TYPE(*)(_Decimal##TYPE*)); \ |
| 14 |
_Decimal##TYPE f1_##TYPE (_Decimal##TYPE(*g)(_Decimal##TYPE*)) \ |
| 15 |
{ \ |
| 16 |
_Decimal##TYPE d##TYPE; \ |
| 17 |
d##TYPE = ((_Decimal##TYPE (*) (_Decimal##TYPE*)) g)(&d##TYPE); \ |
| 18 |
d##TYPE = ((_Decimal##TYPE (*) ()) g); \ |
| 19 |
return d##TYPE; \ |
| 20 |
} \ |
| 21 |
_Decimal##TYPE f2_##TYPE(_Decimal##TYPE(*)[]); \ |
| 22 |
_Decimal##TYPE f2_##TYPE(_Decimal##TYPE(*)[3]); |
| 23 |
|
| 24 |
#define DECIMAL_COMPOSITE_TEST(TYPE) \ |
| 25 |
do \ |
| 26 |
{ \ |
| 27 |
_Decimal##TYPE d##TYPE; \ |
| 28 |
d##TYPE = f1_##TYPE(g1_##TYPE); \ |
| 29 |
d##TYPE = f1_##TYPE(g2_##TYPE); \ |
| 30 |
d##TYPE = f2_##TYPE(h1_##TYPE); \ |
| 31 |
d##TYPE = f2_##TYPE(h2_##TYPE); \ |
| 32 |
d##TYPE = f2_##TYPE(h3_##TYPE); \ |
| 33 |
(void) d##TYPE; \ |
| 34 |
} while(0) |
| 35 |
|
| 36 |
DECIMAL_COMPOSITE_DECL(32); /* { dg-error "incompatible types when assigning to type '\[^\n\]*' from type '\[^\n\]*'" } */ |
| 37 |
/* { dg-message "note: expected '\[^'\n\]*' but argument is of type '\[^'\n\]*'" "note: expected" { target *-*-* } .-1 } */ |
| 38 |
|
| 39 |
|
| 40 |
DECIMAL_COMPOSITE_DECL(64); /* { dg-error "incompatible types when assigning to type '\[^\n\]*' from type '\[^\n\]*'" } */ |
| 41 |
/* { dg-message "note: expected '\[^'\n\]*' but argument is of type '\[^'\n\]*'" "note: expected" { target *-*-* } .-1 } */ |
| 42 |
|
| 43 |
|
| 44 |
DECIMAL_COMPOSITE_DECL(128); /* { dg-error "incompatible types when assigning to type '\[^\n\]*' from type '\[^\n\]*'" } */ |
| 45 |
/* { dg-message "note: expected '\[^'\n\]*' but argument is of type '\[^'\n\]*'" "note: expected" { target *-*-* } .-1 } */ |
| 46 |
|
| 47 |
|
| 48 |
int main() |
| 49 |
{ |
| 50 |
DECIMAL_COMPOSITE_TEST(32); /* { dg-warning "incompatible pointer type" } */ |
| 51 |
DECIMAL_COMPOSITE_TEST(64); /* { dg-warning "incompatible pointer type" } */ |
| 52 |
DECIMAL_COMPOSITE_TEST(128); /* { dg-warning "incompatible pointer type" } */ |
| 53 |
|
| 54 |
return 0; |
| 55 |
} |
| 56 |
|
| 57 |
/* The invalid function redeclarations might also trigger: |
| 58 |
{ dg-prune-output "-Warray-parameter" } */ |