Debian Codegraph @

gcc/testsuite/g++.dg/warn/Wduplicated-cond2.C

raw
1 // PR c++/105035
2 // { dg-do compile }
3 // { dg-options "-Wduplicated-cond" }
4
5 class A {
6 struct B { int c; int f; } e;
7 template <typename> void foo ();
8 void bar ();
9 };
10
11 template <typename> void
12 A::foo ()
13 {
14 int g;
15 if (&g == &e.c)
16 ;
17 else if (&g == &e.f)
18 ;
19 }
20
21 void
22 A::bar ()
23 {
24 int g;
25 if (&g == &e.c) // { dg-message "previously used here" }
26 ;
27 else if (&g == &e.c) // { dg-warning "duplicated 'if' condition" }
28 ;
29 }