1 // RUN: %clang_cc1 -fsyntax-only -verify -Wdangling-else %s
3 void f(int a
, int b
, int c
, int d
, int e
) {
6 { if (a
) if (b
) d
++; else e
++; } // expected-warning {{add explicit braces to avoid dangling else}}
7 { if (a
) while (b
) if (c
) d
++; else e
++; } // expected-warning {{add explicit braces to avoid dangling else}}
8 { if (a
) switch (b
) if (c
) d
++; else e
++; } // expected-warning {{add explicit braces to avoid dangling else}}
9 { if (a
) for (;;) if (c
) d
++; else e
++; } // expected-warning {{add explicit braces to avoid dangling else}}
10 { if (a
) if (b
) if (d
) d
++; else e
++; else d
--; } // expected-warning {{add explicit braces to avoid dangling else}}
15 } else e
++; // expected-warning {{add explicit braces to avoid dangling else}}
18 { if (a
) if (b
) d
++; }
19 { if (a
) if (b
) if (c
) d
++; }
20 { if (a
) if (b
) d
++; else e
++; else d
--; }
21 { if (a
) if (b
) if (d
) d
++; else e
++; else d
--; else e
--; }
22 { if (a
) do if (b
) d
++; else e
++; while (c
); }
34 // Somewhat more elaborate case that shouldn't warn.
37 void operator<<(const char* s
) {}
40 void HandleDisabledThing() {}
41 A
GetThing() { return A(); }
46 HandleDisabledThing(); \
53 FOO(x
) << "hello"; // no warning