diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 26b1dabd6ee..f842efc8d4e 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2016-04-13 Marek Polacek + + PR c++/70639 + * c-indentation.c (should_warn_for_misleading_indentation): Bail out + for switch statements, too. + 2016-03-28 Jason Merrill * c-cppbuiltin.c (c_cpp_builtins): Update __cpp_range_based_for. diff --git a/gcc/c-family/c-indentation.c b/gcc/c-family/c-indentation.c index 1da3f6824c1..8c336867d8c 100644 --- a/gcc/c-family/c-indentation.c +++ b/gcc/c-family/c-indentation.c @@ -239,10 +239,11 @@ should_warn_for_misleading_indentation (const token_indent_info &guard_tinfo, if (line_table->seen_line_directive) return false; - /* We can't usefully warn about do-while statements since the bodies of these - statements are always explicitly delimited at both ends, so control flow is - quite obvious. */ - if (guard_tinfo.keyword == RID_DO) + /* We can't usefully warn about do-while and switch statements since the + bodies of these statements are always explicitly delimited at both ends, + so control flow is quite obvious. */ + if (guard_tinfo.keyword == RID_DO + || guard_tinfo.keyword == RID_SWITCH) return false; /* If the token following the body is a close brace or an "else" diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6edb320c4e2..c8061135327 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-04-13 Marek Polacek + + PR c++/70639 + * c-c++-common/Wmisleading-indentation-4.c: New test. + 2016-04-13 Marek Polacek PR c/70436 diff --git a/gcc/testsuite/c-c++-common/Wmisleading-indentation-4.c b/gcc/testsuite/c-c++-common/Wmisleading-indentation-4.c new file mode 100644 index 00000000000..d15a4793da4 --- /dev/null +++ b/gcc/testsuite/c-c++-common/Wmisleading-indentation-4.c @@ -0,0 +1,11 @@ +/* PR c++/70639 */ +/* { dg-do compile } */ +/* { dg-options "-Wmisleading-indentation" } */ + +void bar (int); +void +foo (int x) +{ + switch (x); + bar (x); +}