From 6b95d7cc2d5ba73f698a4f0439cdff2145583df2 Mon Sep 17 00:00:00 2001 From: Patrick Palka Date: Thu, 24 Sep 2015 01:55:59 +0000 Subject: Fix a -Wmisleading-indentation false-negative 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 | 6 ++++++ gcc/c-family/c-indentation.c | 2 +- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/c-c++-common/Wmisleading-indentation.c | 9 +++++++++ 4 files changed, 20 insertions(+), 1 deletion(-) (limited to 'gcc') diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 8d4df76..e409150 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2015-09-24 Patrick Palka + + * 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 PR c/49654 diff --git a/gcc/c-family/c-indentation.c b/gcc/c-family/c-indentation.c index 5316316..5b119f7 100644 --- a/gcc/c-family/c-indentation.c +++ b/gcc/c-family/c-indentation.c @@ -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; } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index fa93d62..f6f8e0e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2015-09-24 Patrick Palka + + * c-c++-common/Wmisleading-indentation.c: Augment test. + 2015-09-23 Ville Voutilainen Fix small typos in the coding rule enforcement warnings. diff --git a/gcc/testsuite/c-c++-common/Wmisleading-indentation.c b/gcc/testsuite/c-c++-common/Wmisleading-indentation.c index f61c182..00c0a50 100644 --- a/gcc/testsuite/c-c++-common/Wmisleading-indentation.c +++ b/gcc/testsuite/c-c++-common/Wmisleading-indentation.c @@ -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 } -- cgit v1.1