From c3a630ce3e0b06654ec2cbae23182e2928e03143 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Wed, 20 May 2015 16:09:19 +0000 Subject: [PATCH] -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 --- gcc/testsuite/ChangeLog | 15 ++ .../c-c++-common/Wmisleading-indentation.c | 224 ++++++++++++++++++ 2 files changed, 239 insertions(+) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1a7a87cae95..28cc03c04d5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,18 @@ +2015-05-20 David Malcolm + + * 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 PR fortran/65548 diff --git a/gcc/testsuite/c-c++-common/Wmisleading-indentation.c b/gcc/testsuite/c-c++-common/Wmisleading-indentation.c index 3dbbb8b17d3..6363d71fe7f 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); +} -- 2.30.2