view gcc/testsuite/g++.dg/warn/Walways-true-3.C @ 144:8f4e72ab4e11

fix segmentation fault caused by nothing next cur_op to end
author Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Sun, 23 Dec 2018 21:23:56 +0900
parents 04ced10e8804
children 1830386684a0
line wrap: on
line source

// PR c++/65168
// { dg-options "-Waddress" }

void foo (void);

int d;
int &c = d;

void
bar (int &a)
{
  int &b = a;

  if ((int *)&a) // { dg-warning "address of" }
    foo ();

  if (&b) // { dg-warning "address of" }
    foo ();

  if (!&c) // { dg-warning "address of" }
    foo ();

  if (!&(int &)(int &)a) // { dg-warning "address of" }
    foo ();

  if (&a == 0) // { dg-warning "never be NULL" }
    foo ();

  if (&b != 0) // { dg-warning "never be NULL" }
    foo ();

  if (0 == &(int &)(int &)c) // { dg-warning "never be NULL" }
    foo ();

  if (&a != (int *)0) // { dg-warning "never be NULL" }
    foo ();
}

bool
bar_1 (int &a)
{
  if (d == 5)
    return &a; // { dg-warning "address of" }
  else
    return !&(int &)(int &)a; // { dg-warning "address of" }
}