]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix -Wmisleading indentation false-positive for do-while statement
authorPatrick Palka <ppalka@gcc.gnu.org>
Sun, 10 Jan 2016 16:39:39 +0000 (16:39 +0000)
committerPatrick Palka <ppalka@gcc.gnu.org>
Sun, 10 Jan 2016 16:39:39 +0000 (16:39 +0000)
gcc/c-family/ChangeLog:

PR c++/69029
* c-indentation.c (should_warn_for_misleading_indentation):
Don't warn about do-while statements.

gcc/testsuite/ChangeLog:

PR c++/69029
* c-c++-common/Wisleading-indentation.c: Augment test.

From-SVN: r232202

gcc/c-family/ChangeLog
gcc/c-family/c-indentation.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/Wmisleading-indentation.c

index a2743d8f8d94ffdddac81269279846239a7b9043..d8282d9de470ab2d90f39e1945b88ee5039b5cf2 100644 (file)
@@ -1,4 +1,9 @@
-gcc/c-family/ChangeLog:
+2016-01-10  Patrick Palka  <ppalka@gcc.gnu.org>
+
+       PR c++/69029
+       * c-indentation.c (should_warn_for_misleading_indentation):
+       Don't warn about do-while statements.
+
 2016-01-07  Martin Sebor  <msebor@redhat.com>
 
        PR c/68966
index 3c09336d15ab4984504b5bb39ad2efc759a43ce0..cd9637dc3fe04ae3eed8d5464644403e84ea49cd 100644 (file)
@@ -202,6 +202,12 @@ 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)
+    return false;
+
   /* If the token following the body is a close brace or an "else"
      then while indentation may be sloppy, there is not much ambiguity
      about control flow, e.g.
index f233bb923efbe4b1b26c8b8e427c6245f963b2f7..615a527e1ce32bb03e3c3dbc80268514599985b2 100644 (file)
@@ -1,3 +1,8 @@
+2016-01-10  Patrick Palka  <ppalka@gcc.gnu.org>
+
+       PR c++/69029
+       * c-c++-common/Wisleading-indentation.c: Augment test.
+
 2016-01-10  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR fortran/69154
index 491291c171cca22f3a4f91618210166ecf0886a5..25db8fe8412ffd5e329998dbe39b32a7e42a2f45 100644 (file)
@@ -890,6 +890,8 @@ fn_39 (void)
        i < 10;
        i++);
   foo (i);
+
+  do foo (0); while (flagA);
 }
 
 /* We shouldn't complain about the following function.  */