Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/g++.dg/warn/Wnull-conversion-2.C @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | |
children | 84e7813d76e9 |
comparison
equal
deleted
inserted
replaced
68:561a7518be6b | 111:04ced10e8804 |
---|---|
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 | |
37 main() | |
38 { | |
39 int *p = &x; | |
40 | |
41 Foo::Compare(0, *p); | |
42 Foo::Compare<long int, int>(NULL, p); // { dg-warning "passing NULL to" } | |
43 Foo::Compare(NULL, p); | |
44 func1(NULL); // { dg-warning "passing NULL to" } | |
45 } |