aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/Wduplicated-branches-7.c
blob: 03721dc4cb632292fcf2576f761b44f5e548f9f8 (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
33
34
35
36
/* PR c/64279 */
/* { dg-do compile } */
/* { dg-options "-Wduplicated-branches" } */

struct S
{
  int x;
} s;
int a[10];

#define XMEM(R) ((R).x)
#define XSTR(R) ((R).x)

void
f (int i)
{
  if (i)
    XMEM(s) = 1;
  else
    XSTR(s) = 1;

  if (i) /* { dg-warning "this condition has identical branches" } */
    s.x = 1;
  else
    s.x = 1;

  if (i)
    XMEM(s) = 1;
  else
    s.x = 1;

  if (i)
    s.x = 1;
  else
    XMEM(s) = 1;
}