view gcc/testsuite/g++.dg/warn/Wnonnull-compare-8.C @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 04ced10e8804
children
line wrap: on
line source

// PR c++/70295
// { dg-do compile }
// { dg-options "-O2 -Wnonnull-compare" }

struct A { A (); virtual ~A (); bool foo (bool); };
struct B : virtual public A { B (); virtual ~B (); };

bool
A::foo (bool x)
{
  if (x && dynamic_cast<B *>(this) != (B *) 0)	// { dg-bogus "nonnull argument" }
    return true;
  return false;
}