re PR c++/70639 (internal compiler error: in guard_tinfo_to_string, at c-family/c...
authorMarek Polacek <polacek@redhat.com>
Wed, 13 Apr 2016 16:28:46 +0000 (16:28 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Wed, 13 Apr 2016 16:28:46 +0000 (16:28 +0000)
PR c++/70639
* c-indentation.c (should_warn_for_misleading_indentation): Bail out
for switch statements, too.

* c-c++-common/Wmisleading-indentation-4.c: New test.

From-SVN: r234952

gcc/c-family/ChangeLog
gcc/c-family/c-indentation.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/Wmisleading-indentation-4.c [new file with mode: 0644]

index 26b1dabd6eed8010634f5aa47b0330ea073ef0b4..f842efc8d4e39ed3c8279291e8417e00f675ae51 100644 (file)
@@ -1,3 +1,9 @@
+2016-04-13  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/70639
+       * c-indentation.c (should_warn_for_misleading_indentation): Bail out
+       for switch statements, too.
+
 2016-03-28  Jason Merrill  <jason@redhat.com>
 
        * c-cppbuiltin.c (c_cpp_builtins): Update __cpp_range_based_for.
index 1da3f6824c1f5fcb9ed17dbcb823ef864b32aa79..8c336867d8c135f33e196f0dc9100b38213a3a00 100644 (file)
@@ -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"
index 6edb320c4e2bd65a8f1171db985f791b762ed621..c8061135327f0cc6f3f83d22100cba5fc6a1e434 100644 (file)
@@ -1,3 +1,8 @@
+2016-04-13  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/70639
+       * c-c++-common/Wmisleading-indentation-4.c: New test.
+
 2016-04-13  Marek Polacek  <polacek@redhat.com>
 
        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 (file)
index 0000000..d15a479
--- /dev/null
@@ -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);
+}