aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2015-05-20 16:09:19 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2015-05-20 16:09:19 +0000
commitc3a630ce3e0b06654ec2cbae23182e2928e03143 (patch)
tree0859863a5483a4f50f4da9f86344e9e8c073852a /gcc
parente4129dd0c9ec71767eeae6ddb3f65f697c6d8140 (diff)
downloadgcc-c3a630ce3e0b06654ec2cbae23182e2928e03143.zip
gcc-c3a630ce3e0b06654ec2cbae23182e2928e03143.tar.gz
gcc-c3a630ce3e0b06654ec2cbae23182e2928e03143.tar.bz2
-Wmisleading-indentation: Increase test coverage
gcc/testsuite/ChangeLog: * c-c++-common/Wmisleading-indentation.c (fn_32): New. (fn_33_k_and_r_style): New. (fn_33_stroustrup_style): New. (fn_33_allman_style): New. (fn_33_whitesmiths_style): New. (fn_33_horstmann_style): New. (fn_33_ratliff_banner_style): New. (fn_33_lisp_style): New. (fn_34_indent_dash_gnu): New. (fn_34_indent_dash_kr): New. (fn_34_indent_dash_orig): New. (fn_34_indent_linux_style): New. From-SVN: r223447
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog15
-rw-r--r--gcc/testsuite/c-c++-common/Wmisleading-indentation.c224
2 files changed, 239 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 1a7a87c..28cc03c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,18 @@
+2015-05-20 David Malcolm <dmalcolm@redhat.com>
+
+ * c-c++-common/Wmisleading-indentation.c (fn_32): New.
+ (fn_33_k_and_r_style): New.
+ (fn_33_stroustrup_style): New.
+ (fn_33_allman_style): New.
+ (fn_33_whitesmiths_style): New.
+ (fn_33_horstmann_style): New.
+ (fn_33_ratliff_banner_style): New.
+ (fn_33_lisp_style): New.
+ (fn_34_indent_dash_gnu): New.
+ (fn_34_indent_dash_kr): New.
+ (fn_34_indent_dash_orig): New.
+ (fn_34_indent_linux_style): New.
+
2015-05-20 Andre Vehreschild <vehre@gmx.de>
PR fortran/65548
diff --git a/gcc/testsuite/c-c++-common/Wmisleading-indentation.c b/gcc/testsuite/c-c++-common/Wmisleading-indentation.c
index 3dbbb8b..6363d71 100644
--- a/gcc/testsuite/c-c++-common/Wmisleading-indentation.c
+++ b/gcc/testsuite/c-c++-common/Wmisleading-indentation.c
@@ -429,3 +429,227 @@ void fn_31 (void)
else
foo (3);
}
+
+/* Ensure that we can disable the warning. */
+int
+fn_32 (int flag)
+{
+ int x = 4, y = 5;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wmisleading-indentation"
+ if (flag)
+ x = 3;
+ y = 2;
+#pragma GCC diagnostic pop
+
+ return x * y;
+}
+
+/* Verify that a variety of different indentation styles are supported
+ without leading to warnings. */
+void
+fn_33_k_and_r_style (void)
+{
+ int i;
+ for (i = 0; i < 10; i++) {
+ if (flagB) {
+ foo(0);
+ foo(1);
+ } else {
+ foo(2);
+ foo(3);
+ }
+ foo(4);
+ }
+}
+
+void
+fn_33_stroustrup_style (void)
+{
+ int i;
+ for (i = 0; i < 10; i++) {
+ if (flagA) {
+ foo(0);
+ foo(1);
+ }
+ else {
+ foo(2);
+ foo(3);
+ }
+ foo(4);
+ }
+}
+
+void
+fn_33_allman_style (void)
+{
+ int i;
+ for (i = 0; i < 10; i++)
+ {
+ if (flagA)
+ {
+ foo(0);
+ foo(1);
+ }
+ else
+ {
+ foo(2);
+ foo(3);
+ }
+ foo(4);
+ }
+}
+
+void
+fn_33_whitesmiths_style (void)
+{
+ int i;
+ for (i = 0; i < 10; i++)
+ {
+ if (flagA)
+ {
+ foo(0);
+ foo(1);
+ }
+ else
+ {
+ foo(2);
+ foo(3);
+ }
+ foo(4);
+ }
+}
+
+void
+fn_33_horstmann_style (void)
+{
+ int i;
+ for (i = 0; i < 10; i++)
+ { if (flagA)
+ { foo(0);
+ foo(1);
+ }
+ else
+ { foo(2);
+ foo(3);
+ }
+ foo(4);
+ }
+}
+
+void
+fn_33_ratliff_banner_style (void)
+{
+ int i;
+ for (i = 0; i < 10; i++) {
+ if (flagA) {
+ foo(0);
+ foo(1);
+ }
+ else {
+ foo(2);
+ foo(3);
+ }
+ foo(4);
+ }
+}
+
+void
+fn_33_lisp_style (void)
+{
+ int i;
+ for (i = 0; i < 10; i++) {
+ if (flagA) {
+ foo(0);
+ foo(1); }
+ else {
+ foo(2);
+ foo(3); }
+ foo(4); }
+}
+
+/* A function run through GNU "indent" with various options.
+ None of these should lead to warnings. */
+
+/* "indent -gnu". */
+void
+fn_34_indent_dash_gnu (void)
+{
+ int i;
+ while (flagA)
+ for (i = 0; i < 10; i++)
+ {
+ if (flagB)
+ {
+ foo (0);
+ foo (1);
+ }
+ else
+ {
+ foo (2);
+ foo (3);
+ }
+ foo (4);
+ }
+ foo (5);
+}
+
+/* "indent -kr". */
+void fn_34_indent_dash_kr(void)
+{
+ int i;
+ while (flagA)
+ for (i = 0; i < 10; i++) {
+ if (flagB) {
+ foo(0);
+ foo(1);
+ } else {
+ foo(2);
+ foo(3);
+ }
+ foo(4);
+ }
+ foo(5);
+}
+
+/* "indent -orig". */
+void
+fn_34_indent_dash_orig(void)
+{
+ int i;
+ while (flagA)
+ for (i = 0; i < 10; i++) {
+ if (flagB) {
+ foo(0);
+ foo(1);
+ } else {
+ foo(2);
+ foo(3);
+ }
+ foo(4);
+ }
+ foo(5);
+}
+
+/* Linux style:
+ "indent \
+ -nbad -bap -nbc -bbo -hnl -br -brs -c33 -cd33 -ncdb -ce -ci4 \
+ -cli0 -d0 -di1 -nfc1 -i8 -ip0 -l80 -lp -npcs -nprs -npsl -sai \
+ -saf -saw -ncs -nsc -sob -nfca -cp33 -ss -ts8 -il1". */
+
+void fn_34_indent_linux_style(void)
+{
+ int i;
+ while (flagA)
+ for (i = 0; i < 10; i++) {
+ if (flagB) {
+ foo(0);
+ foo(1);
+ } else {
+ foo(2);
+ foo(3);
+ }
+ foo(4);
+ }
+ foo(5);
+}