blob: 6ce7605c55ce91f91509c457cc91be7ce1d04fd4 (
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
// { dg-do compile }
// { dg-options "-Wconversion-null" }
#include <stddef.h>
class Foo
{
public:
template < typename T1, typename T2 >
static void Compare (const T1 & expected, const T2 & actual)
{
}
template < typename T1, typename T2 >
static void Compare (const T1 & expected, T2 * actual)
{
}
};
template < typename T1 > class Foo2
{
public:
Foo2 (int x);
template < typename T2 > void Bar (T2 y);
};
template < typename T3 > void
func (T3 x)
{
}
typedef Foo2 < int >MyFooType;
void
func1 (long int a)
{
MyFooType *foo2 = new MyFooType (NULL); // { dg-warning "passing NULL to" }
foo2->Bar (a);
func (NULL);
func < int >(NULL); // { dg-warning "passing NULL to" }
func < int *>(NULL);
}
int x = 1;
main ()
{
int *p = &x;
Foo::Compare (0, *p);
Foo::Compare < long int, int >(NULL, p); // { dg-warning "passing NULL to" }
Foo::Compare (NULL, p);
func1 (NULL); // { dg-warning "passing NULL to" }
}
|