From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 36448 invoked by alias); 11 Mar 2016 20:05:12 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 36385 invoked by uid 89); 11 Mar 2016 20:05:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=clause, indented, visually, sum X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 11 Mar 2016 20:05:00 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id C6FF3C075660 for ; Fri, 11 Mar 2016 20:04:59 +0000 (UTC) Received: from c64.redhat.com (vpn-230-176.phx2.redhat.com [10.3.230.176]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2BK4w8x012893; Fri, 11 Mar 2016 15:04:59 -0500 From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [committed 2/2] Wmisleading-indentation.c: add more test cases for PR c/68187 Date: Fri, 11 Mar 2016 20:05:00 -0000 Message-Id: <1457728075-11443-2-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1457728075-11443-1-git-send-email-dmalcolm@redhat.com> References: <1457020600.1637.29.camel@redhat.com> <1457728075-11443-1-git-send-email-dmalcolm@redhat.com> X-IsSubscribed: yes X-SW-Source: 2016-03/txt/msg00712.txt.bz2 I posted a series of tests here: https://gcc.gnu.org/ml/gcc-patches/2016-03/msg00271.html as part of the discussion around PR c/68187. I've cleaned them into DejaGnu form and added them to the existing test file; they add 16 PASS results to gcc.sum and 48 PASS results to g++.sum. Committed to trunk as r234146 (as "obvious"). 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. --- .../c-c++-common/Wmisleading-indentation.c | 168 +++++++++++++++++++++ 1 file changed, 168 insertions(+) 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" } */ +} -- 1.8.5.3