aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/Wduplicated-cond-4.c
blob: 4fb7e174848f9c69b9c5b8450f44efaac1bf4340 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* 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;
}