Revision 69d5d21f scripts/checkpatch.pl

b/scripts/checkpatch.pl
1363 1363
# Check for incorrect file permissions
1364 1364
		if ($line =~ /^new (file )?mode.*[7531]\d{0,2}$/) {
1365 1365
			my $permhere = $here . "FILE: $realfile\n";
1366
			if ($realfile =~ /(Makefile|Kconfig|\.c|\.h|\.S|\.tmpl)$/) {
1366
			if ($realfile =~ /(Makefile|Kconfig|\.c|\.cpp|\.h|\.S|\.tmpl)$/) {
1367 1367
				ERROR("do not set execute permissions for source files\n" . $permhere);
1368 1368
			}
1369 1369
		}
......
1460 1460
		}
1461 1461

  
1462 1462
# check we are in a valid source file if not then ignore this hunk
1463
		next if ($realfile !~ /\.(h|c|s|S|pl|sh)$/);
1463
		next if ($realfile !~ /\.(h|c|cpp|s|S|pl|sh)$/);
1464 1464

  
1465 1465
#80 column limit
1466 1466
		if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ &&
......
1495 1495
		}
1496 1496

  
1497 1497
# check we are in a valid source file C or perl if not then ignore this hunk
1498
		next if ($realfile !~ /\.(h|c|pl)$/);
1498
		next if ($realfile !~ /\.(h|c|cpp|pl)$/);
1499 1499

  
1500 1500
# in QEMU, no tabs are allowed
1501 1501
		if ($rawline =~ /^\+.*\t/) {
......
1505 1505
		}
1506 1506

  
1507 1507
# check we are in a valid C source file if not then ignore this hunk
1508
		next if ($realfile !~ /\.(h|c)$/);
1508
		next if ($realfile !~ /\.(h|c|cpp)$/);
1509 1509

  
1510 1510
# check for RCS/CVS revision markers
1511 1511
		if ($rawline =~ /^\+.*\$(Revision|Log|Id)(?:\$|)/) {
......
1969 1969
				asm|__asm__)$/x)
1970 1970
			{
1971 1971

  
1972
			# Ignore 'catch (...)' in C++
1973
			} elsif ($name =~ /^catch$/ && $realfile =~ /(\.cpp|\.h)$/) {
1974

  
1972 1975
			# cpp #define statements have non-optional spaces, ie
1973 1976
			# if there is a space between the name and the open
1974 1977
			# parenthesis it is simply not a parameter group.
......
1992 1995
				\+=|-=|\*=|\/=|%=|\^=|\|=|&=|
1993 1996
				=>|->|<<|>>|<|>|=|!|~|
1994 1997
				&&|\|\||,|\^|\+\+|--|&|\||\+|-|\*|\/|%|
1995
				\?|:
1998
				\?|::|:
1996 1999
			}x;
1997 2000
			my @elements = split(/($ops|;)/, $opline);
1998 2001
			my $off = 0;
......
2062 2065
				# // is a comment
2063 2066
				} elsif ($op eq '//') {
2064 2067

  
2068
				# Ignore : used in class declaration in C++
2069
				} elsif ($opv eq ':B' && $ctx =~ /Wx[WE]/ &&
2070
						 $line =~ /class/ && $realfile =~ /(\.cpp|\.h)$/) {
2071

  
2065 2072
				# No spaces for:
2066 2073
				#   ->
2067 2074
				#   :   when part of a bitfield
......
2088 2095
				} elsif ($op eq '!' || $op eq '~' ||
2089 2096
					 $opv eq '*U' || $opv eq '-U' ||
2090 2097
					 $opv eq '&U' || $opv eq '&&U') {
2091
					if ($ctx !~ /[WEBC]x./ && $ca !~ /(?:\)|!|~|\*|-|\&|\||\+\+|\-\-|\{)$/) {
2098
					if ($op eq '~' && $ca =~ /::$/ && $realfile =~ /(\.cpp|\.h)$/) {
2099
						# '~' used as a name of Destructor
2100

  
2101
					} elsif ($ctx !~ /[WEBC]x./ && $ca !~ /(?:\)|!|~|\*|-|\&|\||\+\+|\-\-|\{)$/) {
2092 2102
						ERROR("space required before that '$op' $at\n" . $hereptr);
2093 2103
					}
2094 2104
					if ($op eq '*' && $cc =~/\s*$Modifier\b/) {
......
2135 2145
				} elsif ($ctx !~ /[EWC]x[CWE]/) {
2136 2146
					my $ok = 0;
2137 2147

  
2148
					if ($realfile =~ /\.cpp|\.h$/) {
2149
						# Ignore template arguments <...> in C++
2150
						if (($op eq '<' || $op eq '>') && $line =~ /<.*>/) {
2151
							$ok = 1;
2152
						}
2153

  
2154
						# Ignore :: in C++
2155
						if ($op eq '::') {
2156
							$ok = 1;
2157
						}
2158
					}
2159

  
2138 2160
					# Ignore email addresses <foo@bar>
2139 2161
					if (($op eq '<' &&
2140 2162
					     $cc =~ /^\S+\@\S+>/) ||

Also available in: Unified diff