aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/ext/attr-nonnull.C
blob: c448bb07971f57b669a4470d243f45992dcbf85c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Bug c++/83871 - wrong code due to attributes on distinct template
// specializations
// Test to verify that an explicit function template specifialization
// does not "inherit" attribute nonnull from an argument declared with
// one in the primary template.
// { dg-do compile }
// { dg-options "-O -Wall" }

template <class T>
void __attribute__ ((nonnull (1)))
f (T*, T*, T*);

template <>
void
f<int>(int*, int*, int*);     // { dg-warning "may be missing attributes" }

template <>
void __attribute__ ((nonnull (3)))
f<float>(float*, float*, float*);


void test_nonnull (void)
{
  f<void>(0, 0, 0);           // { dg-warning "argument 1 null where non-null expected" }

  f<int>(0, 0, 0);            // { dg-bogus "null" }

  f<float>(0, 0, 0);
  // { dg-bogus "argument 1 null where non-null expected" "" { target *-*-* } .-1 }
  // { dg-warning "argument 3 null where non-null expected" "" { target *-*-* } .-2 }
}