Fix a -Wmisleading-indentation false-negative
authorPatrick Palka <ppalka@gcc.gnu.org>
Thu, 24 Sep 2015 01:55:59 +0000 (01:55 +0000)
committerPatrick Palka <ppalka@gcc.gnu.org>
Thu, 24 Sep 2015 01:55:59 +0000 (01:55 +0000)
gcc/c-family/ChangeLog:

* c-indentation.c (should_warn_for_misleading_indentation):
Compare next_stmt_vis_column with guard_line_first_nws instead
of with guard_line_vis_column.

gcc/testsuite/ChangeLog:

* c-c++-common/Wmisleading-indentation.c: Augment test.

From-SVN: r228071

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

index 8d4df7654b77f898b665fc243f829d274b4059ec..e409150ba613c2bd14bdfd46ae2900ca4d75bdaf 100644 (file)
@@ -1,3 +1,9 @@
+2015-09-24  Patrick Palka  <ppalka@gcc.gnu.org>
+
+       * c-indentation.c (should_warn_for_misleading_indentation):
+       Compare next_stmt_vis_column with guard_line_first_nws instead
+       of with guard_line_vis_column.
+
 2015-09-23  Manuel López-Ibáñez  <manu@gcc.gnu.org>
 
        PR c/49654
index 5316316da783f69f6be4b2ce471f18623bb1dbe7..5b119f790f0e057e91f5bd17701be0bf981eadad 100644 (file)
@@ -464,7 +464,7 @@ should_warn_for_misleading_indentation (const token_indent_info &guard_tinfo,
              {
                if (next_stmt_vis_column > guard_line_first_nws
                    || (next_tok_type == CPP_OPEN_BRACE
-                       && next_stmt_vis_column == guard_vis_column))
+                       && next_stmt_vis_column == guard_line_first_nws))
                  return true;
              }
          }
index fa93d62cb4c23f704418b8061ad3da0db13e8a3e..f6f8e0e62f18c92a5e3c9c6724b288ae56901d59 100644 (file)
@@ -1,3 +1,7 @@
+2015-09-24  Patrick Palka  <ppalka@gcc.gnu.org>
+
+       * c-c++-common/Wmisleading-indentation.c: Augment test.
+
 2015-09-23  Ville Voutilainen  <ville.voutilainen@gmail.com>
 
        Fix small typos in the coding rule enforcement warnings.
index f61c182c715a970f880ec1205d07607ea48a018a..00c0a505386fe318b3dff7ef3381f52a4473df05 100644 (file)
@@ -797,6 +797,15 @@ fn_37 (void)
        i++);
     foo (i); /* { dg-warning "statement is indented as if" } */
 
+  if (flagA)
+  {
+    foo (1);
+  }
+  else if (flagB); /* { dg-message "8: ...this 'if' clause" } */
+  { /* { dg-warning "statement is indented as if" } */
+    foo (2);
+  }
+
 #undef EMPTY
 #undef FOR_EACH
 }