| 1 |
// { dg-options "-fdiagnostics-show-template-tree" } |
| 2 |
|
| 3 |
/* Example of default template args, and various kinds of mismatch. */ |
| 4 |
|
| 5 |
template <int = 0, int = 1, int = 2> |
| 6 |
struct s {}; |
| 7 |
|
| 8 |
void takes_s (s<> ); |
| 9 |
void takes_s013 (s<0, 1, 3> ); |
| 10 |
void takes_s321 (s<3, 2, 1> ); |
| 11 |
|
| 12 |
void test () |
| 13 |
{ |
| 14 |
takes_s (s<>()); |
| 15 |
takes_s (s<0, 1>()); |
| 16 |
takes_s (s<0, 1, 2>()); |
| 17 |
takes_s (s<0, 2>()); // { dg-error "could not convert '.*' from 's<.\\.\\.\\..,2>' to 's<.\\.\\.\\..,1>'" } |
| 18 |
/* { dg-begin-multiline-output "" } |
| 19 |
s< |
| 20 |
[...], |
| 21 |
[2 != 1]> |
| 22 |
{ dg-end-multiline-output "" } */ |
| 23 |
|
| 24 |
takes_s (s<1>()); // { dg-error "could not convert '.*' from 's<1>' to 's<0>'" } |
| 25 |
/* { dg-begin-multiline-output "" } |
| 26 |
s< |
| 27 |
[1 != 0]> |
| 28 |
{ dg-end-multiline-output "" } */ |
| 29 |
|
| 30 |
takes_s (s<0, 1, 3>()); // { dg-error "could not convert '.*' from 's<.\\.\\.\\..,.\\.\\.\\..,3>' to 's<.\\.\\.\\..,.\\.\\.\\..,2>'" } |
| 31 |
/* { dg-begin-multiline-output "" } |
| 32 |
s< |
| 33 |
[...], |
| 34 |
[...], |
| 35 |
[3 != 2]> |
| 36 |
{ dg-end-multiline-output "" } */ |
| 37 |
|
| 38 |
takes_s (s<3, 2, 0>()); // { dg-error "could not convert '.*' from 's<3,2,0>' to 's<0,1,2>'" } |
| 39 |
/* { dg-begin-multiline-output "" } |
| 40 |
s< |
| 41 |
[3 != 0], |
| 42 |
[2 != 1], |
| 43 |
[0 != 2]> |
| 44 |
{ dg-end-multiline-output "" } */ |
| 45 |
|
| 46 |
takes_s (s<3, 2, 1>()); // { dg-error "could not convert '.*' from 's<3,2,1>' to 's<0,1,2>'" } |
| 47 |
/* { dg-begin-multiline-output "" } |
| 48 |
s< |
| 49 |
[3 != 0], |
| 50 |
[2 != 1], |
| 51 |
[1 != 2]> |
| 52 |
{ dg-end-multiline-output "" } */ |
| 53 |
|
| 54 |
takes_s013 (s<0, 1, 2>()); // { dg-error "could not convert '.*' from 's<.\\.\\.\\..,.\\.\\.\\..,2>' to 's<.\\.\\.\\..,.\\.\\.\\..,3>'" } |
| 55 |
/* { dg-begin-multiline-output "" } |
| 56 |
s< |
| 57 |
[...], |
| 58 |
[...], |
| 59 |
[2 != 3]> |
| 60 |
{ dg-end-multiline-output "" } */ |
| 61 |
|
| 62 |
takes_s321 (s<>()); // { dg-error "could not convert '.*' from 's<0,1,2>' to 's<3,2,1>'" } |
| 63 |
/* { dg-begin-multiline-output "" } |
| 64 |
s< |
| 65 |
[0 != 3], |
| 66 |
[1 != 2], |
| 67 |
[2 != 1]> |
| 68 |
{ dg-end-multiline-output "" } */ |
| 69 |
|
| 70 |
takes_s321 (s<0, 1, 3>()); // { dg-error "could not convert '.*' from 's<0,1,3>' to 's<3,2,1>'" } |
| 71 |
/* { dg-begin-multiline-output "" } |
| 72 |
s< |
| 73 |
[0 != 3], |
| 74 |
[1 != 2], |
| 75 |
[3 != 1]> |
| 76 |
{ dg-end-multiline-output "" } */ |
| 77 |
|
| 78 |
takes_s321 (s<3, 2, 0>()); // { dg-error "could not convert '.*' from 's<.\\.\\.\\..,.\\.\\.\\..,0>' to 's<.\\.\\.\\..,.\\.\\.\\..,1>'" } |
| 79 |
/* { dg-begin-multiline-output "" } |
| 80 |
s< |
| 81 |
[...], |
| 82 |
[...], |
| 83 |
[0 != 1]> |
| 84 |
{ dg-end-multiline-output "" } */ |
| 85 |
|
| 86 |
takes_s321 (s<3, 2, 1>()); |
| 87 |
|
| 88 |
takes_s321 (s<1, 2, 3>()); // { dg-error "could not convert '.*' from 's<1,.\\.\\.\\..,3>' to 's<3,.\\.\\.\\..,1>'" } |
| 89 |
/* { dg-begin-multiline-output "" } |
| 90 |
s< |
| 91 |
[1 != 3], |
| 92 |
[...], |
| 93 |
[3 != 1]> |
| 94 |
{ dg-end-multiline-output "" } */ |
| 95 |
} |