diff options
author | David Malcolm <dmalcolm@redhat.com> | 2016-03-11 19:54:43 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2016-03-11 19:54:43 +0000 |
commit | 3edc5da4a6b61d9184f1211037ab669897d1eef2 (patch) | |
tree | 40f4da9477e6333973c319c85d42a61e24a3482f /gcc | |
parent | 318c1204185bb06f51056ff875180b874baf4ce4 (diff) | |
download | gcc-3edc5da4a6b61d9184f1211037ab669897d1eef2.zip gcc-3edc5da4a6b61d9184f1211037ab669897d1eef2.tar.gz gcc-3edc5da4a6b61d9184f1211037ab669897d1eef2.tar.bz2 |
Wmisleading-indentation.c: add more test cases for PR c/68187
gcc/testsuite/ChangeLog:
PR c/68187
* c-c++-common/Wmisleading-indentation.c (test43_a): New test
case.
(test43_b): Likewise.
(test43_c): Likewise.
(test43_d): Likewise.
(test43_e): Likewise.
(test43_f): Likewise.
(test43_g): Likewise.
(test44_a): Likewise.
(test44_b): Likewise.
(test44_c): Likewise.
(test44_d): Likewise.
(test44_e): Likewise.
From-SVN: r234146
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/ChangeLog | 17 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/Wmisleading-indentation.c | 168 |
2 files changed, 185 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 34a61a3..f42e943 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,22 @@ 2016-03-11 David Malcolm <dmalcolm@redhat.com> + PR c/68187 + * c-c++-common/Wmisleading-indentation.c (test43_a): New test + case. + (test43_b): Likewise. + (test43_c): Likewise. + (test43_d): Likewise. + (test43_e): Likewise. + (test43_f): Likewise. + (test43_g): Likewise. + (test44_a): Likewise. + (test44_b): Likewise. + (test44_c): Likewise. + (test44_d): Likewise. + (test44_e): Likewise. + +2016-03-11 David Malcolm <dmalcolm@redhat.com> + PR c/70085 * c-c++-common/Wmisleading-indentation.c (pr70085): New test case. diff --git a/gcc/testsuite/c-c++-common/Wmisleading-indentation.c b/gcc/testsuite/c-c++-common/Wmisleading-indentation.c index 38c8aec..ba512e7 100644 --- a/gcc/testsuite/c-c++-common/Wmisleading-indentation.c +++ b/gcc/testsuite/c-c++-common/Wmisleading-indentation.c @@ -1070,3 +1070,171 @@ int pr70085 (int x, int y) return -1; } #undef ENABLE_FEATURE + +/* Additional test coverage for PR c/68187, with various locations for a + pair of aligned statements ("foo (2);" and "foo (3);") that may or may + not be misleadingly indented. */ + +/* Before the "}". + + The two statements aren't visually "within" the above line, so we + shouldn't warn. */ + +void +test43_a (void) +{ + if (flagA) { + foo (1); + } else if (flagB) + foo (2); + foo (3); +} + +/* Aligned with the "}". + + Again, the two statements aren't visually "within" the above line, so we + shouldn't warn. */ + +void +test43_b (void) +{ + if (flagA) { + foo (1); + } else if (flagB) + foo (2); + foo (3); +} + +/* Indented between the "}" and the "else". + + The two statements are indented "within" the line above, so appear that + they would be guarded together. We should warn about this. */ + +void +test43_c (void) +{ + if (flagA) { + foo (1); + } else if (flagB) /* { dg-message "...this .if. clause" } */ + foo (2); + foo (3); /* { dg-warning "statement is indented" } */ +} + +/* Aligned with the "else". Likewise, we should warn. */ + +void +test43_d (void) +{ + if (flagA) { + foo (1); + } else if (flagB) /* { dg-message "...this .if. clause" } */ + foo (2); + foo (3); /* { dg-warning "statement is indented" } */ +} + +/* Indented between the "else" and the "if". Likewise, we should warn. */ + +void +test43_e (void) +{ + if (flagA) { + foo (1); + } else if (flagB) /* { dg-message "...this .if. clause" } */ + foo (2); + foo (3); /* { dg-warning "statement is indented" } */ +} + +/* Aligned with the "if". Likewise, we should warn. */ + +void +test43_f (void) +{ + if (flagA) { + foo (1); + } else if (flagB) /* { dg-message "...this .else. clause" } */ + foo (2); + foo (3); /* { dg-warning "statement is indented" } */ +} + +/* Indented more than the "if". Likewise, we should warn. */ + +void +test43_g (void) +{ + if (flagA) { + foo (1); + } else if (flagB) /* { dg-message "...this .if. clause" } */ + foo (2); + foo (3); /* { dg-warning "statement is indented" } */ +} + +/* Again, but without the 2nd "if". */ + +/* Before the "}". + + As before, the two statements aren't visually "within" the above line, + so we shouldn't warn. */ + +void +test44_a (void) +{ + if (flagA) { + foo (1); + } else + foo (2); + foo (3); +} + +/* Aligned with the "}". + + As before, the two statements aren't visually "within" the above line, + so we shouldn't warn. */ + +void +test44_b (void) +{ + if (flagA) { + foo (1); + } else + foo (2); + foo (3); +} + +/* Indented between the "}" and the "else". + + The two statements are indented "within" the line above, so appear that + they would be guarded together. We should warn about this. */ + +void +test44_c (void) +{ + if (flagA) { + foo (1); + } else /* { dg-message "...this .else. clause" } */ + foo (2); + foo (3); /* { dg-warning "statement is indented" } */ +} + +/* Aligned with the "else". Likewise, we should warn. */ + +void +test44_d (void) +{ + if (flagA) { + foo (1); + } else /* { dg-message "...this .else. clause" } */ + foo (2); + foo (3); /* { dg-warning "statement is indented" } */ +} + +/* Indented more than the "else". Likewise, we should warn. */ + +void +test44_e (void) +{ + if (flagA) { + foo (1); + } else /* { dg-message "...this .else. clause" } */ + foo (2); + foo (3); /* { dg-warning "statement is indented" } */ +} |