Daily bump.
[gcc.git] / gcc / testsuite / g++.dg / warn / Wnonnull14.C
blob16d7ec3f573425b7d5bc9af1884dca76ba0c40df
1 /* PR middle-end/100684 - spurious -Wnonnull with -O1 on a C++ lambda
2    { dg-do compile { target c++11 } }
3    { dg-options "-Og -Wall -fsanitize=undefined" } */
5 #define NONNULL  __attribute__ ((nonnull))
7 typedef int F (const char *);
9 __attribute__ ((nonnull)) int f (const char *);
11 int nowarn_Og ()
13   return static_cast<F*>([](const char *s){ return f (s); })("Og");
14   // { dg-bogus "'this' pointer is null" "" { target *-*-* } .-1 }
17 int warn_Og ()
19   return static_cast<F*>([] NONNULL (const char *){ return 0; })(0);
20   // { dg-warning "\\\[-Wnonnull" "" { target *-*-* } .-1 }
23 int warn_Og_inline ()
25   const char *p = 0;
26   return static_cast<F*>([](const char *s){ return f (s); })(p);
27   // { dg-warning "\\\[-Wnonnull" "lambda not inlined" { xfail *-*-* } .-1 }