| 1 |
// Bug c++/83871 - wrong code due to attributes on distinct template |
| 2 |
// specializations |
| 3 |
// Test to verify that an explicit function template specifialization |
| 4 |
// does not "inherit" attribute nonnull from an argument declared with |
| 5 |
// one in the primary template. |
| 6 |
// { dg-do compile } |
| 7 |
// { dg-options "-O -Wall" } |
| 8 |
|
| 9 |
template <class T> |
| 10 |
void __attribute__ ((nonnull (1))) |
| 11 |
f (T*, T*, T*); |
| 12 |
|
| 13 |
template <> |
| 14 |
void |
| 15 |
f<int>(int*, int*, int*); // { dg-warning "may be missing attributes" } |
| 16 |
|
| 17 |
template <> |
| 18 |
void __attribute__ ((nonnull (3))) |
| 19 |
f<float>(float*, float*, float*); |
| 20 |
|
| 21 |
|
| 22 |
void test_nonnull (void) |
| 23 |
{ |
| 24 |
f<void>(0, 0, 0); // { dg-warning "argument 1 null where non-null expected" } |
| 25 |
|
| 26 |
f<int>(0, 0, 0); // { dg-bogus "null" } |
| 27 |
|
| 28 |
f<float>(0, 0, 0); |
| 29 |
// { dg-bogus "argument 1 null where non-null expected" "" { target *-*-* } .-1 } |
| 30 |
// { dg-warning "argument 3 null where non-null expected" "" { target *-*-* } .-2 } |
| 31 |
} |