PR lto/84212 - -Wno-* does not disable warnings from -flto link stage
[official-gcc.git] / gcc / testsuite / g++.dg / warn / Wnull-conversion-2.C
blobd5501fface517269c2c309b98828ddbb6c0c2192
1 // { dg-do compile }
2 // { dg-options "-Wconversion-null" }
4 #include <stddef.h>
6 class Foo {
7  public:
8   template <typename T1, typename T2>
9   static void Compare(const T1& expected, const T2& actual) { }
11   template <typename T1, typename T2>
12   static void Compare(const T1& expected, T2* actual) { }
16 template<typename T1>
17 class Foo2 {
18  public:
19   Foo2(int x);
20   template<typename T2> void Bar(T2 y);
23 template<typename T3> void func(T3 x) { }
25 typedef Foo2<int> MyFooType;
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);
35 int x = 1;
37 int
38 main()
40   int *p = &x;
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" }
47   return 0;