111
|
1 // { dg-do compile }
|
|
2 // { dg-options "-Wconversion-null" }
|
|
3
|
|
4 #include <stddef.h>
|
|
5
|
|
6 class Foo {
|
|
7 public:
|
|
8 template <typename T1, typename T2>
|
|
9 static void Compare(const T1& expected, const T2& actual) { }
|
|
10
|
|
11 template <typename T1, typename T2>
|
|
12 static void Compare(const T1& expected, T2* actual) { }
|
|
13
|
|
14 };
|
|
15
|
|
16 template<typename T1>
|
|
17 class Foo2 {
|
|
18 public:
|
|
19 Foo2(int x);
|
|
20 template<typename T2> void Bar(T2 y);
|
|
21 };
|
|
22
|
|
23 template<typename T3> void func(T3 x) { }
|
|
24
|
|
25 typedef Foo2<int> MyFooType;
|
|
26
|
|
27 void func1(long int a) {
|
|
28 MyFooType *foo2 = new MyFooType(NULL); // { dg-warning "passing NULL to" }
|
|
29 foo2->Bar(a);
|
|
30 func(NULL);
|
|
31 func<int>(NULL); // { dg-warning "passing NULL to" }
|
|
32 func<int *>(NULL);
|
|
33 }
|
|
34
|
|
35 int x = 1;
|
|
36
|
131
|
37 int
|
111
|
38 main()
|
|
39 {
|
|
40 int *p = &x;
|
|
41
|
|
42 Foo::Compare(0, *p);
|
|
43 Foo::Compare<long int, int>(NULL, p); // { dg-warning "passing NULL to" }
|
|
44 Foo::Compare(NULL, p);
|
|
45 func1(NULL); // { dg-warning "passing NULL to" }
|
131
|
46
|
|
47 return 0;
|
111
|
48 }
|