summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authormsebor <msebor@138bc75d-0d04-0410-961f-82ee72b054a4>2016-03-07 17:01:44 +0000
committermsebor <msebor@138bc75d-0d04-0410-961f-82ee72b054a4>2016-03-07 17:01:44 +0000
commit1bbf98675d582b23f3be563bf74990c5fc537b3a (patch)
tree504ef735be3e4a39b29f39608ed088cd28f85a3b /contrib
parent9b8445029fe77f2feb2a383012280ee903b0ce60 (diff)
downloadgcc-1bbf98675d582b23f3be563bf74990c5fc537b3a.tar.gz
Add style checks to check_GNU_style.sh.
gcc/contrib/ChangeLog: 2016-03-07 Martin Sebor <msebor@redhat.com> * check_GNU_style.sh (color): New global variable. Add checks for trailing operators and spaces before left brackets. Tightened up a check for a trailing left curly brace. (g, ag, vg): Use color. (col): Don't complain about excessively long lines with DejaGnu directives. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@234035 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'contrib')
-rw-r--r--contrib/ChangeLog9
-rwxr-xr-xcontrib/check_GNU_style.sh38
2 files changed, 34 insertions, 13 deletions
diff --git a/contrib/ChangeLog b/contrib/ChangeLog
index e40db53ed64..54f9d5e72b2 100644
--- a/contrib/ChangeLog
+++ b/contrib/ChangeLog
@@ -1,3 +1,12 @@
+2016-03-07 Martin Sebor <msebor@redhat.com>
+
+ * check_GNU_style.sh (color): New global variable.
+ Add checks for trailing operators and spaces before left brackets.
+ Tightened up a check for a trailing left curly brace.
+ (g, ag, vg): Use color.
+ (col): Don't complain about excessively long lines with DejaGnu
+ directives.
+
2016-03-06 Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
* mklog: Look for the ChangeLog file in $cwd.
diff --git a/contrib/check_GNU_style.sh b/contrib/check_GNU_style.sh
index ac54ed070e7..fbf6cb2465d 100755
--- a/contrib/check_GNU_style.sh
+++ b/contrib/check_GNU_style.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Checks some of the GNU style formatting rules in a set of patches.
-# Copyright (C) 2010, 2012 Free Software Foundation, Inc.
+# Copyright (C) 2010, 2012, 2016 Free Software Foundation, Inc.
# Contributed by Sebastian Pop <sebastian.pop@amd.com>
# This program is free software; you can redistribute it and/or modify
@@ -15,8 +15,11 @@
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+# along with this program; if not, see the file COPYING3. If not,
+# see <http://www.gnu.org/licenses/>.
+
+# Set to empty in the environment to override.
+: ${color:---color=always}
usage() {
cat <<EOF
@@ -100,7 +103,7 @@ g (){
local found=false
cat $inp \
- | egrep --color=always -- "$arg" \
+ | egrep $color -- "$arg" \
> "$tmp" && found=true
if $found; then
@@ -117,8 +120,8 @@ ag (){
local found=false
cat $inp \
- | egrep --color=always -- "$arg1" \
- | egrep --color=always -- "$arg2" \
+ | egrep $color -- "$arg1" \
+ | egrep $color -- "$arg2" \
> "$tmp" && found=true
if $found; then
@@ -136,7 +139,7 @@ vg (){
local found=false
cat $inp \
| egrep -v -- "$varg" \
- | egrep --color=always -- "$arg" \
+ | egrep $color -- "$arg" \
> "$tmp" && found=true
if $found; then
@@ -171,10 +174,11 @@ col (){
# Expand tabs to spaces according to tab positions.
# Keep long lines, make short lines empty. Print the part past 80 chars
# in red.
+ # Don't complain about dg-xxx directives in tests.
cat "$tmp" \
| sed 's/^[0-9]*:+//' \
| expand \
- | awk '{ \
+ | awk '$0 !~ /{[[:space:]]*dg-(error|warning|message)[[:space:]]/ { \
if (length($0) > 80) \
printf "%s\033[1;31m%s\033[0m\n", \
substr($0,1,80), \
@@ -201,6 +205,7 @@ col (){
done
}
+
col 'Lines should not exceed 80 characters.'
g 'Blocks of 8 spaces should be replaced with tabs.' \
@@ -221,13 +226,20 @@ g 'Dot, space, space, end of comment.' \
g 'Sentences should end with a dot. Dot, space, space, end of the comment.' \
'[[:alnum:]][[:blank:]]*\*/'
-vg 'There should be exactly one space between function name and parentheses.' \
+vg 'There should be exactly one space between function name and parenthesis.' \
'\#define' \
'[[:alnum:]]([[:blank:]]{2,})?\('
-g 'There should be no space before closing parentheses.' \
+g 'There should be no space before a left square bracket.' \
+ '[[:alnum:]][[:blank:]]+\['
+
+g 'There should be no space before closing parenthesis.' \
'[[:graph:]][[:blank:]]+\)'
-ag 'Braces should be on a separate line.' \
- '\{' \
- 'if[[:blank:]]\(|while[[:blank:]]\(|switch[[:blank:]]\('
+# This will give false positives for C99 compound literals.
+g 'Braces should be on a separate line.' \
+ '(\)|else)[[:blank:]]*{'
+
+# Does this apply to definition of aggregate objects?
+g 'Trailing operator.' \
+ '(([^a-zA-Z_]\*)|([-%<=&|^?])|([^*]/)|([^:][+]))$'