PR c++/85553
[official-gcc.git] / gcc / testsuite / g++.dg / ext / attr-nonnull.C
blob5ef754ee37737538a83c8afafc121c6b5477ef4c
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" }
9 template <class T>
10 void __attribute__ ((nonnull (1)))
11 f (T*, T*, T*);
13 template <>
14 void
15 f<int>(int*, int*, int*);     // { dg-warning "may be missing attributes" }
17 template <>
18 void __attribute__ ((nonnull (3)))
19 f<float>(float*, float*, float*);
22 void test_nonnull (void)
24   f<void>(0, 0, 0);           // { dg-warning "null argument where non-null required \\\(argument 1\\\)" }
26   f<int>(0, 0, 0);            // { dg-bogus "null argument" }
28   f<float>(0, 0, 0);
29   // { dg-bogus "null argument where non-null required \\\(argument 1\\\)" "" { target *-*-* } .-1 }
30   // { dg-warning "null argument where non-null required \\\(argument 3\\\)" "" { target *-*-* } .-2 }