view gcc/testsuite/c-c++-common/Wduplicated-cond-4.c @ 19:2b5abeee2509 default tip

update gcc11
author anatofuz
date Mon, 25 May 2020 07:50:57 +0900
parents 04ced10e8804
children
line wrap: on
line source

/* PR c/64249 */
/* { dg-do compile } */
/* { dg-options "-Wduplicated-cond" } */
/* Test we don't warn if a condition in an if-else-if chain
   has a side-effect.  E.g. __cxxabiv1::__cxa_end_catch ()
   uses such a construction.  */

extern int a, bar (void);

int
fn1 (void)
{
  if (a)
    return 1;
  else if (bar ())
    return 2;
  else if (a)
    return 3;
  return 0;
}

int
fn2 (int c)
{
  if (c < 0)
    return 1;
  else if (--c == 0)
    return 2;
  else if (c < 0)
    return 3;
  return 0;
}